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