Documentation
¶
Overview ¶
Package config manages the non-secret CLI configuration (~/.config/reearth/config.yaml) and project files (.reearth.yaml). Secrets never live here; see package credstore.
Index ¶
Constants ¶
const ( KindOAuth = "oauth" KindToken = "token" )
Account kinds.
Variables ¶
var ErrNewerVersion = errors.New("written by a newer version of the CLI")
ErrNewerVersion is wrapped by the error LoadFile returns for a file written by a newer version of the CLI.
var Settings = []Setting{ {Key: "output", Description: "Default output format on a TTY", Default: "table", Allowed: []string{"table", "plain", "json", "yaml", "ndjson"}}, {Key: "prompt", Description: "Allow interactive prompts", Default: "enabled", Allowed: []string{"enabled", "disabled"}}, {Key: "update_check", Description: "Check for new reearth versions (reearth binary only)", Default: "enabled", Allowed: []string{"enabled", "disabled"}}, {Key: "browser", Description: "Command used to open URLs (empty: system default)"}, }
Settings lists every supported setting key.
Functions ¶
func CacheDir ¶
func CacheDir() string
CacheDir returns the cache directory (tokens are never stored here).
func Dir ¶
func Dir() string
Dir returns the configuration directory. REEARTH_CONFIG_DIR > XDG_CONFIG_HOME/reearth > %AppData%/reearth (Windows) > ~/.config/reearth
func SettingEnv ¶
SettingEnv returns the environment variable that overrides a setting.
Types ¶
type Account ¶
type Account struct {
Env string `yaml:"env" json:"env"`
Kind string `yaml:"kind" json:"kind"`
Product string `yaml:"product,omitempty" json:"product,omitempty"`
User *User `yaml:"user,omitempty" json:"user,omitempty"`
// Workspace is the default workspace ID for this account.
Workspace string `yaml:"workspace,omitempty" json:"workspace,omitempty"`
// InsecureStorage stores credentials in a plain file instead of the OS keyring.
InsecureStorage bool `yaml:"insecure_storage,omitempty" json:"insecure_storage,omitempty"`
Extra map[string]any `yaml:",inline" json:"-"`
}
type Config ¶
type Config struct {
Version int `yaml:"version"`
Active string `yaml:"active,omitempty"`
Accounts map[string]*Account `yaml:"accounts,omitempty"`
Envs map[string]*EnvConfig `yaml:"envs,omitempty"`
// Hostname is the hostname for the OAuth redirect listener (default: "127.0.0.1").
Hostname string `yaml:"hostname,omitempty"`
// Port fixes the OAuth loopback port used during login (0 = try 8085-8087).
// Register http://<hostname>:<port>/callback in your Auth0 allowed callback URLs.
Port int `yaml:"port,omitempty"`
// Settings keeps values of keys this version does not know as written.
Settings map[string]any `yaml:"settings,omitempty"`
// Extra keeps top-level fields this version does not know, so that saving
// does not erase what a newer version wrote. The nested structs below
// keep theirs the same way.
Extra map[string]any `yaml:",inline" json:"-"`
// contains filtered or unexported fields
}
func (*Config) AccountNames ¶
AccountNames returns account names sorted alphabetically.
func (*Config) RemoveAccount ¶
RemoveAccount deletes an account and fixes up the active account.
type EnvConfig ¶
type EnvConfig struct {
Auth EnvAuth `yaml:"auth"`
Products map[string]EnvProduct `yaml:"products,omitempty"`
Extra map[string]any `yaml:",inline" json:"-"`
}
EnvConfig is a user-defined environment (on-premise, self-hosted Auth0, ...).
type EnvProduct ¶
type Project ¶
type Project struct {
Account string `yaml:"account,omitempty"`
Workspace string `yaml:"workspace,omitempty"`
Products map[string]map[string]any `yaml:",inline"`
// contains filtered or unexported fields
}
Project is a per-directory config file (.reearth.yaml), meant to be committed.
account: work workspace: 01hq... cms: project: my-project
func FindProject ¶
FindProject searches dir and its parents for a project file. It returns nil if none is found.