Documentation
¶
Index ¶
- Constants
- func AssertAccountAsExpected(identity *sts.GetCallerIdentityOutput, expectedAccount string) error
- func ClearCurrentEnv() error
- func ClearGlobalCurrentEnv() error
- func FindLocalDir() (string, error)
- func GetIsWhoIAmSubShell() bool
- func GetShell() string
- func NewSubShell(args ...string) (*exec.Cmd, error)
- func PrintCallerIdentityTable(identity *sts.GetCallerIdentityOutput, name string)
- func ReadCurrentEnv() (string, error)
- func ReadCurrentEnvForConfig(cfg *Config) (string, string, error)
- func ReadCurrentEnvWithSource() (string, string, error)
- func ReadGlobalCurrentEnv() (string, error)
- func ValidateAccountNumber(number string) error
- func WriteCurrentEnv(name string) error
- func WriteGlobalCurrentEnv(name string) error
- type CallerIdentityClient
- type Config
- func (c *Config) AccountExists(name string) bool
- func (c *Config) AddAccount(name, number string) error
- func (c *Config) DeleteAccount(name string)
- func (c *Config) GetAccountByNumber(number string) string
- func (c *Config) PrintConfigTable(w io.Writer)
- func (c *Config) PrintConfigTableWithSource(w io.Writer, sources map[string]string)
- type ConfigPath
- type StsClient
- type SubShell
Constants ¶
const ( ShellEnvVar = "SHELL" DefaultShell = "/bin/bash" SubShellVar = "WHOIAM_SUBSHELL" SubShellVarEnabled = "WHOIAM_SUBSHELL=1" )
const AwsProfileEnvVar = "AWS_PROFILE"
const ExpectedEnvVar = "WHOIAM_EXPECTED_ENV"
Variables ¶
This section is empty.
Functions ¶
func AssertAccountAsExpected ¶
func AssertAccountAsExpected(identity *sts.GetCallerIdentityOutput, expectedAccount string) error
func ClearCurrentEnv ¶
func ClearCurrentEnv() error
ClearCurrentEnv removes .whoiam/expected-env if it exists.
func ClearGlobalCurrentEnv ¶
func ClearGlobalCurrentEnv() error
ClearGlobalCurrentEnv removes ~/.whoiam/expected-env if it exists.
func FindLocalDir ¶
FindLocalDir walks up from CWD looking for a .whoiam/ directory. Returns "" (no error) if none is found. Stops before reaching the home directory to avoid treating ~/.whoiam/ as local.
func GetIsWhoIAmSubShell ¶
func GetIsWhoIAmSubShell() bool
func PrintCallerIdentityTable ¶
func PrintCallerIdentityTable(identity *sts.GetCallerIdentityOutput, name string)
func ReadCurrentEnv ¶
ReadCurrentEnv reads the account name from .whoiam/expected-env. Checks local first, then falls back to global. Returns "" if neither is set.
func ReadCurrentEnvForConfig ¶
ReadCurrentEnvForConfig resolves the expected environment using the full priority chain, including AWS_PROFILE if the profile name matches an account defined in cfg. Priority: --env flag (caller) > WHOIAM_EXPECTED_ENV > AWS_PROFILE (if matched) > local file > global file.
func ReadCurrentEnvWithSource ¶
ReadCurrentEnvWithSource is like ReadCurrentEnv but also returns the source: "env" (WHOIAM_EXPECTED_ENV), "local" (.whoiam/expected-env), "global" (~/.whoiam/expected-env), or "" if not set. Does not check AWS_PROFILE; use ReadCurrentEnvForConfig when a config is available.
func ReadGlobalCurrentEnv ¶
ReadGlobalCurrentEnv reads the account name from ~/.whoiam/expected-env.
func ValidateAccountNumber ¶
func WriteCurrentEnv ¶
WriteCurrentEnv writes the account name to .whoiam/expected-env. Requires a .whoiam/ directory to already exist (created by whoiam init).
func WriteGlobalCurrentEnv ¶
WriteGlobalCurrentEnv writes the account name to ~/.whoiam/expected-env.
Types ¶
type CallerIdentityClient ¶ added in v0.6.0
type CallerIdentityClient interface {
GetCallerIdentity() (*sts.GetCallerIdentityOutput, error)
}
CallerIdentityClient is the interface used by commands to look up AWS identity.
type Config ¶
func LoadEffectiveConfig ¶
LoadEffectiveConfig loads the global config and merges any project-local config on top. Local account definitions take precedence over global ones on conflict.
func LoadEffectiveConfigWithSources ¶
LoadEffectiveConfigWithSources is like LoadEffectiveConfig but also returns a map of account name -> source ("global" or "local") for each entry.
func NewTemplateConfig ¶
func (*Config) AccountExists ¶
func (*Config) AddAccount ¶
func (*Config) DeleteAccount ¶
func (*Config) GetAccountByNumber ¶
func (*Config) PrintConfigTable ¶
type ConfigPath ¶
func FindLocalConfigPath ¶
func FindLocalConfigPath() (*ConfigPath, error)
FindLocalConfigPath walks up the directory tree from CWD looking for a .whoiam/whoiam.yaml. Returns nil (no error) if no local config is found. Stops before reaching the home directory to avoid treating ~/.whoiam/whoiam.yaml as local.
func NewConfigPath ¶
func NewConfigPath() (*ConfigPath, error)
func NewProjectConfigPath ¶
func NewProjectConfigPath() (*ConfigPath, error)
NewProjectConfigPath returns a ConfigPath rooted at .whoiam/ in the current directory. Used by whoiam init to create a project-local config.
func (*ConfigPath) ConfigFileExists ¶
func (c *ConfigPath) ConfigFileExists() bool
func (*ConfigPath) Create ¶
func (c *ConfigPath) Create() error
func (*ConfigPath) Exists ¶
func (c *ConfigPath) Exists() bool
func (*ConfigPath) FullPath ¶
func (c *ConfigPath) FullPath() string
func (*ConfigPath) LoadConfig ¶
func (c *ConfigPath) LoadConfig() (*Config, error)
func (*ConfigPath) SaveConfig ¶
func (c *ConfigPath) SaveConfig(config *Config) error
type StsClient ¶
func NewStsClient ¶
func (*StsClient) GetCallerIdentity ¶
func (s *StsClient) GetCallerIdentity() (*sts.GetCallerIdentityOutput, error)