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