Skip to content

Commit

Permalink
fixup! Misc
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com>
  • Loading branch information
pierre-emmanuelJ committed Dec 22, 2023
1 parent 4d12fb8 commit 55bbc85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
3 changes: 1 addition & 2 deletions v3/credentials/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ type Value struct {
APISecret string
}

// HasKeys returns if the credentials Value has both AccessKeyID and
// SecretAccessKey value set.
// HasKeys returns true if the credentials Value has both APIKey and APISecret.
func (v Value) HasKeys() bool {
return v.APIKey != "" && v.APISecret != ""
}
Expand Down
13 changes: 6 additions & 7 deletions v3/credentials/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ func NewEnvCredentials() *Credentials {
func (e *EnvProvider) Retrieve() (Value, error) {
e.retrieved = false

key := os.Getenv("AWS_ACCESS_KEY_ID")
secret := os.Getenv("AWS_SECRET_ACCESS_KEY")
v := Value{
APIKey: os.Getenv("EXOSCALE_API_KEY"),
APISecret: os.Getenv("EXOSCALE_API_SECRET"),
}

if key == "" || secret == "" {
if !v.HasKeys() {
return Value{}, ErrMissingIncomplete
}

e.retrieved = true
return Value{
APIKey: key,
APISecret: secret,
}, nil
return v, nil
}

// IsExpired returns if the credentials have been retrieved.
Expand Down

0 comments on commit 55bbc85

Please # to comment.