Skip to content

Filter secret names for registry pod's sa #2165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/controller/registry/reconciler/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ func (s *grpcCatalogSourceDecorator) ServiceAccount() *corev1.ServiceAccount {
blockOwnerDeletion := true
isController := true
for _, secretName := range s.CatalogSource.Spec.Secrets {
if secretName == "" {
continue
}
secrets = append(secrets, corev1.LocalObjectReference{Name: secretName})
}
return &corev1.ServiceAccount{
Expand Down
10 changes: 7 additions & 3 deletions pkg/controller/registry/reconciler/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func validGrpcCatalogSource(image, address string) *v1alpha1.CatalogSource {
}
}

func grpcCatalogSourceWithSecret(secretName string) *v1alpha1.CatalogSource {
func grpcCatalogSourceWithSecret(secretNames []string) *v1alpha1.CatalogSource {
return &v1alpha1.CatalogSource{
ObjectMeta: metav1.ObjectMeta{
Name: "private-catalog",
Expand All @@ -45,7 +45,7 @@ func grpcCatalogSourceWithSecret(secretName string) *v1alpha1.CatalogSource {
Image: "private-image",
Address: "",
SourceType: v1alpha1.SourceTypeGrpc,
Secrets: []string{secretName},
Secrets: secretNames,
},
}
}
Expand All @@ -61,6 +61,10 @@ func TestGrpcRegistryReconciler(t *testing.T) {
blockOwnerDeletion := true
isController := true

// We expect the empty string secret name should not be set
// on the service account
testSecrets := []string{"test-secret", ""}

type cluster struct {
k8sObjs []runtime.Object
}
Expand Down Expand Up @@ -225,7 +229,7 @@ func TestGrpcRegistryReconciler(t *testing.T) {
},
},
},
catsrc: grpcCatalogSourceWithSecret("test-secret"),
catsrc: grpcCatalogSourceWithSecret(testSecrets),
},
out: out{
status: &v1alpha1.RegistryServiceStatus{
Expand Down