Documentation ¶
Index ¶
Constants ¶
const ( // EnvCredentialsToken specifies the name of the environment variable points // to the Spot Token. EnvCredentialsToken = credentials.EnvCredentialsVarToken // EnvCredentialsAccount specifies the name of the environment variable points // to the Spot account ID. EnvCredentialsAccount = credentials.EnvCredentialsVarAccount )
Variables ¶
var ErrEnvCredentialsNotFound = fmt.Errorf("credentials: %s and %s not found "+ "in environment", EnvCredentialsToken, EnvCredentialsAccount)
ErrEnvCredentialsNotFound is returned when no credentials can be found in the process's environment.
var ErrNoValidProvidersFoundInChain = errors.New("credentials: no valid " +
"credentials providers in chain")
ErrNoValidProvidersFoundInChain Is returned when there are no valid credentials providers in the ChainProvider.
var ErrSecretCredentialsNotFound = fmt.Errorf("credentials: %s and %s not found "+ "in Secret", EnvCredentialsToken, EnvCredentialsAccount)
ErrSecretCredentialsNotFound is returned when no credentials can be found in Secret.
Functions ¶
This section is empty.
Types ¶
type ChainProvider ¶
type ChainProvider struct {
Providers []Provider
}
ChainProvider will search for a provider which returns credentials and cache that provider until Retrieve is called again.
The ChainProvider provides a way of chaining multiple providers together which will pick the first available using priority order of the Providers in the list.
If none of the Providers retrieve valid credentials, Retrieve() will return the error ErrNoValidProvidersFoundInChain.
If a Provider is found which returns valid credentials, ChainProvider will cache that Provider for all calls until Retrieve is called again.
func (*ChainProvider) Retrieve ¶
func (x *ChainProvider) Retrieve(ctx context.Context) (*Value, error)
Retrieve retrieves and returns the credentials, or error in case of failure.
func (*ChainProvider) String ¶
func (x *ChainProvider) String() string
String returns the string representation of the Chain provider.
type Credentials ¶
type Credentials struct {
// contains filtered or unexported fields
}
Credentials provides synchronous safe retrieval of credentials.
Credentials is safe to use across multiple goroutines and will manage the synchronous state so the Providers do not need to implement their own synchronization.
The first Credentials.Get() will always call Provider.Retrieve() to get the first instance of the credentials. All calls to Get() after that will return the cached credentials.
func NewChainProvider ¶
func NewChainProvider(providers ...Provider) *Credentials
NewChainProvider returns a new Credentials object wrapping a chain of providers.
func NewCredentials ¶
func NewCredentials(provider Provider) *Credentials
NewCredentials returns a new Credentials with the provider set.
func NewEnvProvider ¶
func NewEnvProvider() *Credentials
NewEnvProvider returns a new Credentials object wrapping the Env provider.
func NewSecretProvider ¶
func NewSecretProvider(client client.Client, name, namespace string) *Credentials
NewSecretProvider returns a new Credentials object wrapping the Secret provider.
func (*Credentials) Get ¶
func (x *Credentials) Get(ctx context.Context) (*Value, error)
Get returns the credentials, or error if the credentials failed to be retrieved. Will return the cached credentials. If the credentials are empty the Provider's Retrieve() will be called to refresh the credentials.
func (*Credentials) Refresh ¶
func (x *Credentials) Refresh() *Credentials
Refresh refreshes the credentials and forces it to be retrieved on the next call to Get().
type EnvProvider ¶
type EnvProvider struct{}
EnvProvider retrieves credentials from the environment variables of the process.
func (*EnvProvider) Retrieve ¶
func (x *EnvProvider) Retrieve(ctx context.Context) (*Value, error)
Retrieve retrieves and returns the credentials, or error in case of failure.
func (*EnvProvider) String ¶
func (x *EnvProvider) String() string
String returns the string representation of the Env provider.
type Provider ¶
type Provider interface { fmt.Stringer // Retrieve retrieves and returns the credentials, or error in case of failure. Retrieve(ctx context.Context) (*Value, error) }
Provider defines the interface for any component which will provide credentials. The Provider should not need to implement its own mutexes, because that will be managed by Config.
type SecretProvider ¶
SecretProvider retrieves credentials from a Secret.
func (*SecretProvider) Retrieve ¶
func (x *SecretProvider) Retrieve(ctx context.Context) (*Value, error)
Retrieve retrieves and returns the credentials, or error in case of failure.
func (*SecretProvider) String ¶
func (x *SecretProvider) String() string
String returns the string representation of the Secret provider.