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 will be used to clone repositories.
22  public_url: "{{ .SSH.PublicURL }}"
23
24  # The relative path to the SSH server's private key.
25  key_path: "{{ .SSH.KeyPath }}"
26
27  # The relative path to the SSH server's internal api private key.
28  internal_key_path: "{{ .SSH.InternalKeyPath }}"
29
30  # The maximum number of seconds a connection can take.
31  # A value of 0 means no timeout.
32  max_timeout: {{ .SSH.MaxTimeout }}
33
34  # The number of seconds a connection can be idle before it is closed.
35  idle_timeout: {{ .SSH.IdleTimeout }}
36
37# The Git daemon configuration.
38git:
39  # The address on which the Git daemon will listen.
40  listen_addr: "{{ .Git.ListenAddr }}"
41
42  # The maximum number of seconds a connection can take.
43  # A value of 0 means no timeout.
44  max_timeout: {{ .Git.MaxTimeout }}
45
46  # The number of seconds a connection can be idle before it is closed.
47  idle_timeout: {{ .Git.IdleTimeout }}
48
49  # The maximum number of concurrent connections.
50  max_connections: {{ .Git.MaxConnections }}
51
52# The HTTP server configuration.
53http:
54  # The address on which the HTTP server will listen.
55  listen_addr: "{{ .HTTP.ListenAddr }}"
56
57  # The relative path to the TLS private key.
58  tls_key_path: "{{ .HTTP.TLSKeyPath }}"
59
60  # The relative path to the TLS certificate.
61  tls_cert_path: "{{ .HTTP.TLSCertPath }}"
62
63  # The public URL of the HTTP server.
64  # This is the address will be used to clone repositories.
65  public_url: "{{ .HTTP.PublicURL }}"
66
67`))
68)
69
70func newConfigFile(cfg *Config) string {
71	var b bytes.Buffer
72	configFileTmpl.Execute(&b, cfg)
73	return b.String()
74}