Skip to content

Commit c376e28

Browse files
Merge pull request #2165 from hasbro17/fix-ssa-error-from-empty-string
Filter secret names for registry pod's sa
2 parents 9053ec3 + ee40fd9 commit c376e28

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pkg/controller/registry/reconciler/grpc.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ func (s *grpcCatalogSourceDecorator) ServiceAccount() *corev1.ServiceAccount {
9898
blockOwnerDeletion := true
9999
isController := true
100100
for _, secretName := range s.CatalogSource.Spec.Secrets {
101+
if secretName == "" {
102+
continue
103+
}
101104
secrets = append(secrets, corev1.LocalObjectReference{Name: secretName})
102105
}
103106
return &corev1.ServiceAccount{

pkg/controller/registry/reconciler/grpc_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func validGrpcCatalogSource(image, address string) *v1alpha1.CatalogSource {
3333
}
3434
}
3535

36-
func grpcCatalogSourceWithSecret(secretName string) *v1alpha1.CatalogSource {
36+
func grpcCatalogSourceWithSecret(secretNames []string) *v1alpha1.CatalogSource {
3737
return &v1alpha1.CatalogSource{
3838
ObjectMeta: metav1.ObjectMeta{
3939
Name: "private-catalog",
@@ -45,7 +45,7 @@ func grpcCatalogSourceWithSecret(secretName string) *v1alpha1.CatalogSource {
4545
Image: "private-image",
4646
Address: "",
4747
SourceType: v1alpha1.SourceTypeGrpc,
48-
Secrets: []string{secretName},
48+
Secrets: secretNames,
4949
},
5050
}
5151
}
@@ -61,6 +61,10 @@ func TestGrpcRegistryReconciler(t *testing.T) {
6161
blockOwnerDeletion := true
6262
isController := true
6363

64+
// We expect the empty string secret name should not be set
65+
// on the service account
66+
testSecrets := []string{"test-secret", ""}
67+
6468
type cluster struct {
6569
k8sObjs []runtime.Object
6670
}
@@ -225,7 +229,7 @@ func TestGrpcRegistryReconciler(t *testing.T) {
225229
},
226230
},
227231
},
228-
catsrc: grpcCatalogSourceWithSecret("test-secret"),
232+
catsrc: grpcCatalogSourceWithSecret(testSecrets),
229233
},
230234
out: out{
231235
status: &v1alpha1.RegistryServiceStatus{

0 commit comments

Comments
 (0)