| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package credentials
- import (
- "github.com/ks3sdklib/aws-sdk-go/internal/apierr"
- )
- var (
- // ErrStaticCredentialsEmpty is emitted when static credentials are empty.
- ErrStaticCredentialsEmpty = apierr.New("EmptyStaticCreds", "static credentials are empty", nil)
- )
- // A StaticProvider is a set of credentials which are set pragmatically,
- // and will never expire.
- type StaticProvider struct {
- Value
- }
- // NewStaticCredentials returns a pointer to a new Credentials object
- // wrapping a static credentials value provider.
- func NewStaticCredentials(id, secret, token string) *Credentials {
- return NewCredentials(&StaticProvider{Value: Value{
- AccessKeyID: id,
- SecretAccessKey: secret,
- SessionToken: token,
- }})
- }
- // Retrieve returns the credentials or error if the credentials are invalid.
- func (s *StaticProvider) Retrieve() (Value, error) {
- if s.AccessKeyID == "" || s.SecretAccessKey == "" {
- return Value{}, ErrStaticCredentialsEmpty
- }
- return s.Value, nil
- }
- // IsExpired returns if the credentials are expired.
- //
- // For StaticProvider, the credentials never expired.
- func (s *StaticProvider) IsExpired() bool {
- return false
- }
|