Documentation
¶
Overview ¶
Package config manages slio's on-disk configuration (registered workspace profiles and their tokens) and resolves which credentials an invocation should use.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProfileNames ¶
ProfileNames returns the registered profile names, sorted and comma-joined, for use in error messages (e.g. "profile %q not found; registered profiles: %s"). Returns "(none)" if none are registered.
Types ¶
type Credentials ¶
type Credentials struct {
Token string
// Host is the profile's stored workspace host. Empty when the token
// came from SLIO_TOKEN, since no profile was resolved in that case.
Host string
// Profile is the resolved profile name. Empty when the token came from
// SLIO_TOKEN.
Profile string
// ViaEnvToken is true when SLIO_TOKEN supplied the token, bypassing
// profile resolution entirely.
ViaEnvToken bool
}
Credentials is the resolved outcome of Resolve: the token to use for a single invocation, plus the profile metadata behind it when one was resolved.
func Resolve ¶
Resolve implements slio's credential precedence for a single invocation:
- --profile flag (flagProfile): uses that profile's stored token, ignoring SLIO_TOKEN. Errors if the profile doesn't exist, or if urlHost is set and doesn't match the profile's host (calling the wrong workspace would yield an indistinguishable channel_not_found).
- SLIO_TOKEN: bypasses profile resolution and the unregistered-host check entirely — the caller takes responsibility for the token.
- urlHost auto-selection: the profile whose host matches urlHost. Errors if no profile is registered for that host (no fallback to the default profile, for the same channel_not_found reason as above).
- SLIO_PROFILE.
- The default profile.
SLACK_TOKEN is deliberately never read here.
type File ¶
type File struct {
DefaultProfile string `json:"default_profile"`
Profiles map[string]Profile `json:"profiles"`
}
File is the on-disk representation of ~/.config/slio/config.json.