Documentation ¶
Index ¶
Constants ¶
const EnvProviderName = "EnvProvider"
const StaticProviderName = "StaticProvider"
Variables ¶
var ( ErrEnvUserNotFound = checkpointerror.New("EnvUserNotFound", "CHECKPOINT_USER not found in environment", nil) ErrEnvPasswordNotFound = checkpointerror.New("EnvPasswordNotFound", "CHECKPOINT_PASSWORD not found in environment", nil) )
var AnonymousCredentials = NewStaticCredentials("", "")
var (
ErrStaticCredentialsEmpty = checkpointerror.New("EmptyStaticCreds", "static credentials are empty", nil)
)
Functions ¶
This section is empty.
Types ¶
type ChainProvider ¶
type ChainProvider struct { Providers []Provider // contains filtered or unexported fields }
func (*ChainProvider) IsExpired ¶
func (c *ChainProvider) IsExpired() bool
func (*ChainProvider) Retrieve ¶
func (c *ChainProvider) Retrieve() (Value, error)
type Credentials ¶
type Credentials struct {
// contains filtered or unexported fields
}
A Credentials provides concurrency safe retrieval of a credentials Value. Credentials will cache the credentials value until they expire. Once the value expires the next Get will attempt to retrieve valid 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 Value. All calls to Get() after that will return the cached credentials Value until IsExpired() returns true.
func NewChainCredentials ¶
func NewChainCredentials(providers []Provider) *Credentials
func NewCredentials ¶
func NewCredentials(provider Provider) *Credentials
NewCredentials returns a pointer to a new Credentials with the provider set.
func NewEnvCredentials ¶
func NewEnvCredentials() *Credentials
func NewStaticCredentials ¶
func NewStaticCredentials(user, password string) *Credentials
func NewStaticCredentialsFromCreds ¶
func NewStaticCredentialsFromCreds(creds Value) *Credentials
func (*Credentials) Get ¶
func (c *Credentials) Get() (Value, error)
Get returns the credentials value, or error if the credentials Value failed to be retrieved.
Will return the cached credentials Value if it has not expired. If the credentials Value has expired the Provider's Retrieve() will be called to refresh the credentials.
If Credentials.Expire() was called the credentials Value will be force expired, and the next call to Get() will cause them to be refreshed.
func (*Credentials) IsExpired ¶
func (c *Credentials) IsExpired() bool
IsExpired returns if the credentials are no longer valid, and need to be retrieved.
If the Credentials were forced to be expired with Expire() this will reflect that override.
type EnvProvider ¶
type EnvProvider struct {
// contains filtered or unexported fields
}
A EnvProvider retrieves credentials from the environment variables of the running process. Environment credentials never expire.
Environment variables used:
* User: CHECKPOINT_USER
* Password: CHECKPOINT_PASSWORD
func (*EnvProvider) IsExpired ¶
func (e *EnvProvider) IsExpired() bool
IsExpired returns false if the credentials have been retrieved.
func (*EnvProvider) Retrieve ¶
func (e *EnvProvider) Retrieve() (Value, error)
Retrieve retrieves the keys from the environment.
type ErrorProvider ¶
type ErrorProvider struct { // The error to be returned from Retrieve Err error // The provider name to set on the Retrieved returned Value ProviderName string }
An ErrorProvider is a stub credentials provider that always returns an error this is used by the SDK when construction a known provider is not possible due to an error.
func (ErrorProvider) IsExpired ¶
func (p ErrorProvider) IsExpired() bool
IsExpired will always return not expired.
func (ErrorProvider) Retrieve ¶
func (p ErrorProvider) Retrieve() (Value, error)
Retrieve will always return the error that the ErrorProvider was created with.
type Provider ¶
type Provider interface { Retrieve() (Value, error) // IsExpired returns if the credentials are no longer valid, and need // to be retrieved. IsExpired() bool }
Credentials provider interface
type StaticProvider ¶
type StaticProvider struct {
Value
}
func (*StaticProvider) IsExpired ¶
func (s *StaticProvider) IsExpired() bool
For StaticProvider, the credentials never expire.
func (*StaticProvider) Retrieve ¶
func (s *StaticProvider) Retrieve() (Value, error)