1package config
 2
 3import (
 4	"bytes"
 5	"text/template"
 6)
 7
 8var configFileTmpl = template.Must(template.New("config").Parse(`# Soft Serve Server configurations
 9
10# The name of the server.
11# This is the name that will be displayed in the UI.
12name: "{{ .Name }}"
13
14# Logging configuration.
15log:
16  # Log format to use. Valid values are "json", "logfmt", and "text".
17  format: "{{ .Log.Format }}"
18  # Time format for the log "timestamp" field.
19  # Should be described in Golang's time format.
20  time_format: "{{ .Log.TimeFormat }}"
21
22# The SSH server configuration.
23ssh:
24  # The address on which the SSH server will listen.
25  listen_addr: "{{ .SSH.ListenAddr }}"
26
27  # The public URL of the SSH server.
28  # This is the address that will be used to clone repositories.
29  public_url: "{{ .SSH.PublicURL }}"
30
31  # The path to the SSH server's private key.
32  key_path: "{{ .SSH.KeyPath }}"
33
34  # The path to the server's client private key. This key will be used to
35  # authenticate the server to make git requests to ssh remotes.
36  client_key_path: "{{ .SSH.ClientKeyPath }}"
37
38  # The maximum number of seconds a connection can take.
39  # A value of 0 means no timeout.
40  max_timeout: {{ .SSH.MaxTimeout }}
41
42  # The number of seconds a connection can be idle before it is closed.
43  # A value of 0 means no timeout.
44  idle_timeout: {{ .SSH.IdleTimeout }}
45
46# The Git daemon configuration.
47git:
48  # The address on which the Git daemon will listen.
49  listen_addr: "{{ .Git.ListenAddr }}"
50
51  # The maximum number of seconds a connection can take.
52  # A value of 0 means no timeout.
53  max_timeout: {{ .Git.MaxTimeout }}
54
55  # The number of seconds a connection can be idle before it is closed.
56  idle_timeout: {{ .Git.IdleTimeout }}
57
58  # The maximum number of concurrent connections.
59  max_connections: {{ .Git.MaxConnections }}
60
61# The HTTP server configuration.
62http:
63  # The address on which the HTTP server will listen.
64  listen_addr: "{{ .HTTP.ListenAddr }}"
65
66  # The path to the TLS private key.
67  tls_key_path: "{{ .HTTP.TLSKeyPath }}"
68
69  # The path to the TLS certificate.
70  tls_cert_path: "{{ .HTTP.TLSCertPath }}"
71
72  # The public URL of the HTTP server.
73  # This is the address that will be used to clone repositories.
74  # Make sure to use https:// if you are using TLS.
75  public_url: "{{ .HTTP.PublicURL }}"
76
77# The stats server configuration.
78stats:
79  # The address on which the stats server will listen.
80  listen_addr: "{{ .Stats.ListenAddr }}"
81
82# Additional admin keys.
83#initial_admin_keys:
84#  - "ssh-rsa AAAAB3NzaC1yc2..."
85`))
86
87func newConfigFile(cfg *Config) string {
88	var b bytes.Buffer
89	configFileTmpl.Execute(&b, cfg) // nolint: errcheck
90	return b.String()
91}