Documentation
¶
Overview ¶
Package resolve decides which profile, endpoints, organization, credentials and output format one command uses, and remembers where each value came from (for `norcube config list`).
Precedence, highest first:
profile --profile > NORCUBE_PROFILE > default_profile > "default"
organization --org > NORCUBE_ORG > project file (.langsync.json) > profile
endpoints --endpoint-url svc=url (and --auth-url, --web-app)
> NORCUBE_<SERVICE>_URL > profile endpoints > environment
credentials --token-file > NORCUBE_TOKEN > profile credential_store > keyring
output -o > NORCUBE_OUTPUT > profile output > [defaults] output > table
The project file is read by the commands that support it (LangSync); this package reports whether --org or NORCUBE_ORG already decided.
Index ¶
Constants ¶
const ( EnvProfile = "NORCUBE_PROFILE" EnvOrg = "NORCUBE_ORG" EnvToken = "NORCUBE_TOKEN" // #nosec G101 -- the variable's name, not a credential EnvOutput = "NORCUBE_OUTPUT" )
Environment variables read here.
const (
CredentialTokenFile = "token-file"
)
Credentials sources beyond the profile's stores.
Variables ¶
This section is empty.
Functions ¶
func ParseEndpoints ¶
ParseEndpoints turns --endpoint-url values ("service=url") into a map.
func ProfileNames ¶
ProfileNames returns the profiles defined in f, sorted.
func ValidateProfileName ¶
ValidateProfileName rejects names that can't be a TOML table key, a keyring item or a file name on every OS.
Types ¶
type Input ¶
type Input struct {
File *config.File
Getenv func(string) string
Profile string // --profile
Org string // --org
// Output is -o; OutputSet tells an explicit -o table from the default.
Output string
OutputSet bool
// Endpoints are --endpoint-url service=url values, plus --auth-url and
// --web-app mapped to their services.
Endpoints map[string]string
TokenFile string // --token-file
}
Input is everything a command was given.
type Result ¶
type Result struct {
Profile Value
// ProfileDefined is false when the profile isn't in the config file
// yet (a first login, or the implicit "default").
ProfileDefined bool
Environment Value
Endpoints map[string]Value
// Org is the organization as given (slug or id); empty when none.
// OrgOverride is true when it came from --org or NORCUBE_ORG, which
// beat a project file.
Org Value
OrgOverride bool
// Credentials is keyring, file, env (NORCUBE_TOKEN) or token-file.
Credentials Value
// TokenFile is the --token-file path when Credentials is token-file.
TokenFile string
Output Value
// contains filtered or unexported fields
}
Result is the resolved configuration of one command.
func (*Result) StoredProfile ¶
StoredProfile returns the profile's stored settings (an empty profile when it isn't defined).