From ee76983381f2392db6b6d6240ba38219f261c143 Mon Sep 17 00:00:00 2001 From: ianhundere <138915+ianhundere@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:49:28 -0500 Subject: [PATCH] fix: makes env vars for azure tenant-id and gcp credentials file more consistent w/ flags. Signed-off-by: ianhundere <138915+ianhundere@users.noreply.github.com> --- cmd/certificate_maker/certificate_maker.go | 4 ++-- cmd/certificate_maker/certificate_maker_test.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd/certificate_maker/certificate_maker.go b/cmd/certificate_maker/certificate_maker.go index 4cae6bd1..5361a342 100644 --- a/cmd/certificate_maker/certificate_maker.go +++ b/cmd/certificate_maker/certificate_maker.go @@ -119,7 +119,7 @@ func runCreate(_ *cobra.Command, _ []string) error { // Handle KMS provider options switch config.Type { case "gcpkms": - if credsFile := getConfigValue(kmsCredsFile, "KMS_CREDENTIALS_FILE"); credsFile != "" { + if credsFile := getConfigValue(kmsCredsFile, "GCP_CREDENTIALS_FILE"); credsFile != "" { // Check if credentials file exists before trying to use it if _, err := os.Stat(credsFile); err != nil { if os.IsNotExist(err) { @@ -130,7 +130,7 @@ func runCreate(_ *cobra.Command, _ []string) error { config.Options["credentials-file"] = credsFile } case "azurekms": - if tenantID := getConfigValue(kmsTenantID, "KMS_TENANT_ID"); tenantID != "" { + if tenantID := getConfigValue(kmsTenantID, "AZURE_TENANT_ID"); tenantID != "" { config.Options["tenant-id"] = tenantID } } diff --git a/cmd/certificate_maker/certificate_maker_test.go b/cmd/certificate_maker/certificate_maker_test.go index 9ae4a91d..8b0844d0 100644 --- a/cmd/certificate_maker/certificate_maker_test.go +++ b/cmd/certificate_maker/certificate_maker_test.go @@ -54,6 +54,20 @@ func TestGetConfigValue(t *testing.T) { envValue: "", want: "", }, + { + name: "GCP credentials file from env", + flagValue: "", + envVar: "GCP_CREDENTIALS_FILE", + envValue: "/path/to/creds.json", + want: "/path/to/creds.json", + }, + { + name: "Azure tenant ID from env", + flagValue: "", + envVar: "AZURE_TENANT_ID", + envValue: "tenant-123", + want: "tenant-123", + }, } for _, tt := range tests {