Skip to content

Commit ea3a33d

Browse files
SpiritZhouzhenghanzhou
and
zhenghanzhou
authored
Refactor Azure Monitor Scaler (#6646)
Signed-off-by: zhenghanzhou <[email protected]> Co-authored-by: zhenghanzhou <[email protected]>
1 parent c2d4c44 commit ea3a33d

File tree

3 files changed

+151
-191
lines changed

3 files changed

+151
-191
lines changed

Diff for: pkg/scalers/azure_app_insights_scaler.go

+27
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,33 @@ func parseAzureAppInsightsMetadata(config *scalersconfig.ScalerConfig, logger lo
189189
return &meta, nil
190190
}
191191

192+
// parseAzurePodIdentityParams gets the activeDirectory clientID and password
193+
func parseAzurePodIdentityParams(config *scalersconfig.ScalerConfig) (clientID string, clientPassword string, err error) {
194+
switch config.PodIdentity.Provider {
195+
case "", kedav1alpha1.PodIdentityProviderNone:
196+
clientID, err = getParameterFromConfig(config, "activeDirectoryClientId", true)
197+
if err != nil || clientID == "" {
198+
return "", "", fmt.Errorf("no activeDirectoryClientId given")
199+
}
200+
201+
if config.AuthParams["activeDirectoryClientPassword"] != "" {
202+
clientPassword = config.AuthParams["activeDirectoryClientPassword"]
203+
} else if config.TriggerMetadata["activeDirectoryClientPasswordFromEnv"] != "" {
204+
clientPassword = config.ResolvedEnv[config.TriggerMetadata["activeDirectoryClientPasswordFromEnv"]]
205+
}
206+
207+
if len(clientPassword) == 0 {
208+
return "", "", fmt.Errorf("no activeDirectoryClientPassword given")
209+
}
210+
case kedav1alpha1.PodIdentityProviderAzureWorkload:
211+
// no params required to be parsed
212+
default:
213+
return "", "", fmt.Errorf("azure Monitor doesn't support pod identity %s", config.PodIdentity.Provider)
214+
}
215+
216+
return clientID, clientPassword, nil
217+
}
218+
192219
func (s *azureAppInsightsScaler) Close(context.Context) error {
193220
return nil
194221
}

0 commit comments

Comments
 (0)