@@ -127,13 +127,6 @@ func (d *Deployer) getOperatorIndexImage() string {
127127func (d * Deployer ) createCatalogSource (ctx context.Context , indexImage string ) error {
128128 d .logger .Info ("Creating CatalogSource..." )
129129
130- // Check if CatalogSource CRD supports securityContextConfig (OCP 4.14+).
131- hasSecurityContextConfig , err := d .catalogSourceSupportsSecurityContextConfig (ctx )
132- if err != nil {
133- d .logger .Warning ("Could not check CatalogSource CRD capabilities, proceeding without securityContextConfig" )
134- hasSecurityContextConfig = false
135- }
136-
137130 catalogSource := map [string ]interface {}{
138131 "apiVersion" : "operators.coreos.com/v1alpha1" ,
139132 "kind" : "CatalogSource" ,
@@ -145,24 +138,21 @@ func (d *Deployer) createCatalogSource(ctx context.Context, indexImage string) e
145138 "sourceType" : "grpc" ,
146139 "image" : indexImage ,
147140 "displayName" : "StackRox Operator Index" ,
141+ "grpcPodConfig" : map [string ]interface {}{
142+ "securityContextConfig" : "restricted" ,
143+ },
148144 },
149145 }
150146
151- // TODO(ROX-34499): Add security context config if supported.
152- if hasSecurityContextConfig {
153- spec := catalogSource ["spec" ].(map [string ]interface {})
154- spec ["grpcPodConfig" ] = map [string ]interface {}{
155- "securityContextConfig" : "restricted" ,
156- }
157- }
158-
159147 yamlData , err := yaml .Marshal (catalogSource )
160148 if err != nil {
161149 return fmt .Errorf ("failed to marshal CatalogSource: %w" , err )
162150 }
163151
164152 _ , err = d .runKubectl (ctx , k8s.KubectlOptions {
165- Args : []string {"apply" , "-f" , "-" },
153+ // Apply with --validate=ignore because securityContextConfig may not
154+ // be in the CatalogSource CRD schema.
155+ Args : []string {"apply" , "--validate=ignore" , "-f" , "-" },
166156 Stdin : bytes .NewReader (yamlData ),
167157 })
168158 if err != nil {
@@ -173,20 +163,6 @@ func (d *Deployer) createCatalogSource(ctx context.Context, indexImage string) e
173163 return nil
174164}
175165
176- // catalogSourceSupportsSecurityContextConfig checks if the CatalogSource CRD supports securityContextConfig.
177- func (d * Deployer ) catalogSourceSupportsSecurityContextConfig (ctx context.Context ) (bool , error ) {
178- result , err := d .runKubectl (ctx , k8s.KubectlOptions {
179- Args : []string {"get" , "crd" , "catalogsources.operators.coreos.com" , "-o" , "yaml" },
180- })
181- if err != nil {
182- return false , err
183- }
184-
185- // TODO(ROX-34499): this is overly optimistic and would incorrectly succeed if an api version
186- // that contains this had "serving: false"
187- return strings .Contains (result .Stdout , "securityContextConfig" ), nil
188- }
189-
190166// createOperatorGroup creates the OperatorGroup.
191167func (d * Deployer ) createOperatorGroup (ctx context.Context ) error {
192168 d .logger .Info ("Creating OperatorGroup..." )
0 commit comments