Skip to content

Commit e7d189f

Browse files
committed
Add CEL content in PBs created by build_ds_container.py
1 parent be0071e commit e7d189f

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

utils/build_ds_container.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def copy_build_files_to_output_directory(output_directory):
207207
build_directory = os.path.join(REPO_PATH, 'build')
208208
for f in os.listdir(build_directory):
209209
filepath = os.path.join(build_directory, f)
210-
if os.path.isfile(filepath) and filepath.endswith('-ds.xml'):
210+
if os.path.isfile(filepath) and (filepath.endswith('-ds.xml') or filepath.endswith('-cel-content.yaml')):
211211
shutil.copy(filepath, output_directory)
212212

213213

@@ -235,17 +235,34 @@ def create_profile_bundles(products, content_image=None):
235235
product_name = product
236236
else:
237237
product_name = 'upstream-' + product
238+
239+
# Check if CEL content exists for this product
240+
cel_content_file = product + '-cel-content.yaml'
241+
build_directory = os.path.join(REPO_PATH, 'build')
242+
cel_content_path = os.path.join(build_directory, cel_content_file)
243+
244+
profile_bundle_spec = {
245+
'contentImage': content_image or 'openscap-ocp4-ds:latest',
246+
'contentFile': content_file
247+
}
248+
249+
# Add celContentFile if CEL content exists
250+
if os.path.isfile(cel_content_path):
251+
profile_bundle_spec['celContentFile'] = cel_content_file
252+
log.debug(f'Including CEL content for {product}: {cel_content_file}')
253+
238254
profile_bundle_update = {
239255
'apiVersion': 'compliance.openshift.io/v1alpha1',
240256
'kind': 'ProfileBundle',
241257
'metadata': {'name': product_name},
242-
'spec': {
243-
'contentImage': content_image or 'openscap-ocp4-ds:latest',
244-
'contentFile': content_file}}
258+
'spec': profile_bundle_spec
259+
}
260+
245261
with tempfile.NamedTemporaryFile() as f:
246262
yaml.dump(profile_bundle_update, f, encoding='utf-8')
247263
command = ['kubectl', 'apply', '-n', args.namespace, '-f', f.name]
248264
subprocess.run(command, check=True, capture_output=CAPTURE_OUTPUT)
265+
249266
log.info(f'Created profile bundles for {", ".join(products)}')
250267

251268

0 commit comments

Comments
 (0)