Skip to content

Commit

Permalink
Enable dd api key from creds object (#915)
Browse files Browse the repository at this point in the history
  • Loading branch information
eversC authored Jan 9, 2024
1 parent d159fef commit 70eb07e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/rotate/rotatekeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,15 @@ func Rotate(account, provider, project string, c config.Config) (err error) {
return
}
logger.Infof("Filtered down to %d keys based on current app config", len(providerKeys))
ddAPIKey := ""
if isDatadogKeySet(c.DatadogAPIKey) {
ddAPIKey = c.DatadogAPIKey
} else if isDatadogKeySet(c.Credentials.Datadog.APIKey) {
ddAPIKey = c.Credentials.Datadog.APIKey
}
if !c.RotationMode {
if isDatadogKeySet(c.DatadogAPIKey) {
if metricErr := postMetric(providerKeys, c.DatadogAPIKey, c.Datadog); metricErr != nil {
if ddAPIKey != "" {
if metricErr := postMetric(providerKeys, ddAPIKey, c.Datadog); metricErr != nil {
logger.Infow("Posting metrics errored", metricErr)
}
}
Expand Down Expand Up @@ -145,12 +151,12 @@ func Rotate(account, provider, project string, c config.Config) (err error) {
if err = rotateKeys(rc, c.Credentials); err != nil {
return
}
if isDatadogKeySet(c.DatadogAPIKey) {
if ddAPIKey != "" {
// Refresh key ages post rotation
if providerKeys, err = keysOfProviders(account, provider, project, c); err != nil {
return
}
return postMetric(providerKeys, c.DatadogAPIKey, c.Datadog)
return postMetric(providerKeys, ddAPIKey, c.Datadog)
}
return
}
Expand Down

0 comments on commit 70eb07e

Please sign in to comment.