1package config
2
3import (
4 "bytes"
5 "text/template"
6)
7
8var configFileTmpl = template.Must(template.New("config").Parse(`# Soft Serve Server configurations
9
10# The name of the server.
11# This is the name that will be displayed in the UI.
12name: "{{ .Name }}"
13
14# Logging configuration.
15log:
16 # Log format to use. Valid values are "json", "logfmt", and "text".
17 format: "{{ .Log.Format }}"
18 # Time format for the log "timestamp" field.
19 # Should be described in Golang's time format.
20 time_format: "{{ .Log.TimeFormat }}"
21 # Path to the log file. Leave empty to write to stderr.
22 #path: "{{ .Log.Path }}"
23
24# The SSH server configuration.
25ssh:
26 # The address on which the SSH server will listen.
27 listen_addr: "{{ .SSH.ListenAddr }}"
28
29 # The public URL of the SSH server.
30 # This is the address that will be used to clone repositories.
31 public_url: "{{ .SSH.PublicURL }}"
32
33 # The path to the SSH server's private key.
34 key_path: {{ .SSH.KeyPath }}
35
36 # The path to the server's client private key. This key will be used to
37 # authenticate the server to make git requests to ssh remotes.
38 client_key_path: {{ .SSH.ClientKeyPath }}
39
40 # The maximum number of seconds a connection can take.
41 # A value of 0 means no timeout.
42 max_timeout: {{ .SSH.MaxTimeout }}
43
44 # The number of seconds a connection can be idle before it is closed.
45 # A value of 0 means no timeout.
46 idle_timeout: {{ .SSH.IdleTimeout }}
47
48# The Git daemon configuration.
49git:
50 # The address on which the Git daemon will listen.
51 listen_addr: "{{ .Git.ListenAddr }}"
52
53 # The public URL of the Git daemon server.
54 # This is the address that will be used to clone repositories.
55 public_url: "{{ .Git.PublicURL }}"
56
57 # The maximum number of seconds a connection can take.
58 # A value of 0 means no timeout.
59 max_timeout: {{ .Git.MaxTimeout }}
60
61 # The number of seconds a connection can be idle before it is closed.
62 idle_timeout: {{ .Git.IdleTimeout }}
63
64 # The maximum number of concurrent connections.
65 max_connections: {{ .Git.MaxConnections }}
66
67# The HTTP server configuration.
68http:
69 # The address on which the HTTP server will listen.
70 listen_addr: "{{ .HTTP.ListenAddr }}"
71
72 # The path to the TLS private key.
73 tls_key_path: {{ .HTTP.TLSKeyPath }}
74
75 # The path to the TLS certificate.
76 tls_cert_path: {{ .HTTP.TLSCertPath }}
77
78 # The public URL of the HTTP server.
79 # This is the address that will be used to clone repositories.
80 # Make sure to use https:// if you are using TLS.
81 public_url: "{{ .HTTP.PublicURL }}"
82
83# The stats server configuration.
84stats:
85 # The address on which the stats server will listen.
86 listen_addr: "{{ .Stats.ListenAddr }}"
87
88# The database configuration.
89db:
90 # The database driver to use.
91 # Valid values are "sqlite" and "postgres".
92 driver: "{{ .DB.Driver }}"
93 # The database data source name.
94 # This is driver specific and can be a file path or connection string.
95 # Make sure foreign key support is enabled when using SQLite.
96 data_source: "{{ .DB.DataSource }}"
97
98# Git LFS configuration.
99lfs:
100 # Enable Git LFS.
101 enabled: {{ .LFS.Enabled }}
102 # Enable Git SSH transfer.
103 ssh_enabled: {{ .LFS.SSHEnabled }}
104
105# Cron job configuration
106jobs:
107 mirror_pull: "{{ .Jobs.MirrorPull }}"
108
109# Additional admin keys.
110#initial_admin_keys:
111# - "ssh-rsa AAAAB3NzaC1yc2..."
112`))
113
114func newConfigFile(cfg *Config) string {
115 var b bytes.Buffer
116 configFileTmpl.Execute(&b, cfg) // nolint: errcheck
117 return b.String()
118}