Documentation
¶
Overview ¶
Package config manages named connection profiles stored under $XDG_CONFIG_HOME/rdsh (default ~/.config/rdsh), the same location scheme gh uses. os.UserConfigDir is deliberately avoided: on darwin it points to ~/Library/Application Support instead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
ActiveProfile string `yaml:"active_profile,omitempty"`
Profiles map[string]Profile `yaml:"profiles,omitempty"`
}
Config is the on-disk configuration.
func Load ¶
Load reads the config file. A missing file is not an error and yields an empty config, so first-run commands can give their own guidance.
func (*Config) Save ¶
Save writes the config file with 0600 permissions (0700 for the directory), enforcing the mode even when the file already exists with a looser one.
func (*Config) SetProfile ¶
SetProfile adds or replaces a profile. The first profile ever saved becomes the active one.
type Connection ¶
Connection is a resolved set of credentials for talking to one Redash instance. DataSource may be empty (the run command then requires --data-source).
func Resolve ¶
func Resolve(cfg *Config, profileFlag string) (Connection, error)
Resolve picks the connection to use. Precedence: the --profile flag (explicit, one invocation) > the RDSH_URL/RDSH_API_KEY pair > the profile set persistently by `profile use`. When --profile is given the environment is not consulted — an explicit flag must never lose silently to ambient state.