file.go

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