@@ -106,9 +106,15 @@ func Rotate(account, provider, project string, c config.Config) (err error) {
106106 return
107107 }
108108 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+ }
109115 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 {
112118 logger .Infow ("Posting metrics errored" , metricErr )
113119 }
114120 }
@@ -145,12 +151,12 @@ func Rotate(account, provider, project string, c config.Config) (err error) {
145151 if err = rotateKeys (rc , c .Credentials ); err != nil {
146152 return
147153 }
148- if isDatadogKeySet ( c . DatadogAPIKey ) {
154+ if ddAPIKey != "" {
149155 // Refresh key ages post rotation
150156 if providerKeys , err = keysOfProviders (account , provider , project , c ); err != nil {
151157 return
152158 }
153- return postMetric (providerKeys , c . DatadogAPIKey , c .Datadog )
159+ return postMetric (providerKeys , ddAPIKey , c .Datadog )
154160 }
155161 return
156162}
0 commit comments