@@ -831,6 +831,19 @@ func TestNamespaceResolverRBAC(t *testing.T) {
831
831
},
832
832
}
833
833
bundle := bundleWithPermissions ("a.v1" , "a" , "alpha" , "" , nil , nil , nil , nil , simplePermissions , simplePermissions )
834
+ defaultServiceAccountPermissions := []v1alpha1.StrategyDeploymentPermissions {
835
+ {
836
+ ServiceAccountName : "default" ,
837
+ Rules : []rbacv1.PolicyRule {
838
+ {
839
+ Verbs : []string {"get" , "list" },
840
+ APIGroups : []string {"" },
841
+ Resources : []string {"configmaps" },
842
+ },
843
+ },
844
+ },
845
+ }
846
+ bundleWithDefaultServiceAccount := bundleWithPermissions ("a.v1" , "a" , "alpha" , "" , nil , nil , nil , nil , defaultServiceAccountPermissions , defaultServiceAccountPermissions )
834
847
type out struct {
835
848
steps [][]* v1alpha1.Step
836
849
subs []* v1alpha1.Subscription
@@ -857,6 +870,21 @@ func TestNamespaceResolverRBAC(t *testing.T) {
857
870
},
858
871
},
859
872
},
873
+ {
874
+ name : "don't create default service accounts" ,
875
+ clusterState : []runtime.Object {
876
+ newSub (namespace , "a" , "alpha" , catalog ),
877
+ },
878
+ bundlesInCatalog : []* api.Bundle {bundleWithDefaultServiceAccount },
879
+ out : out {
880
+ steps : [][]* v1alpha1.Step {
881
+ withoutResourceKind ("ServiceAccount" , bundleSteps (bundleWithDefaultServiceAccount , namespace , "" , catalog )),
882
+ },
883
+ subs : []* v1alpha1.Subscription {
884
+ updatedSub (namespace , "a.v1" , "" , "a" , "alpha" , catalog ),
885
+ },
886
+ },
887
+ },
860
888
}
861
889
for _ , tt := range tests {
862
890
t .Run (tt .name , func (t * testing.T ) {
@@ -1028,6 +1056,18 @@ func bundleSteps(bundle *api.Bundle, ns, replaces string, catalog registry.Catal
1028
1056
return steps
1029
1057
}
1030
1058
1059
+ func withoutResourceKind (kind string , steps []* v1alpha1.Step ) []* v1alpha1.Step {
1060
+ filtered := make ([]* v1alpha1.Step , 0 )
1061
+
1062
+ for i , s := range steps {
1063
+ if s .Resource .Kind != kind {
1064
+ filtered = append (filtered , steps [i ])
1065
+ }
1066
+ }
1067
+
1068
+ return filtered
1069
+ }
1070
+
1031
1071
func subSteps (namespace , operatorName , pkgName , channelName string , catalog registry.CatalogKey ) []* v1alpha1.Step {
1032
1072
sub := & v1alpha1.Subscription {
1033
1073
ObjectMeta : metav1.ObjectMeta {
0 commit comments