file.go

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