Browse Source

Merge pull request #438 from gusfcarvalho/fix/433

Fixing ClusterScope access for AzureKV Provider
paul-the-alien[bot] 4 years ago
parent
commit
7ab0fcf502

+ 1 - 1
pkg/provider/azure/keyvault/keyvault.go

@@ -177,7 +177,7 @@ func (a *Azure) newAzureClient(ctx context.Context) (*keyvault.BaseClient, strin
 		return nil, "", fmt.Errorf("missing clientID/clientSecret in store config")
 	}
 	clusterScoped := false
-	if a.store.GetObjectMeta().String() == esv1alpha1.ClusterSecretStoreKind {
+	if a.store.GetObjectKind().GroupVersionKind().Kind == esv1alpha1.ClusterSecretStoreKind {
 		clusterScoped = true
 	}
 	if spec.AuthSecretRef.ClientID == nil || spec.AuthSecretRef.ClientSecret == nil {

+ 8 - 0
pkg/provider/azure/keyvault/keyvault_test.go

@@ -73,6 +73,14 @@ func TestNewClientNoCreds(t *testing.T) {
 	secretClient, err = provider.NewClient(context.Background(), &store, k8sClient, namespace)
 	tassert.EqualError(t, err, "could not find secret internal/user: secrets \"user\" not found")
 	tassert.Nil(t, secretClient)
+	store.TypeMeta.Kind = esv1alpha1.ClusterSecretStoreKind
+	store.TypeMeta.APIVersion = esv1alpha1.ClusterSecretStoreKindAPIVersion
+	ns := "default"
+	store.Spec.Provider.AzureKV.AuthSecretRef.ClientID.Namespace = &ns
+	store.Spec.Provider.AzureKV.AuthSecretRef.ClientSecret.Namespace = &ns
+	secretClient, err = provider.NewClient(context.Background(), &store, k8sClient, namespace)
+	tassert.EqualError(t, err, "could not find secret default/user: secrets \"user\" not found")
+	tassert.Nil(t, secretClient)
 }
 
 const (