credentials

package
v0.102.4-0...-cdaec67 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingIncomplete = errors.New("missing or incomplete API credentials")
)
View Source
var (
	ErrNoValidCredentialProviders = errors.New("no valid credential providers")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	Name                string
	Account             string
	SosEndpoint         string
	Environment         string
	Key                 string
	Secret              string
	SecretCommand       []string
	DefaultZone         string
	DefaultSSHKey       string
	DefaultTemplate     string
	DefaultOutputFormat string
	ClientTimeout       int
	CustomHeaders       map[string]string
}

type ChainProvider

type ChainProvider struct {
	Providers []Provider
	// contains filtered or unexported fields
}

A ChainProvider will search for a provider which returns credentials and cache that provider until Retrieve is called again.

func (*ChainProvider) IsExpired

func (c *ChainProvider) IsExpired() bool

IsExpired will returned the expired state of the currently cached provider if there is one. If there is no current provider, true will be returned.

func (*ChainProvider) Retrieve

func (c *ChainProvider) Retrieve() (Value, error)

Retrieve returns the first provider in the chain that succeeds, or error if no provider returned.

If a provider is found it will be cached and any calls to IsExpired() will return the expired state of the cached provider.

type Config

type Config struct {
	DefaultAccount      string
	DefaultOutputFormat string
	Accounts            []Account
}

type Credentials

type Credentials struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewChainCredentials

func NewChainCredentials(providers []Provider) *Credentials

NewChainCredentials returns a pointer to a new Credentials object wrapping a chain of providers.

func NewCredentials

func NewCredentials(provider Provider) *Credentials

func NewEnvCredentials

func NewEnvCredentials() *Credentials

func NewFileCredentials

func NewFileCredentials(opts ...FileOpt) *Credentials

func NewStaticCredentials

func NewStaticCredentials(apiKey, apiSecret string) *Credentials

func (*Credentials) Expire

func (c *Credentials) Expire()

func (*Credentials) Get

func (c *Credentials) Get() (Value, error)

func (*Credentials) IsExpired

func (c *Credentials) IsExpired() bool

type EnvProvider

type EnvProvider struct {
	// contains filtered or unexported fields
}

func (*EnvProvider) IsExpired

func (e *EnvProvider) IsExpired() bool

IsExpired returns if the credentials have been retrieved.

func (*EnvProvider) Retrieve

func (e *EnvProvider) Retrieve() (Value, error)

Retrieve retrieves the keys from the environment.

type FileOpt

type FileOpt func(*FileProvider)

func FileOptWithAccount

func FileOptWithAccount(account string) FileOpt

FileOptWithAccount returns a FileOpt overriding the default account.

func FileOptWithFilename

func FileOptWithFilename(filename string) FileOpt

FileOptWithFilename returns a FileOpt overriding the default filename.

type FileProvider

type FileProvider struct {
	// contains filtered or unexported fields
}

func (*FileProvider) IsExpired

func (f *FileProvider) IsExpired() bool

IsExpired returns if the shared credentials have expired.

func (*FileProvider) Retrieve

func (f *FileProvider) Retrieve() (Value, error)

type Provider

type Provider interface {
	// Retrieve returns nil if it successfully retrieved the value.
	// Error is returned if the value were not obtainable, or empty.
	Retrieve() (Value, error)

	// IsExpired returns if the credentials are no longer valid, and need
	// to be retrieved.
	IsExpired() bool
}

type StaticProvider

type StaticProvider struct {
	// contains filtered or unexported fields
}

A StaticProvider is a set of credentials which are set programmatically, and will never expire.

func (*StaticProvider) IsExpired

func (s *StaticProvider) IsExpired() bool

IsExpired returns if the credentials are expired.

For StaticProvider, the credentials never expired.

func (*StaticProvider) Retrieve

func (s *StaticProvider) Retrieve() (Value, error)

Retrieve returns the credentials or error if the credentials are invalid.

type Value

type Value struct {
	APIKey    string
	APISecret string
}

func (Value) IsSet

func (v Value) IsSet() bool

IsSet returns true if the credentials Value has both APIKey and APISecret.

Jump to

Keyboard shortcuts

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