Parent directory

file.go

4705 bytes
  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  # Enable the read-only public web UI. Disabled by default.
 93  web_ui:
 94    enabled: {{ .HTTP.WebUI.Enabled }}
 95
 96    # Internal worker URL used for current build status badges.
 97    build_status_url: "{{ .HTTP.WebUI.BuildStatusURL }}"
 98
 99  # The cross-origin request security options
100  cors:
101    # The allowed cross-origin headers
102    allowed_headers:
103       - "Accept"
104       - "Accept-Language"
105       - "Content-Language"
106       - "Content-Type"
107       - "Origin"
108       - "X-Requested-With"
109       - "User-Agent"
110       - "Authorization"
111       - "Access-Control-Request-Method"
112       - "Access-Control-Allow-Origin"
113    # The allowed cross-origin URLs
114    allowed_origins:
115       - "{{ .HTTP.PublicURL }}" # always allowed
116       # - "https://example.com"
117    # The allowed cross-origin methods
118    allowed_methods:
119       - "GET"
120       - "HEAD"
121       - "POST"
122       - "PUT"
123       - "OPTIONS"
124
125# The stats server configuration.
126stats:
127  # Enable the stats server.
128  enabled: {{ .Stats.Enabled }}
129
130  # The address on which the stats server will listen.
131  listen_addr: "{{ .Stats.ListenAddr }}"
132
133# The database configuration.
134db:
135  # The database driver to use.
136  # Valid values are "sqlite" and "postgres".
137  driver: "{{ .DB.Driver }}"
138  # The database data source name.
139  # This is driver specific and can be a file path or connection string.
140  # Make sure foreign key support is enabled when using SQLite.
141  data_source: "{{ .DB.DataSource }}"
142
143# Git LFS configuration.
144lfs:
145  # Enable Git LFS.
146  enabled: {{ .LFS.Enabled }}
147  # Enable Git SSH transfer.
148  ssh_enabled: {{ .LFS.SSHEnabled }}
149
150# Cron job configuration
151jobs:
152  mirror_pull: "{{ .Jobs.MirrorPull }}"
153
154# Additional admin keys.
155#initial_admin_keys:
156#  - "ssh-rsa AAAAB3NzaC1yc2..."
157
158# Name of a repository to create automatically on boot if it doesn't already
159# exist. Empty disables this behavior.
160#default_repo: ""
161`))
162
163func newConfigFile(cfg *Config) string {
164	var b bytes.Buffer
165	configFileTmpl.Execute(&b, cfg) //nolint: errcheck
166	return b.String()
167}