1 package credentials
2 3 // A StaticProvider is a set of credentials which are set programmatically,
4 // and will never expire.
5 type StaticProvider struct {
6 creds Value
7 retrieved bool
8 }
9 10 func NewStaticCredentials(apiKey, apiSecret string) *Credentials {
11 return NewCredentials(
12 &StaticProvider{creds: Value{APIKey: apiKey, APISecret: apiSecret}},
13 )
14 }
15 16 // Retrieve returns the credentials or error if the credentials are invalid.
17 func (s *StaticProvider) Retrieve() (Value, error) {
18 if !s.creds.IsSet() {
19 return Value{}, ErrMissingIncomplete
20 }
21 22 s.retrieved = true
23 24 return s.creds, nil
25 }
26 27 // IsExpired returns if the credentials are expired.
28 //
29 // For StaticProvider, the credentials never expired.
30 func (s *StaticProvider) IsExpired() bool {
31 return !s.retrieved
32 }
33