Documentation
¶
Overview ¶
Package detect resolves which cloud provider should back the flat `param` / `secret` command aliases (and, later, the GUI's initial provider selection), based purely on environment variables. It performs no network calls and no credential-chain resolution, so it is safe to run on every process start.
The rules (per service, param and secret decided independently):
- A provider is "active via env" when its address/identity env var is set: AWS — AWS_ACCESS_KEY_ID | AWS_VAULT | AWS_PROFILE (both services) GoogleCloud — GOOGLE_CLOUD_PROJECT (secret only) Azure — AZURE_KEYVAULT_NAME (secret) / AZURE_APPCONFIG_NAME (param)
- A flat alias is exposed for a service only when exactly ONE provider is active for it. Zero or two-plus active means no alias — the user must use the explicit group (e.g. `suve aws secret`). There is no priority order.
- AWS-only final fallback: when NO provider is active via env for any service, AWS is accepted via ~/.aws/credentials so the common "plain AWS" setup keeps working. If that file is absent too, nothing is aliased.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Environment ¶
type Environment struct {
// Getenv reads an environment variable (os.Getenv in production).
Getenv func(string) string
// AWSCredentialsExist reports whether the AWS shared credentials file is
// present. It is only consulted for the final fallback, never eagerly.
AWSCredentialsExist func() bool
}
Environment abstracts the inputs the resolver reads, so it can be tested without mutating the real process environment or filesystem.
func OSEnvironment ¶
func OSEnvironment() Environment
OSEnvironment returns an Environment backed by the real OS.
type Result ¶
type Result struct {
// Param and Secret name the single active provider for that service, or an
// empty Provider ("") when the service is not uniquely resolvable (0 or 2+
// active) — meaning no flat alias should be exposed for it.
Param provider.Provider
Secret provider.Provider
// Stage names the single active provider for the staging workflow, or an
// empty Provider ("") when staging is not uniquely resolvable (0 or 2+
// staging-capable providers active). Staging is supported for AWS (param +
// secret), Google Cloud (secret), and Azure (Key Vault secret / App
// Configuration param).
Stage provider.Provider
// ParamActive and SecretActive list every provider active for that service,
// in stable order (AWS, GoogleCloud, Azure).
ParamActive []provider.Provider
SecretActive []provider.Provider
// StageActive lists every staging-capable provider active, in stable order
// (AWS, GoogleCloud, Azure).
StageActive []provider.Provider
// AWSViaFallback is true when AWS became active only through the
// ~/.aws/credentials fallback (no provider was active via env).
AWSViaFallback bool
}
Result holds the resolved flat-alias target for each service plus the full active sets (useful for help text and the GUI).
func Resolve ¶
func Resolve(env Environment) Result
Resolve computes the alias targets from the given environment.
func (Result) FlatSecret ¶
FlatSecret reports whether a top-level `secret` alias should be exposed.