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 maximum number of seconds a connection can take.
 54  # A value of 0 means no timeout.
 55  max_timeout: {{ .Git.MaxTimeout }}
 56
 57  # The number of seconds a connection can be idle before it is closed.
 58  idle_timeout: {{ .Git.IdleTimeout }}
 59
 60  # The maximum number of concurrent connections.
 61  max_connections: {{ .Git.MaxConnections }}
 62
 63# The HTTP server configuration.
 64http:
 65  # The address on which the HTTP server will listen.
 66  listen_addr: "{{ .HTTP.ListenAddr }}"
 67
 68  # The path to the TLS private key.
 69  tls_key_path: {{ .HTTP.TLSKeyPath }}
 70
 71  # The path to the TLS certificate.
 72  tls_cert_path: {{ .HTTP.TLSCertPath }}
 73
 74  # The public URL of the HTTP server.
 75  # This is the address that will be used to clone repositories.
 76  # Make sure to use https:// if you are using TLS.
 77  public_url: "{{ .HTTP.PublicURL }}"
 78
 79# The stats server configuration.
 80stats:
 81  # The address on which the stats server will listen.
 82  listen_addr: "{{ .Stats.ListenAddr }}"
 83
 84# The database configuration.
 85db:
 86  # The database driver to use.
 87  # Valid values are "sqlite" and "postgres".
 88  driver: "{{ .DB.Driver }}"
 89  # The database data source name.
 90  # This is driver specific and can be a file path or connection string.
 91  data_source: "{{ .DB.DataSource }}"
 92
 93# Git LFS configuration.
 94lfs:
 95  # Enable Git LFS.
 96  enabled: {{ .LFS.Enabled }}
 97  # Enable Git SSH transfer.
 98  ssh_enabled: {{ .LFS.SSHEnabled }}
 99
100# Additional admin keys.
101#initial_admin_keys:
102#  - "ssh-rsa AAAAB3NzaC1yc2..."
103`))
104
105func newConfigFile(cfg *Config) string {
106	var b bytes.Buffer
107	configFileTmpl.Execute(&b, cfg) // nolint: errcheck
108	return b.String()
109}