From feaac36d007bce15fbc0381fdf102a6d58bb7f1f Mon Sep 17 00:00:00 2001 From: Erik Kristensen Date: Tue, 17 May 2022 00:17:23 +0000 Subject: [PATCH] allow tenant override by env var --- pkg/azure/client_certificate.go | 3 +++ pkg/azure/client_secret.go | 3 +++ pkg/azure/client_token.go | 3 +++ 3 files changed, 9 insertions(+) diff --git a/pkg/azure/client_certificate.go b/pkg/azure/client_certificate.go index 43bd318..a4c8629 100644 --- a/pkg/azure/client_certificate.go +++ b/pkg/azure/client_certificate.go @@ -21,6 +21,9 @@ func AcquireTokenClientCertificate(ctx context.Context, tenantID, resource strin if v := os.Getenv("AZURE_AUTHORITY_HOST"); v != "" { authorityHost = v } + if v := os.Getenv("AZURE_TENANT_ID"); v != "" { + tenantID = v + } // trim the suffix / if exists resource = strings.TrimSuffix(resource, "/") diff --git a/pkg/azure/client_secret.go b/pkg/azure/client_secret.go index efb9403..72b1d91 100644 --- a/pkg/azure/client_secret.go +++ b/pkg/azure/client_secret.go @@ -17,6 +17,9 @@ func AcquireTokenClientSecret(ctx context.Context, tenantID, resource string) fu if v := os.Getenv("AZURE_AUTHORITY_HOST"); v != "" { authorityHost = v } + if v := os.Getenv("AZURE_TENANT_ID"); v != "" { + tenantID = v + } // trim the suffix / if exists resource = strings.TrimSuffix(resource, "/") diff --git a/pkg/azure/client_token.go b/pkg/azure/client_token.go index b91aa88..0bb7309 100644 --- a/pkg/azure/client_token.go +++ b/pkg/azure/client_token.go @@ -26,6 +26,9 @@ func AcquireTokenFederatedToken(ctx context.Context, tenantID string) func(tenan if v := os.Getenv("AZURE_AUTHORITY_HOST"); v != "" { authorityHost = v } + if v := os.Getenv("AZURE_TENANT_ID"); v != "" { + tenantID = v + } // trim the suffix / if exists resource = strings.TrimSuffix(resource, "/")