Documentation ¶
Index ¶
- Variables
- func DefaultDataPath() string
- func IsDebug() bool
- func IsVerbose() bool
- func KeyPair(cfg *Config) (*keygen.SSHKeyPair, error)
- func WithContext(ctx context.Context, cfg *Config) context.Context
- type Config
- func (c *Config) AdminKeys() []ssh.PublicKey
- func (c *Config) ConfigPath() string
- func (c *Config) Environ() []string
- func (c *Config) Exist() bool
- func (c *Config) Parse() error
- func (c *Config) ParseEnv() error
- func (c *Config) ParseFile() error
- func (c *Config) Validate() error
- func (c *Config) WriteConfig() error
- type DBConfig
- type GitConfig
- type HTTPConfig
- type JobsConfig
- type LFSConfig
- type LogConfig
- type SSHConfig
- type StatsConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNilConfig is returned when a nil config is passed to a function. ErrNilConfig = errors.New("nil config") // ErrEmptySSHKeyPath is returned when the SSH key path is empty. ErrEmptySSHKeyPath = errors.New("empty SSH key path") )
var ContextKey = struct{ string }{"config"}
ContextKey is the context key for the config.
Functions ¶
func DefaultDataPath ¶
func DefaultDataPath() string
DefaultDataPath returns the path to the data directory. It uses the SOFT_SERVE_DATA_PATH environment variable if set, otherwise it uses "data".
func IsVerbose ¶
func IsVerbose() bool
IsVerbose returns true if the server is running in verbose mode. Verbose mode is only enabled if debug mode is enabled.
Types ¶
type Config ¶
type Config struct { // Name is the name of the server. Name string `env:"NAME" yaml:"name"` // SSH is the configuration for the SSH server. SSH SSHConfig `envPrefix:"SSH_" yaml:"ssh"` // Git is the configuration for the Git daemon. Git GitConfig `envPrefix:"GIT_" yaml:"git"` // HTTP is the configuration for the HTTP server. HTTP HTTPConfig `envPrefix:"HTTP_" yaml:"http"` // Stats is the configuration for the stats server. Stats StatsConfig `envPrefix:"STATS_" yaml:"stats"` // Log is the logger configuration. Log LogConfig `envPrefix:"LOG_" yaml:"log"` // DB is the database configuration. DB DBConfig `envPrefix:"DB_" yaml:"db"` // LFS is the configuration for Git LFS. LFS LFSConfig `envPrefix:"LFS_" yaml:"lfs"` // Jobs is the configuration for cron jobs Jobs JobsConfig `envPrefix:"JOBS_" yaml:"jobs"` // InitialAdminKeys is a list of public keys that will be added to the list of admins. InitialAdminKeys []string `env:"INITIAL_ADMIN_KEYS" envSeparator:"\n" yaml:"initial_admin_keys"` // DataPath is the path to the directory where Soft Serve will store its data. DataPath string `env:"DATA_PATH" yaml:"-"` }
Config is the configuration for Soft Serve.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default Config. All the path values are relative to the data directory. Use Validate() to validate the config and ensure absolute paths.
func FromContext ¶
FromContext returns the configuration from the context.
func (*Config) ConfigPath ¶
ConfigPath returns the path to the config file.
func (*Config) Parse ¶
Parse parses the config from the default file path and environment variables. This also calls Validate() on the config.
func (*Config) ParseEnv ¶
ParseEnv parses the config from the environment variables. This also calls Validate() on the config.
func (*Config) ParseFile ¶
ParseFile parses the config from the default file path. This also calls Validate() on the config.
func (*Config) Validate ¶
Validate validates the configuration. It updates the configuration with absolute paths.
func (*Config) WriteConfig ¶
WriteConfig writes the configuration to the default file.
type DBConfig ¶
type DBConfig struct { // Driver is the driver for the database. Driver string `env:"DRIVER" yaml:"driver"` // DataSource is the database data source name. DataSource string `env:"DATA_SOURCE" yaml:"data_source"` }
DBConfig is the database connection configuration.
type GitConfig ¶
type GitConfig struct { // ListenAddr is the address on which the Git daemon will listen. ListenAddr string `env:"LISTEN_ADDR" yaml:"listen_addr"` // PublicURL is the public URL of the Git daemon server. PublicURL string `env:"PUBLIC_URL" yaml:"public_url"` // MaxTimeout is the maximum number of seconds a connection can take. MaxTimeout int `env:"MAX_TIMEOUT" yaml:"max_timeout"` // IdleTimeout is the number of seconds a connection can be idle before it is closed. IdleTimeout int `env:"IDLE_TIMEOUT" yaml:"idle_timeout"` // MaxConnections is the maximum number of concurrent connections. MaxConnections int `env:"MAX_CONNECTIONS" yaml:"max_connections"` }
GitConfig is the Git daemon configuration for the server.
type HTTPConfig ¶
type HTTPConfig struct { // ListenAddr is the address on which the HTTP server will listen. ListenAddr string `env:"LISTEN_ADDR" yaml:"listen_addr"` // TLSKeyPath is the path to the TLS private key. TLSKeyPath string `env:"TLS_KEY_PATH" yaml:"tls_key_path"` // TLSCertPath is the path to the TLS certificate. TLSCertPath string `env:"TLS_CERT_PATH" yaml:"tls_cert_path"` // PublicURL is the public URL of the HTTP server. PublicURL string `env:"PUBLIC_URL" yaml:"public_url"` }
HTTPConfig is the HTTP configuration for the server.
type JobsConfig ¶
type JobsConfig struct {
MirrorPull string `env:"MIRROR_PULL" yaml:"mirror_pull"`
}
JobsConfig is the configuration for cron jobs.
type LFSConfig ¶
type LFSConfig struct { // Enabled is whether or not Git LFS is enabled. Enabled bool `env:"ENABLED" yaml:"enabled"` // SSHEnabled is whether or not Git LFS over SSH is enabled. // This is only used if LFS is enabled. SSHEnabled bool `env:"SSH_ENABLED" yaml:"ssh_enabled"` }
LFSConfig is the configuration for Git LFS.
type LogConfig ¶
type LogConfig struct { // Format is the format of the logs. // Valid values are "json", "logfmt", and "text". Format string `env:"FORMAT" yaml:"format"` // Time format for the log `ts` field. // Format must be described in Golang's time format. TimeFormat string `env:"TIME_FORMAT" yaml:"time_format"` // Path to a file to write logs to. // If not set, logs will be written to stderr. Path string `env:"PATH" yaml:"path"` }
LogConfig is the logger configuration.
type SSHConfig ¶
type SSHConfig struct { // ListenAddr is the address on which the SSH server will listen. ListenAddr string `env:"LISTEN_ADDR" yaml:"listen_addr"` // PublicURL is the public URL of the SSH server. PublicURL string `env:"PUBLIC_URL" yaml:"public_url"` // KeyPath is the path to the SSH server's private key. KeyPath string `env:"KEY_PATH" yaml:"key_path"` // ClientKeyPath is the path to the server's client private key. ClientKeyPath string `env:"CLIENT_KEY_PATH" yaml:"client_key_path"` // MaxTimeout is the maximum number of seconds a connection can take. MaxTimeout int `env:"MAX_TIMEOUT" yaml:"max_timeout"` // IdleTimeout is the number of seconds a connection can be idle before it is closed. IdleTimeout int `env:"IDLE_TIMEOUT" yaml:"idle_timeout"` }
SSHConfig is the configuration for the SSH server.
type StatsConfig ¶
type StatsConfig struct { // ListenAddr is the address on which the stats server will listen. ListenAddr string `env:"LISTEN_ADDR" yaml:"listen_addr"` }
StatsConfig is the configuration for the stats server.