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

profile

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 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 CachedCredential added in v0.2.0

type CachedCredential struct {
	credential.Credential
	// contains filtered or unexported fields
}

CachedCredential is the token cache of the one credential a session uses, shared with every other process using the same profile and credential.

func (CachedCredential) Load added in v0.2.0

func (c CachedCredential) Load(ctx context.Context) error

func (CachedCredential) Modify added in v0.2.0

func (c CachedCredential) Modify(ctx context.Context, action func() error) error

func (CachedCredential) Read added in v0.2.0

func (c CachedCredential) Read(ctx context.Context, action func() error) error

func (CachedCredential) Write added in v0.2.0

func (c CachedCredential) Write(ctx context.Context) error

Write stores the cache even when it is nil, because the identity alone is what lets a later Modify write back the token it mints.

type Credentials

type Credentials struct {
	credential.Credentials

	Version  int    `json:"version"`
	FilePath string `json:"-"`
}

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 might be meshstack.NoWorkspace (empty string), default value when being unmarshaled.
	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) CacheFor added in v0.2.0

func (p Profile) CacheFor(cred credential.Credential) CachedCredential

func (Profile) Credentials

func (p Profile) Credentials(ctx context.Context) (out Credentials, err error)

func (Profile) EndpointSource

func (p Profile) EndpointSource() setting.FallbackSource

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

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
}

type SettingSources

type SettingSources = setting.Sources

Jump to

Keyboard shortcuts

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