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