file.go

  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  # Enable SSH.
 27  enabled: {{ .SSH.Enabled }}
 28
 29  # The address on which the SSH server will listen.
 30  listen_addr: "{{ .SSH.ListenAddr }}"
 31
 32  # The public URL of the SSH server.
 33  # This is the address that will be used to clone repositories.
 34  public_url: "{{ .SSH.PublicURL }}"
 35
 36  # The path to the SSH server's private key.
 37  key_path: {{ .SSH.KeyPath }}
 38
 39  # The path to the server's client private key. This key will be used to
 40  # authenticate the server to make git requests to ssh remotes.
 41  client_key_path: {{ .SSH.ClientKeyPath }}
 42
 43  # The maximum number of seconds a connection can take.
 44  # A value of 0 means no timeout.
 45  max_timeout: {{ .SSH.MaxTimeout }}
 46
 47  # The number of seconds a connection can be idle before it is closed.
 48  # A value of 0 means no timeout.
 49  idle_timeout: {{ .SSH.IdleTimeout }}
 50
 51# The Git daemon configuration.
 52git:
 53  # Enable the Git daemon.
 54  enabled: {{ .Git.Enabled }}
 55
 56  # The address on which the Git daemon will listen.
 57  listen_addr: "{{ .Git.ListenAddr }}"
 58
 59  # The public URL of the Git daemon server.
 60  # This is the address that will be used to clone repositories.
 61  public_url: "{{ .Git.PublicURL }}"
 62
 63  # The maximum number of seconds a connection can take.
 64  # A value of 0 means no timeout.
 65  max_timeout: {{ .Git.MaxTimeout }}
 66
 67  # The number of seconds a connection can be idle before it is closed.
 68  idle_timeout: {{ .Git.IdleTimeout }}
 69
 70  # The maximum number of concurrent connections.
 71  max_connections: {{ .Git.MaxConnections }}
 72
 73# The HTTP server configuration.
 74http:
 75  # Enable the HTTP server.
 76  enabled: {{ .HTTP.Enabled }}
 77
 78  # The address on which the HTTP server will listen.
 79  listen_addr: "{{ .HTTP.ListenAddr }}"
 80
 81  # The path to the TLS private key.
 82  tls_key_path: {{ .HTTP.TLSKeyPath }}
 83
 84  # The path to the TLS certificate.
 85  tls_cert_path: {{ .HTTP.TLSCertPath }}
 86
 87  # The public URL of the HTTP server.
 88  # This is the address that will be used to clone repositories.
 89  # Make sure to use https:// if you are using TLS.
 90  public_url: "{{ .HTTP.PublicURL }}"
 91
 92# The stats server configuration.
 93stats:
 94  # Enable the stats server.
 95  enabled: {{ .Stats.Enabled }}
 96
 97  # The address on which the stats server will listen.
 98  listen_addr: "{{ .Stats.ListenAddr }}"
 99
100# The database configuration.
101db:
102  # The database driver to use.
103  # Valid values are "sqlite" and "postgres".
104  driver: "{{ .DB.Driver }}"
105  # The database data source name.
106  # This is driver specific and can be a file path or connection string.
107  # Make sure foreign key support is enabled when using SQLite.
108  data_source: "{{ .DB.DataSource }}"
109
110# Git LFS configuration.
111lfs:
112  # Enable Git LFS.
113  enabled: {{ .LFS.Enabled }}
114  # Enable Git SSH transfer.
115  ssh_enabled: {{ .LFS.SSHEnabled }}
116
117# Cron job configuration
118jobs:
119  mirror_pull: "{{ .Jobs.MirrorPull }}"
120
121# Additional admin keys.
122#initial_admin_keys:
123#  - "ssh-rsa AAAAB3NzaC1yc2..."
124`))
125
126func newConfigFile(cfg *Config) string {
127	var b bytes.Buffer
128	configFileTmpl.Execute(&b, cfg) //nolint: errcheck
129	return b.String()
130}