Documentation
¶
Overview ¶
Package config manages cflio's on-disk configuration (registered Confluence site profiles and their API 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. Returns "(none)" if none are registered.
func SortedProfileNames ¶
SortedProfileNames returns the registered profile names in a stable order. Every listing and lookup that walks the profiles goes through it, so error messages, `profile list` and the host-matching scan can never disagree about ordering the way raw map iteration would.
Types ¶
type Credentials ¶
Credentials is the resolved outcome of Resolve: everything a single invocation needs to authenticate, plus the name of the profile it came from (needed for error messages and status output).
func Resolve ¶
Resolve implements cflio's credential precedence for a single invocation:
- --profile flag (flagProfile): uses that profile. Errors if the profile doesn't exist, or if urlHost is set and doesn't match the profile's host — talking to the wrong site would yield an indistinguishable "page not found".
- urlHost auto-selection: the profile whose host matches urlHost. Errors if no profile is registered for that host; there is deliberately no fallback to the default profile, for the same reason as above.
- CFLIO_PROFILE, which stands in for the default profile. It does not override URL-host auto-selection, and it is not checked for host conflicts — only an explicit --profile is.
- The default profile.
CFLIO_TOKEN, if set, then replaces the resolved profile's token; the site and email still come from the profile, so a profile must resolve either way. Shared-namespace variables such as ATLASSIAN_API_TOKEN are deliberately never read.
type File ¶
type File struct {
DefaultProfile string `json:"default_profile"`
Profiles map[string]Profile `json:"profiles"`
}
File is the on-disk representation of ~/.config/cflio/config.json.
type Profile ¶
type Profile struct {
// SiteURL is the Confluence base URL including the /wiki path, e.g.
// "https://example.atlassian.net/wiki". The host is derived from it
// rather than stored separately, so there is no second copy to drift.
SiteURL string `json:"site_url"`
Email string `json:"email"`
Token string `json:"token"`
}
Profile holds the stored credentials for a single registered site.
func (Profile) Host ¶
Host returns the profile's site host, or "" if SiteURL cannot be parsed. `auth login` validates SiteURL before storing it, so an unparseable value means a hand-edited config; the empty host then simply fails to match any URL, which surfaces as the regular unregistered-host error.