Skip to content

Commit

Permalink
update naming to UseCredentialFromEnvironment
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie McBride authored and Charlie McBride committed Jan 23, 2024
1 parent 04452c9 commit 77f28fb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile-az.mk
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ az-patch-skaffold-azureoverlay: az-patch-skaffold az-fetch-network-info
# old identity path is still the default, so need to override the values values with new logic.
# TODO (chmcbrid): update the new logic path as the default.
$(eval KARPENTER_USER_ASSIGNED_CLIENT_ID=$(shell az identity show --resource-group "${AZURE_RESOURCE_GROUP}" --name "${AZURE_KARPENTER_USER_ASSIGNED_IDENTITY_NAME}" --query 'clientId' -otsv))
yq -i '(.manifests.helm.releases[0].overrides.controller.env[] | select(.name=="ARM_USE_NEW_CRED_WORKFLOW")) .value = "true"' skaffold.yaml
yq -i '(.manifests.helm.releases[0].overrides.controller.env[] | select(.name=="ARM_USE_CREDENTIAL_FROM_ENVIRONMENT")) .value = "true"' skaffold.yaml
yq -i '(.manifests.helm.releases[0].overrides.controller.env[] | select(.name=="ARM_USE_MANAGED_IDENTITY_EXTENSION")) .value = "false"' skaffold.yaml
yq -i '(.manifests.helm.releases[0].overrides.controller.env[] | select(.name=="ARM_USER_ASSIGNED_IDENTITY_ID")) .value = ""' skaffold.yaml

Expand Down
2 changes: 1 addition & 1 deletion pkg/auth/autorest_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

func NewAuthorizer(config *Config, env *azure.Environment) (autorest.Authorizer, error) {
// TODO (charliedmcb): need to get track 2 support for the skewer API, and align all auth under workload identity in the same way within cred.go
if config.UseNewCredWorkflow {
if config.UseCredentialFromEnvironment {
klog.V(2).Infoln("auth: using workload identity for new authorizer")
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
Expand Down
22 changes: 11 additions & 11 deletions pkg/auth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ type Config struct {
AuthMethod string `json:"authMethod" yaml:"authMethod"`

// Settings for a service principal.
AADClientID string `json:"aadClientId" yaml:"aadClientId"`
AADClientSecret string `json:"aadClientSecret" yaml:"aadClientSecret"`
AADClientCertPath string `json:"aadClientCertPath" yaml:"aadClientCertPath"`
AADClientCertPassword string `json:"aadClientCertPassword" yaml:"aadClientCertPassword"`
UseNewCredWorkflow bool `json:"useNewCredWorkflow" yaml:"useNewCredWorkflow"`
UseManagedIdentityExtension bool `json:"useManagedIdentityExtension" yaml:"useManagedIdentityExtension"`
UserAssignedIdentityID string `json:"userAssignedIdentityID" yaml:"userAssignedIdentityID"`
AADClientID string `json:"aadClientId" yaml:"aadClientId"`
AADClientSecret string `json:"aadClientSecret" yaml:"aadClientSecret"`
AADClientCertPath string `json:"aadClientCertPath" yaml:"aadClientCertPath"`
AADClientCertPassword string `json:"aadClientCertPassword" yaml:"aadClientCertPassword"`
UseCredentialFromEnvironment bool `json:"useCredentialFromEnvironment" yaml:"useCredentialFromEnvironment"`
UseManagedIdentityExtension bool `json:"useManagedIdentityExtension" yaml:"useManagedIdentityExtension"`
UserAssignedIdentityID string `json:"userAssignedIdentityID" yaml:"userAssignedIdentityID"`

//Configs only for AKS
ClusterName string `json:"clusterName" yaml:"clusterName"`
Expand Down Expand Up @@ -115,13 +115,13 @@ func (cfg *Config) BaseVars() {
}

func (cfg *Config) prepareID() error {
useNewCredWorkflowFromEnv := os.Getenv("ARM_USE_NEW_CRED_WORKFLOW")
if len(useNewCredWorkflowFromEnv) > 0 {
shouldUse, err := strconv.ParseBool(useNewCredWorkflowFromEnv)
useCredentialFromEnvironmentFromEnv := os.Getenv("ARM_USE_CREDENTIAL_FROM_ENVIRONMENT")
if len(useCredentialFromEnvironmentFromEnv) > 0 {
shouldUse, err := strconv.ParseBool(useCredentialFromEnvironmentFromEnv)
if err != nil {
return err
}
cfg.UseNewCredWorkflow = shouldUse
cfg.UseCredentialFromEnvironment = shouldUse
}
useManagedIdentityExtensionFromEnv := os.Getenv("ARM_USE_MANAGED_IDENTITY_EXTENSION")
if len(useManagedIdentityExtensionFromEnv) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/auth/cred.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewCredential(cfg *Config) (azcore.TokenCredential, error) {
return nil, fmt.Errorf("failed to create credential, nil config provided")
}

if cfg.UseNewCredWorkflow {
if cfg.UseCredentialFromEnvironment {
klog.V(2).Infoln("cred: using workload identity for new credential")
return azidentity.NewDefaultAzureCredential(nil)
}
Expand Down
2 changes: 1 addition & 1 deletion skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ manifests:
value: "Please run make az-all"
- name: LOCATION
value: westus2
- name: ARM_USE_NEW_CRED_WORKFLOW
- name: ARM_USE_CREDENTIAL_FROM_ENVIRONMENT
value: "false"
- name: ARM_USE_MANAGED_IDENTITY_EXTENSION
value: "true"
Expand Down

0 comments on commit 77f28fb

Please sign in to comment.