Skip to content

Commit

Permalink
fix: makes env vars for azure tenant-id and gcp credentials file more…
Browse files Browse the repository at this point in the history
… consistent w/ flags.

Signed-off-by: ianhundere <[email protected]>
  • Loading branch information
ianhundere committed Dec 17, 2024
1 parent bc4d463 commit ee76983
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/certificate_maker/certificate_maker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
}
Expand Down
14 changes: 14 additions & 0 deletions cmd/certificate_maker/certificate_maker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ee76983

Please sign in to comment.