Help us shape the future of Go! Take the 2026 Go Developer Survey

profile

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

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

func ResolveProfile(ctx context.Context, opts ResolveProfileOptions) (*Profile, Profiles, error)

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)

func (Credentials) Store

func (c Credentials) Store(ctx context.Context) error

type Name

type Name string

func (Name) MarshalText

func (n Name) MarshalText() ([]byte, error)

func (Name) String

func (n Name) String() string

func (*Name) UnmarshalText

func (n *Name) UnmarshalText(text []byte) (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) RemoveCredentials

func (p Profile) RemoveCredentials(ctx context.Context) error

func (Profile) String

func (p Profile) String() string

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)

func (Profiles) Store

func (ps Profiles) Store(ctx context.Context) 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

type SettingSources = setting.Sources

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL