Documentation
¶
Overview ¶
Package config loads and exposes the ~/.bitgit/config.toml configuration.
Usage:
cfg, err := config.Load() // reads $BITGIT_HOME/config.toml or ~/.bitgit/config.toml cfg := config.MustLoad() // panics on error
The singleton is safe for concurrent read after Load() returns.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
DefaultRemote string `toml:"default_remote"`
Hosts []HostEntry `toml:"hosts"`
Plugins PluginsConfig `toml:"plugins"`
// InsecureSkipVerify enables skipping TLS cert validation for all hosts.
// WARNING: exposes you to MITM attacks. Use only in controlled environments.
InsecureSkipVerify bool `toml:"insecure_skip_verify"`
// contains filtered or unexported fields
}
Config is the parsed ~/.bitgit/config.toml.
func Load ¶
Load loads the config exactly once and returns the singleton. Subsequent calls return the cached result.
func (*Config) HostForURL ¶
HostForURL finds the first [[hosts]] entry matching the given URL prefix. Returns nil if not found.
func (*Config) PluginsDir ¶
PluginsDir returns the plugins subdirectory.
func (*Config) ReadToken ¶
ReadToken reads a bearer token for the given host.
Resolution order:
- Environment variable (GITHUB_TOKEN for github, BITBUCKET_TOKEN for bitbucket-dc)
- token_file path from [[hosts]] entry
- Default secrets file: <config-dir>/secrets/<type>.token
The file must be mode 0600; ReadToken returns an error if it is world-readable.
func (*Config) SecretsDir ¶
SecretsDir returns the secrets subdirectory.
type HostEntry ¶
type HostEntry struct {
URL string `toml:"url"`
Type string `toml:"type"` // "github" | "bitbucket-dc"
TokenFile string `toml:"token_file"` // path to token file
}
HostEntry is a per-host credential block in [[hosts]].
type PluginsConfig ¶
type PluginsConfig struct {
Disabled []string `toml:"disabled"`
}
PluginsConfig holds the [plugins] section overrides.