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 : Optional [list ] = None ,
4041 approve_wildcards : str = False ,
4142 outraw : bool = False ,
4243 outraw_pretty_print : bool = False ,
@@ -64,6 +65,9 @@ def acipolicygen_confcom(
6465 "For additional information, see http://aka.ms/clisecrets. \n " ,
6566 )
6667
68+ if container_definitions is None :
69+ container_definitions = []
70+
6771 stdio_enabled = resolve_stdio (enable_stdio , disable_stdio )
6872
6973 if print_existing_policy and arm_template :
@@ -147,6 +151,16 @@ def acipolicygen_confcom(
147151 exclude_default_fragments = exclude_default_fragments ,
148152 infrastructure_svn = infrastructure_svn ,
149153 )
154+ elif container_definitions :
155+ container_group_policies = AciPolicy (
156+ {
157+ ACI_FIELD_VERSION : "1.0" ,
158+ ACI_FIELD_CONTAINERS : [],
159+ },
160+ debug_mode = debug_mode ,
161+ disable_stdio = disable_stdio ,
162+ container_definitions = container_definitions ,
163+ )
150164
151165 exit_code = 0
152166
@@ -227,6 +241,7 @@ def acifragmentgen_confcom(
227241 key : str ,
228242 chain : str ,
229243 minimum_svn : str ,
244+ container_definitions : Optional [list ] = None ,
230245 image_target : str = "" ,
231246 algo : str = "ES384" ,
232247 fragment_path : str = None ,
@@ -241,6 +256,8 @@ def acifragmentgen_confcom(
241256 no_print : bool = False ,
242257 fragments_json : str = "" ,
243258):
259+ if container_definitions is None :
260+ container_definitions = []
244261
245262 stdio_enabled = resolve_stdio (enable_stdio , disable_stdio )
246263
@@ -299,13 +316,27 @@ def acifragmentgen_confcom(
299316 policy = security_policy .load_policy_from_image_name (
300317 image_name , debug_mode = debug_mode , disable_stdio = (not stdio_enabled )
301318 )
302- else :
319+ elif input_path :
303320 # this is using --input
304321 if not tar_mapping :
305322 tar_mapping = os_util .load_tar_mapping_from_config_file (input_path )
306323 policy = security_policy .load_policy_from_json_file (
307324 input_path , debug_mode = debug_mode , disable_stdio = (not stdio_enabled )
308325 )
326+ elif container_definitions :
327+ policy = AciPolicy (
328+ {
329+ ACI_FIELD_VERSION : "1.0" ,
330+ ACI_FIELD_CONTAINERS : [],
331+ },
332+ debug_mode = debug_mode ,
333+ disable_stdio = disable_stdio ,
334+ container_definitions = container_definitions ,
335+ )
336+ else :
337+ eprint ("Either --image-name, --input, or --container-definitions must be provided" , exit_code = 2 )
338+ return
339+
309340 # get all of the fragments that are being used in the policy
310341 # and associate them with each container group
311342 fragment_policy_list = []
@@ -321,7 +352,7 @@ def acifragmentgen_confcom(
321352
322353 # make sure we have images to generate a fragment
323354 policy_images = policy .get_images ()
324- if not policy_images :
355+ if not policy_images and not container_definitions :
325356 eprint ("No images found in the policy or all images are covered by fragments" )
326357
327358 if not feed :
0 commit comments