]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / aws / aws-sdk-go / aws / credentials / static_provider.go
CommitLineData
bae9f6d2
JC
1package credentials
2
3import (
4 "github.com/aws/aws-sdk-go/aws/awserr"
5)
6
7// StaticProviderName provides a name of Static provider
8const StaticProviderName = "StaticProvider"
9
10var (
11 // ErrStaticCredentialsEmpty is emitted when static credentials are empty.
bae9f6d2
JC
12 ErrStaticCredentialsEmpty = awserr.New("EmptyStaticCreds", "static credentials are empty", nil)
13)
14
15// A StaticProvider is a set of credentials which are set programmatically,
16// and will never expire.
17type StaticProvider struct {
18 Value
19}
20
21// NewStaticCredentials returns a pointer to a new Credentials object
22// wrapping a static credentials value provider.
23func NewStaticCredentials(id, secret, token string) *Credentials {
24 return NewCredentials(&StaticProvider{Value: Value{
25 AccessKeyID: id,
26 SecretAccessKey: secret,
27 SessionToken: token,
28 }})
29}
30
31// NewStaticCredentialsFromCreds returns a pointer to a new Credentials object
32// wrapping the static credentials value provide. Same as NewStaticCredentials
33// but takes the creds Value instead of individual fields
34func NewStaticCredentialsFromCreds(creds Value) *Credentials {
35 return NewCredentials(&StaticProvider{Value: creds})
36}
37
38// Retrieve returns the credentials or error if the credentials are invalid.
39func (s *StaticProvider) Retrieve() (Value, error) {
40 if s.AccessKeyID == "" || s.SecretAccessKey == "" {
41 return Value{ProviderName: StaticProviderName}, ErrStaticCredentialsEmpty
42 }
43
44 if len(s.Value.ProviderName) == 0 {
45 s.Value.ProviderName = StaticProviderName
46 }
47 return s.Value, nil
48}
49
50// IsExpired returns if the credentials are expired.
51//
52// For StaticProvider, the credentials never expired.
53func (s *StaticProvider) IsExpired() bool {
54 return false
55}