Skip to content

Commit

Permalink
Change servicePrinciple to client and ad to activeDirectory. Make cli…
Browse files Browse the repository at this point in the history
…entID required
  • Loading branch information
Mel Cone committed Jan 30, 2020
1 parent 4ae421a commit a4dc5ce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pkg/scalers/azure_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func GetAzureMetricValue(ctx context.Context, metricMetadata *azureMonitorMetada

func newMonitorClient(metadata *azureMonitorMetadata) azureExternalMetricClient {
client := insights.NewMetricsClient(metadata.subscriptionID)
config := auth.NewClientCredentialsConfig(metadata.servicePrincipalID, metadata.servicePrincipalPass, metadata.tentantID)
config := auth.NewClientCredentialsConfig(metadata.clientID, metadata.clientPassword, metadata.tentantID)

authorizer, err := config.Authorizer()
if err == nil {
Expand Down
46 changes: 23 additions & 23 deletions pkg/scalers/azure_monitor_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package scalers
import (
"context"
"fmt"
"strconv"
"strings"
"strconv"
"strings"

v2beta1 "k8s.io/api/autoscaling/v2beta1"
"k8s.io/apimachinery/pkg/api/resource"
Expand All @@ -24,17 +24,17 @@ type azureMonitorScaler struct {
}

type azureMonitorMetadata struct {
resourceURI string
tentantID string
subscriptionID string
resourceGroupName string
name string
filter string
aggregationInterval string
aggregationType string
servicePrincipalID string
servicePrincipalPass string
targetValue int
resourceURI string
tentantID string
subscriptionID string
resourceGroupName string
name string
filter string
aggregationInterval string
aggregationType string
clientID string
clientPassword string
targetValue int
}

var azureMonitorLog = logf.Log.WithName("azure_monitor_scaler")
Expand Down Expand Up @@ -108,25 +108,25 @@ func parseAzureMonitorMetadata(metadata, resolvedEnv, authParams map[string]stri

if val, ok := metadata["metricAggregationInterval"]; ok {
if val != "" {
aggregationInterval := strings.Split(val, ":")
if len(aggregationInterval) != 3 {
return nil, fmt.Errorf("metricAggregationInterval not in the correct format. Should be hh:mm:ss")
}
aggregationInterval := strings.Split(val, ":")
if len(aggregationInterval) != 3 {
return nil, fmt.Errorf("metricAggregationInterval not in the correct format. Should be hh:mm:ss")
}

meta.aggregationInterval = val
}
}

if val, ok := metadata["adServicePrincipleId"]; ok && val != "" {
meta.servicePrincipalID = val
if val, ok := metadata["activeDirectoryClientId"]; ok && val != "" {
meta.clientID = val
} else {
return nil, fmt.Errorf("no adServicePrincipleId given")
return nil, fmt.Errorf("no activeDirectoryClientId given")
}

if val, ok := metadata["adServicePrinciplePassword"]; ok {
meta.servicePrincipalPass = val
if val, ok := metadata["activeDirectoryClientPassword"]; ok && val != "" {
meta.clientPassword = val
} else {
return nil, fmt.Errorf("no adServicePrinciplePassword given")
return nil, fmt.Errorf("no activeDirectoryClientPassword given")
}

return &meta, nil
Expand Down

0 comments on commit a4dc5ce

Please sign in to comment.