Documentation
¶
Overview ¶
Package credentials resolves and manages shared Circles credentials.
Index ¶
- func IsError(err error, code ErrorCode) bool
- type Credential
- type CredentialProvider
- type Error
- type ErrorCode
- type FilePaths
- type Kind
- type Option
- func WithClientID(clientID string) Option
- func WithConfigFile(path string) Option
- func WithCredential(value string) Option
- func WithCredentialProvider(provider CredentialProvider) Option
- func WithCredentialsFile(path string) Option
- func WithEnvironment(environment map[string]string) Option
- func WithHTTPClient(client *http.Client) Option
- func WithHomeDir(home string) Option
- func WithLockTimeout(timeout time.Duration) Option
- func WithNow(now func() time.Time) Option
- func WithProfile(profile string) Option
- type ProfileConfig
- type ProfileCredentials
- type ProfileUpdate
- type Provider
- func (provider *Provider) ClearProfiles(ctx context.Context) error
- func (provider *Provider) CurrentProfile(ctx context.Context) (string, bool, error)
- func (provider *Provider) DeleteProfile(ctx context.Context) error
- func (provider *Provider) GetProfile(ctx context.Context) (*StoredProfile, error)
- func (provider *Provider) Paths() FilePaths
- func (provider *Provider) Refresh(ctx context.Context) (Credential, error)
- func (provider *Provider) Resolve(ctx context.Context) (Credential, error)
- func (provider *Provider) SelectedProfileName(ctx context.Context) (string, error)
- func (provider *Provider) SetCurrentProfile(ctx context.Context, profile string) error
- func (provider *Provider) UpdateProfile(ctx context.Context, update ProfileUpdate) error
- type Source
- type SourceType
- type StoredProfile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Credential ¶
Credential is a resolved Circles Bearer credential.
type CredentialProvider ¶
type CredentialProvider interface {
Resolve(context.Context) (Credential, error)
}
CredentialProvider resolves a credential with cancellation support.
type Error ¶
type Error struct {
Code ErrorCode
// contains filtered or unexported fields
}
Error is safe to show to a user and never contains credential values.
type ErrorCode ¶
type ErrorCode string
ErrorCode is a stable, language-neutral credential failure category.
const ( ErrCredentialNotFound ErrorCode = "CREDENTIAL_NOT_FOUND" ErrInvalidCredential ErrorCode = "INVALID_CREDENTIAL" ErrAmbiguousCredential ErrorCode = "AMBIGUOUS_CREDENTIAL" ErrRefreshFailed ErrorCode = "REFRESH_FAILED" ErrProfileConflict ErrorCode = "PROFILE_CONFLICT" ErrCredentialStorage ErrorCode = "CREDENTIAL_STORAGE_FAILED" )
type FilePaths ¶
type FilePaths struct {
ConfigFile string
CredentialsFile string
LegacyConfigFile string
LegacyCredentialsFile string
LegacyJSONFile string
}
FilePaths are the canonical and compatibility paths used by a Provider.
type Option ¶
type Option func(*providerOptions)
Option configures a Provider.
func WithClientID ¶
WithClientID replaces the OAuth public client identifier.
func WithConfigFile ¶
WithConfigFile replaces the shared config path.
func WithCredential ¶
WithCredential supplies the highest-precedence in-memory Bearer value.
func WithCredentialProvider ¶
func WithCredentialProvider(provider CredentialProvider) Option
WithCredentialProvider supplies the highest-precedence credential provider.
func WithCredentialsFile ¶
WithCredentialsFile replaces the shared credentials path.
func WithEnvironment ¶
WithEnvironment replaces the process environment, primarily for embedding and tests.
func WithHTTPClient ¶
WithHTTPClient replaces the OAuth refresh HTTP client.
func WithHomeDir ¶
WithHomeDir replaces the operating-system home directory.
func WithLockTimeout ¶
WithLockTimeout replaces the cross-process lock wait timeout.
func WithProfile ¶
WithProfile selects a named profile explicitly.
type ProfileConfig ¶
ProfileConfig contains non-secret endpoint and default-context settings.
type ProfileCredentials ¶
ProfileCredentials replaces one profile's credential form.
type ProfileUpdate ¶
type ProfileUpdate struct {
Config *ProfileConfig
Credentials *ProfileCredentials
}
ProfileUpdate updates either or both shared profile files.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider resolves and manages Circles shared credentials.
func (*Provider) ClearProfiles ¶
ClearProfiles removes all canonical profiles while retaining legacy rollback files.
func (*Provider) CurrentProfile ¶ added in v1.1.0
CurrentProfile returns the persisted non-secret current-profile selection.
func (*Provider) DeleteProfile ¶
DeleteProfile removes the selected canonical profile while retaining migration history.
func (*Provider) GetProfile ¶
func (provider *Provider) GetProfile(ctx context.Context) (*StoredProfile, error)
GetProfile returns only a selected profile's non-secret settings.
func (*Provider) Refresh ¶
func (provider *Provider) Refresh(ctx context.Context) (Credential, error)
Refresh forces OAuth refresh for the selected profile.
func (*Provider) Resolve ¶
func (provider *Provider) Resolve(ctx context.Context) (Credential, error)
Resolve evaluates the shared provider chain.
func (*Provider) SelectedProfileName ¶ added in v1.1.0
SelectedProfileName returns the profile selected by explicit options, environment variables, shared current-profile metadata, or legacy default.
func (*Provider) SetCurrentProfile ¶ added in v1.1.0
SetCurrentProfile makes an existing credential profile the shared default selection.
func (*Provider) UpdateProfile ¶
func (provider *Provider) UpdateProfile(ctx context.Context, update ProfileUpdate) error
UpdateProfile atomically replaces each changed profile file.
type Source ¶
type Source struct {
Type SourceType `json:"type"`
Profile string `json:"profile,omitempty"`
}
Source contains only non-secret diagnostic metadata.
type SourceType ¶
type SourceType string
SourceType identifies the winning provider category.
const ( SourceExplicit SourceType = "explicit" SourceEnvironment SourceType = "environment" SourceProfile SourceType = "profile" )
type StoredProfile ¶
type StoredProfile struct {
Name string
Config ProfileConfig
}
StoredProfile is the non-secret portion of a named profile.