@@ -106,9 +106,15 @@ func Rotate(account, provider, project string, c config.Config) (err error) {
106
106
return
107
107
}
108
108
logger .Infof ("Filtered down to %d keys based on current app config" , len (providerKeys ))
109
+ ddAPIKey := ""
110
+ if isDatadogKeySet (c .DatadogAPIKey ) {
111
+ ddAPIKey = c .DatadogAPIKey
112
+ } else if isDatadogKeySet (c .Credentials .Datadog .APIKey ) {
113
+ ddAPIKey = c .Credentials .Datadog .APIKey
114
+ }
109
115
if ! c .RotationMode {
110
- if isDatadogKeySet ( c . DatadogAPIKey ) {
111
- if metricErr := postMetric (providerKeys , c . DatadogAPIKey , c .Datadog ); metricErr != nil {
116
+ if ddAPIKey != "" {
117
+ if metricErr := postMetric (providerKeys , ddAPIKey , c .Datadog ); metricErr != nil {
112
118
logger .Infow ("Posting metrics errored" , metricErr )
113
119
}
114
120
}
@@ -145,12 +151,12 @@ func Rotate(account, provider, project string, c config.Config) (err error) {
145
151
if err = rotateKeys (rc , c .Credentials ); err != nil {
146
152
return
147
153
}
148
- if isDatadogKeySet ( c . DatadogAPIKey ) {
154
+ if ddAPIKey != "" {
149
155
// Refresh key ages post rotation
150
156
if providerKeys , err = keysOfProviders (account , provider , project , c ); err != nil {
151
157
return
152
158
}
153
- return postMetric (providerKeys , c . DatadogAPIKey , c .Datadog )
159
+ return postMetric (providerKeys , ddAPIKey , c .Datadog )
154
160
}
155
161
return
156
162
}
0 commit comments