-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): store server config in file
- Loading branch information
1 parent
0bfce9c
commit 9a80cdb
Showing
2 changed files
with
145 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package config | ||
|
||
import ( | ||
"bytes" | ||
"text/template" | ||
) | ||
|
||
var ( | ||
configFileTmpl = template.Must(template.New("config").Parse(`# Soft Serve Server configurations | ||
# The name of the server. | ||
# This is the name that will be displayed in the UI. | ||
name: "{{ .Name }}" | ||
# The SSH server configuration. | ||
ssh: | ||
# The address on which the SSH server will listen. | ||
listen_addr: "{{ .SSH.ListenAddr }}" | ||
# The public URL of the SSH server. | ||
# This is the address will be used to clone repositories. | ||
public_url: "{{ .SSH.PublicURL }}" | ||
# The relative path to the SSH server's private key. | ||
key_path: "{{ .SSH.KeyPath }}" | ||
# The relative path to the SSH server's internal api private key. | ||
internal_key_path: "{{ .SSH.InternalKeyPath }}" | ||
# The maximum number of seconds a connection can take. | ||
# A value of 0 means no timeout. | ||
max_timeout: {{ .SSH.MaxTimeout }} | ||
# The number of seconds a connection can be idle before it is closed. | ||
idle_timeout: {{ .SSH.IdleTimeout }} | ||
# The Git daemon configuration. | ||
git: | ||
# The address on which the Git daemon will listen. | ||
listen_addr: "{{ .Git.ListenAddr }}" | ||
# The maximum number of seconds a connection can take. | ||
# A value of 0 means no timeout. | ||
max_timeout: {{ .Git.MaxTimeout }} | ||
# The number of seconds a connection can be idle before it is closed. | ||
idle_timeout: {{ .Git.IdleTimeout }} | ||
# The maximum number of concurrent connections. | ||
max_connections: {{ .Git.MaxConnections }} | ||
# The HTTP server configuration. | ||
http: | ||
# The address on which the HTTP server will listen. | ||
listen_addr: "{{ .HTTP.ListenAddr }}" | ||
# The public URL of the HTTP server. | ||
# This is the address will be used to clone repositories. | ||
public_url: "{{ .HTTP.PublicURL }}" | ||
`)) | ||
) | ||
|
||
func newConfigFile(cfg *Config) string { | ||
var b bytes.Buffer | ||
configFileTmpl.Execute(&b, cfg) | ||
return b.String() | ||
} |