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# Cache configuration.
 15cache:
 16  # The cache backend to use. The default backend is "lru" memory cache.
 17  backend: "{{ .Cache.Backend }}"
 18
 19# Database configuration.
 20database:
 21  # The database driver to use. The default driver is "sqlite".
 22  driver: "{{ .Database.Driver }}"
 23  # The data source to the database. For sqlite, this is the path to the
 24  # database file.
 25  data_source:"{{ .Database.DataSource }}"
 26
 27# Backend configuration defines the backend for server settings, repositories,
 28# authentication, and authorization.
 29backend:
 30  # Settings is the server settings backend.
 31  # The default is "sqlite" which stores server settings as a key-value pair in
 32  # the database.
 33  settings: "{{ .Backend.Settings }}"
 34  # Access is the authorization backend.
 35  # The default is "sqlite" which stores access rules in the database.
 36  access: "{{ .Backend.Access }}"
 37  # Auth is the authentication backend.
 38  # The default is "sqlite" which stores and manages users in the database.
 39  auth: "{{ .Backend.Auth }}"
 40  # Store is the repository storage backend.
 41  # The default is "filesqlite" which stores repositories in the filesystem and
 42  # the sqlite database.
 43  # Git repositories are stored in the filesystem and their metadata are stored
 44  # in both the filesystem and database.
 45  store: "{{ .Backend.Store }}"
 46
 47# Logging configuration.
 48log:
 49  # Log format to use. Valid values are "json", "logfmt", and "text".
 50  format: "{{ .Log.Format }}"
 51  # Time format for the log "timestamp" field.
 52  # Should be described in Golang's time format.
 53  time_format: "{{ .Log.TimeFormat }}"
 54
 55# The SSH server configuration.
 56ssh:
 57  # The address on which the SSH server will listen.
 58  listen_addr: "{{ .SSH.ListenAddr }}"
 59
 60  # The public URL of the SSH server.
 61  # This is the address that will be used to clone repositories.
 62  public_url: "{{ .SSH.PublicURL }}"
 63
 64  # The path to the SSH server's private key.
 65  key_path: "{{ .SSH.KeyPath }}"
 66
 67  # The path to the server's client private key. This key will be used to
 68  # authenticate the server to make git requests to ssh remotes.
 69  client_key_path: "{{ .SSH.ClientKeyPath }}"
 70
 71  # The maximum number of seconds a connection can take.
 72  # A value of 0 means no timeout.
 73  max_timeout: {{ .SSH.MaxTimeout }}
 74
 75  # The number of seconds a connection can be idle before it is closed.
 76  # A value of 0 means no timeout.
 77  idle_timeout: {{ .SSH.IdleTimeout }}
 78
 79# The Git daemon configuration.
 80git_daemon:
 81  # The address on which the Git daemon will listen.
 82  listen_addr: "{{ .GitDaemon.ListenAddr }}"
 83
 84  # The maximum number of seconds a connection can take.
 85  # A value of 0 means no timeout.
 86  max_timeout: {{ .GitDaemon.MaxTimeout }}
 87
 88  # The number of seconds a connection can be idle before it is closed.
 89  idle_timeout: {{ .GitDaemon.IdleTimeout }}
 90
 91  # The maximum number of concurrent connections.
 92  max_connections: {{ .GitDaemon.MaxConnections }}
 93
 94# The HTTP server configuration.
 95http:
 96  # The address on which the HTTP server will listen.
 97  listen_addr: "{{ .HTTP.ListenAddr }}"
 98
 99  # The path to the TLS private key.
100  tls_key_path: "{{ .HTTP.TLSKeyPath }}"
101
102  # The path to the TLS certificate.
103  tls_cert_path: "{{ .HTTP.TLSCertPath }}"
104
105  # The public URL of the HTTP server.
106  # This is the address that will be used to clone repositories.
107  # Make sure to use https:// if you are using TLS.
108  public_url: "{{ .HTTP.PublicURL }}"
109
110# The stats server configuration.
111stats:
112  # The address on which the stats server will listen.
113  # Note that by default, the stats server binds to "localhost".
114  # This won't make it accessible from other networks.
115  # If you're running Soft Serve on a container, you probably want it to be
116  # accessible to other networks. To do so, change the listen address to
117  # ":PORT" or "0.0.0.0:PORT".
118  listen_addr: "{{ .Stats.ListenAddr }}"
119
120# Additional admin keys.
121#initial_admin_keys:
122#  - "ssh-rsa AAAAB3NzaC1yc2..."
123`))
124
125func newConfigFile(cfg *Config) string {
126	var b bytes.Buffer
127	configFileTmpl.Execute(&b, cfg) // nolint: errcheck
128	return b.String()
129}