Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NameSetting = setting.Setting[Name]{ Env: "MESHSTACK_PROFILE", Short: func(envKey string) string { return fmt.Sprintf("The profile whose credentials and defaults this run uses. Also read from %s.", envKey) }, Long: func(envKey string) string { return fmt.Sprintf("The profile whose credentials and defaults this run uses, also read from `%s`.\n\n"+ "A profile is a named bundle of endpoint and credential, written by "+ "`meshstack auth login` into the meshStack CLI's configuration directory. It supplies each of those "+ "only where nothing above it did, so it is never an override.\n\n"+ "With no name given, the profile is the one whose endpoint matches the endpoint in use, else the one "+ "the last `meshstack auth login` selected, else `default`.", envKey) }, Default: setting.StaticDefault("default"), Parse: setting.ParseTextUnmarshaler[Name], }
Functions ¶
func ResolveProfile ¶
ResolveProfile loads every profile from disk, creating a default one when there is none. The returned *Profile points into Profiles.Profiles, so a change through the pointer is persisted by a later Profiles.Store.
Types ¶
type Credentials ¶
type Credentials struct {
credential.Credentials
Version int `json:"version"`
FilePath string `json:"-"`
// contains filtered or unexported fields
}
func (Credentials) ModifyCache ¶
func (c Credentials) ModifyCache(ctx context.Context, cred credential.Credential, action func() error) (err error)
func (Credentials) ReadCache ¶
func (c Credentials) ReadCache(ctx context.Context, cred credential.Credential, action func() error) (err error)
type Profile ¶
type Profile struct {
Endpoint *xurl.URL `json:"endpoint,omitzero"`
DefaultWorkspace meshstack.Workspace `json:"default_workspace,omitzero"`
Credential credential.Name `json:"credential,omitzero"`
// Name and ConfigDir are set by [Profile.init] after load or create, not by the JSON.
Name Name `json:"-"`
ConfigDir config.Directory `json:"-"`
}
func (Profile) Credentials ¶
func (p Profile) Credentials(ctx context.Context) (out Credentials, err error)
func (Profile) EndpointSource ¶
func (p Profile) EndpointSource() setting.FallbackSource
EndpointSource ranks below the environment, which is what lets ResolveSession catch an endpoint that does not match the profile rather than quietly using the profile's own.
func (Profile) WorkspaceSource ¶
func (p Profile) WorkspaceSource() setting.FallbackSource
WorkspaceSource ranks below the environment and below an interactive prompt: it is what a login remembered, never an override of what this run asks for.
type Profiles ¶
type Profiles struct {
Version int `json:"version"`
CurrentProfile Name `json:"currentProfile,omitzero"`
Profiles map[Name]*Profile `json:"profiles,omitzero"`
// contains filtered or unexported fields
}
func LoadProfiles ¶
func LoadProfiles(ctx context.Context, opts ResolveProfileOptions) (profiles Profiles, err error)
type ResolveProfileOptions ¶
type ResolveProfileOptions struct {
SettingSources
// CreateProfileIfMissing writes the resolved name as a new profile instead of failing on
// it. Only a login may ask for that: for every other command an unknown name is a typo,
// and an empty profile is no help to it.
CreateProfileIfMissing bool
}
type SettingSources ¶
Click to show internal directories.
Click to hide internal directories.