Skip to content

Commit

Permalink
fix: use tenantID instead of tenantId in parameters (#898)
Browse files Browse the repository at this point in the history
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
  • Loading branch information
aramase committed May 26, 2022
1 parent 2540d1c commit 858b765
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/provider/types/parameters.go
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"gopkg.in/yaml.v2"
"k8s.io/klog/v2"
)

// GetKeyVaultName returns the key vault name
Expand Down Expand Up @@ -42,6 +43,12 @@ func GetUserAssignedIdentityID(parameters map[string]string) string {

// GetTenantID returns the tenant ID
func GetTenantID(parameters map[string]string) string {
// ref: https://github.com/Azure/secrets-store-csi-driver-provider-azure/issues/857
tenantID := strings.TrimSpace(parameters["tenantID"])
if tenantID != "" {
return tenantID
}
klog.V(3).Info("tenantId is deprecated and will be removed in a future release. Use 'tenantID' instead")
return strings.TrimSpace(parameters[TenantIDParameter])
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/provider/types/parameters_test.go
Expand Up @@ -293,6 +293,20 @@ func TestGetTenantID(t *testing.T) {
},
expected: "test",
},
{
name: "new tenantID parameter",
parameters: map[string]string{
"tenantID": "test",
},
expected: "test",
},
{
name: "new tenantID parameter with spaces",
parameters: map[string]string{
"tenantID": " test ",
},
expected: "test",
},
}

for _, test := range tests {
Expand Down
2 changes: 2 additions & 0 deletions pkg/provider/types/types.go
Expand Up @@ -38,6 +38,8 @@ const (
// UserAssignedIdentityIDParameter is the name of the user assigned identity ID parameter
UserAssignedIdentityIDParameter = "userAssignedIdentityID"
// TenantIDParameter is the name of the tenant ID parameter
// TODO(aramase): change this from tenantId to tenantID after v1.2 release
// ref: https://github.com/Azure/secrets-store-csi-driver-provider-azure/issues/857
TenantIDParameter = "tenantId"
// CloudEnvFileNameParameter is the name of the cloud env file name parameter
CloudEnvFileNameParameter = "cloudEnvFileName"
Expand Down

0 comments on commit 858b765

Please sign in to comment.