Documentation
¶
Overview ¶
Package config owns persisted settings, separate from private runtime credentials.
Index ¶
- Constants
- Variables
- func DefaultStatePath() (string, error)
- func Edit(key string, value *string) error
- func EditFile(path, key string, value *string) error
- func Path() (string, error)
- func StateDir() (string, error)
- type ConsoleValues
- type FetcherValues
- type GitHub
- type Google
- type LocalValues
- type RemoteValues
- type ServerSettings
- type ServerValues
- type Values
Constants ¶
const DefaultConsolePort = 7970
DefaultConsolePort keeps diffx-console beside diffx-server (7980) and off the local `diffx [PATH]` range (7981-7990).
const DefaultInternalPort = 7979
DefaultInternalPort serves the GitHub fetcher protocol; never publish it.
const DefaultServerPort = 7980
DefaultServerPort keeps diffx-server off the local `diffx [PATH]` range (7981-7990) so both modes can run on one machine.
Variables ¶
var Keys = []string{"local.host", "local.port", "local.state", "local.webDir", "local.retentionDays", "remote.url", "remote.token"}
Keys lists persisted settings by dotted path.
Functions ¶
func DefaultStatePath ¶ added in v0.2.1
DefaultStatePath is the local persistent database used when none is configured.
Types ¶
type ConsoleValues ¶ added in v0.2.4
type ConsoleValues struct {
Host string
Port int
// DatabaseURL is the server's Postgres connection string; never echoed.
DatabaseURL string
// PublicURL is the console's browser-facing origin; AppURL is the app's,
// used in invite and member reset links.
PublicURL string
AppURL string
InsecureCookies bool
// Google is the console's own OAuth client, with its callback on PublicURL.
Google Google
AuthRateLimit bool
ClientIPHeader string
}
ConsoleValues configures diffx-console, the admin console over the server's database. It comes only from DIFFX_CONSOLE_* environment variables.
func LoadConsole ¶ added in v0.2.4
func LoadConsole() (ConsoleValues, error)
LoadConsole resolves defaults, then the environment.
func (ConsoleValues) ListenAddress ¶ added in v0.2.4
func (values ConsoleValues) ListenAddress() (string, error)
func (ConsoleValues) Validate ¶ added in v0.2.4
func (values ConsoleValues) Validate() error
Validate checks everything Run needs: the app origin for invite and reset links, the optional console origin, complete Google sign-in and rate limiting.
func (ConsoleValues) ValidateDatabase ¶ added in v0.2.4
func (values ConsoleValues) ValidateDatabase() error
ValidateDatabase requires the Postgres connection string without echoing it.
type FetcherValues ¶ added in v0.2.1
type FetcherValues struct {
ServerURL string
Secret string
Mirrors string
DiskLimitBytes int64
Concurrency int
}
FetcherValues configures diffx-fetcher. DiskLimitBytes bounds its mirrors.
func LoadFetcher ¶ added in v0.2.1
func LoadFetcher() (FetcherValues, error)
LoadFetcher reads DIFFX_FETCHER_* environment only; the fetcher has no config file. Diagnostics never echo the secret.
type GitHub ¶ added in v0.2.1
type GitHub struct {
AppID int64 `json:"appId"`
ClientID string `json:"clientId"`
PrivateKeyFile string `json:"privateKeyFile"`
PublicURL string `json:"publicUrl"`
ClientSecret string `json:"-"`
WebhookSecret string `json:"-"`
TokenKey string `json:"-"`
// FetcherSecret authenticates diffx-fetcher on the internal listener.
FetcherSecret string `json:"-"`
}
GitHub configures the optional GitHub App integration. Secrets come only from DIFFX_SERVER_GITHUB_* environment variables, never the config file.
type Google ¶ added in v0.2.2
Google configures Google sign-in. The secret comes only from DIFFX_SERVER_GOOGLE_CLIENT_SECRET, never the config file.
type LocalValues ¶ added in v0.2.1
type LocalValues struct {
Host string `json:"host"`
Port *int `json:"port"`
State string `json:"state"`
WebDir string `json:"webDir"`
RetentionDays int `json:"retentionDays"`
}
LocalValues configure the foreground `diffx [PATH]` server only.
type RemoteValues ¶
RemoteValues select the destination for sync and agent hooks only.
type ServerSettings ¶
type ServerValues ¶ added in v0.2.1
type ServerValues struct {
Host string `json:"host"`
Port int `json:"port"`
// DatabaseURL is the Postgres connection string. It holds credentials, so it
// comes only from DIFFX_SERVER_DATABASE_URL, never a file or flag, and is never echoed.
DatabaseURL string `json:"-"`
PublicURL string `json:"publicUrl"`
InsecureCookies bool `json:"insecureCookies"`
RetentionDays int `json:"retentionDays"`
// InternalPort listens beside Port, on the same host, when GitHub is enabled.
InternalPort int `json:"internalPort"`
GitHub GitHub `json:"github"`
Google Google `json:"google"`
// AuthRateLimit bounds authentication attempts per client IP across
// replicas. The IP comes from ClientIPHeader, which a trusted ingress must
// set; both come only from the environment.
AuthRateLimit bool `json:"-"`
ClientIPHeader string `json:"-"`
}
ServerValues is deployment configuration, independent of personal CLI settings.
func LoadServerFile ¶ added in v0.2.1
func LoadServerFile(path string) (ServerValues, error)
LoadServerFile resolves defaults, an explicitly selected file, then environment. It never discovers personal config, creates files, or acquires a config lock. Variables use the DIFFX_SERVER_ prefix so they never configure the local CLI.
func (ServerValues) InternalAddress ¶ added in v0.2.1
func (values ServerValues) InternalAddress(listen string) (string, error)
InternalAddress places the internal listener on the public listener's host.
func (ServerValues) ListenAddress ¶ added in v0.2.1
func (values ServerValues) ListenAddress() (string, error)
ListenAddress validates the configured listener when no flag overrides it.
func (ServerValues) ValidateAuthRateLimit ¶ added in v0.2.2
func (values ServerValues) ValidateAuthRateLimit() error
ValidateAuthRateLimit requires a header name when limiting is enabled; the server cannot tell a client from its ingress without one.
func (ServerValues) ValidateDatabase ¶ added in v0.2.2
func (values ServerValues) ValidateDatabase() error
ValidateDatabase requires the Postgres connection string without echoing it.
func (ServerValues) ValidateIdentity ¶ added in v0.2.2
func (values ServerValues) ValidateIdentity() error
ValidateIdentity checks the optional public origin and Google sign-in, which needs both credentials and that origin. How people join is a console setting, not configuration.
type Values ¶
type Values struct {
Local LocalValues `json:"local"`
Remote RemoteValues `json:"remote"`
}
Values keep local serving and remote delivery in separate namespaces so one file configures both modes without either reading the other's settings.
func LoadFile ¶
LoadFile resolves defaults, a JSON file, then environment overrides. It never persists environment values. An empty path selects the machine config. Environment names are namespaced like the file so a diffx-server deployment's DIFFX_SERVER_* variables never configure the local CLI.
func (Values) RemoteConfigured ¶ added in v0.2.1
RemoteConfigured reports whether sync and hooks have a complete destination.
func (Values) Settings ¶
func (values Values) Settings() (ServerSettings, error)