1111from azext_confcom ._validators import resolve_stdio
1212from azext_confcom .config import (
1313 DEFAULT_REGO_FRAGMENTS , POLICY_FIELD_CONTAINERS_ELEMENTS_REGO_FRAGMENTS ,
14- REGO_IMPORT_FILE_STRUCTURE )
14+ REGO_IMPORT_FILE_STRUCTURE , ACI_FIELD_VERSION , ACI_FIELD_CONTAINERS )
1515from azext_confcom .cose_proxy import CoseSignToolProxy
1616from azext_confcom .errors import eprint
1717from azext_confcom .fragment_util import get_all_fragment_contents
1818from azext_confcom .init_checks import run_initial_docker_checks
1919from azext_confcom .kata_proxy import KataPolicyGenProxy
20- from azext_confcom .security_policy import OutputType
20+ from azext_confcom .security_policy import AciPolicy , OutputType
2121from azext_confcom .template_util import (
2222 get_image_name , inject_policy_into_template , inject_policy_into_yaml ,
2323 pretty_print_func , print_existing_policy_from_arm_template ,
@@ -37,6 +37,7 @@ def acipolicygen_confcom(
3737 virtual_node_yaml_path : str ,
3838 infrastructure_svn : str ,
3939 tar_mapping_location : str ,
40+ container_definitions : list ,
4041 approve_wildcards : str = False ,
4142 outraw : bool = False ,
4243 outraw_pretty_print : bool = False ,
@@ -147,6 +148,16 @@ def acipolicygen_confcom(
147148 exclude_default_fragments = exclude_default_fragments ,
148149 infrastructure_svn = infrastructure_svn ,
149150 )
151+ elif container_definitions :
152+ container_group_policies = AciPolicy (
153+ {
154+ ACI_FIELD_VERSION : "1.0" ,
155+ ACI_FIELD_CONTAINERS : [],
156+ },
157+ debug_mode = debug_mode ,
158+ disable_stdio = disable_stdio ,
159+ container_definitions = container_definitions ,
160+ )
150161
151162 exit_code = 0
152163
@@ -227,6 +238,7 @@ def acifragmentgen_confcom(
227238 key : str ,
228239 chain : str ,
229240 minimum_svn : str ,
241+ container_definitions : list ,
230242 image_target : str = "" ,
231243 algo : str = "ES384" ,
232244 fragment_path : str = None ,
@@ -299,13 +311,24 @@ def acifragmentgen_confcom(
299311 policy = security_policy .load_policy_from_image_name (
300312 image_name , debug_mode = debug_mode , disable_stdio = (not stdio_enabled )
301313 )
302- else :
314+ elif input_path :
303315 # this is using --input
304316 if not tar_mapping :
305317 tar_mapping = os_util .load_tar_mapping_from_config_file (input_path )
306318 policy = security_policy .load_policy_from_json_file (
307319 input_path , debug_mode = debug_mode , disable_stdio = (not stdio_enabled )
308320 )
321+ elif container_definitions :
322+ policy = AciPolicy (
323+ {
324+ ACI_FIELD_VERSION : "1.0" ,
325+ ACI_FIELD_CONTAINERS : [],
326+ },
327+ debug_mode = debug_mode ,
328+ disable_stdio = disable_stdio ,
329+ container_definitions = container_definitions ,
330+ )
331+
309332 # get all of the fragments that are being used in the policy
310333 # and associate them with each container group
311334 fragment_policy_list = []
@@ -321,7 +344,7 @@ def acifragmentgen_confcom(
321344
322345 # make sure we have images to generate a fragment
323346 policy_images = policy .get_images ()
324- if not policy_images :
347+ if not policy_images and not container_definitions :
325348 eprint ("No images found in the policy or all images are covered by fragments" )
326349
327350 if not feed :
0 commit comments