@@ -81,7 +81,7 @@ def build_image(image_name: str, build_configuration: ImageBuildConfiguration):
81
81
def image_build_config_from_args (args ) -> ImageBuildConfiguration :
82
82
image = args .image
83
83
84
- build_scenario = BuildScenario (args .scenario ) or BuildScenario .infer_scenario_from_environment ()
84
+ build_scenario = get_scenario_from_arg (args .scenario ) or BuildScenario .infer_scenario_from_environment ()
85
85
86
86
build_info = load_build_info (build_scenario )
87
87
image_build_info = build_info .images .get (image )
@@ -92,7 +92,7 @@ def image_build_config_from_args(args) -> ImageBuildConfiguration:
92
92
# TODO: cover versions for agents and OM images
93
93
version = args .version or image_build_info .version
94
94
registry = args .registry or image_build_info .repository
95
- platforms = get_platforms_from_arg (args ) or image_build_info .platforms
95
+ platforms = get_platforms_from_arg (args . platform ) or image_build_info .platforms
96
96
sign = args .sign or image_build_info .sign
97
97
# TODO: remove "all_agents" from context and environment variables support (not needed anymore)
98
98
all_agents = args .all_agents or build_scenario .all_agents ()
@@ -109,12 +109,22 @@ def image_build_config_from_args(args) -> ImageBuildConfiguration:
109
109
)
110
110
111
111
112
- def get_platforms_from_arg (args ):
112
+ def get_scenario_from_arg (args_scenario : str ) -> BuildScenario | None :
113
+ if args_scenario :
114
+ try :
115
+ return BuildScenario (args_scenario )
116
+ except ValueError as e :
117
+ raise ValueError (f"Invalid scenario '{ args_scenario } ': { e } " )
118
+
119
+ return None
120
+
121
+
122
+ def get_platforms_from_arg (args_platforms : str ) -> list [str ] | None :
113
123
"""Parse and validate the --platform argument"""
114
- platforms = [p .strip () for p in args . platform .split ("," )]
124
+ platforms = [p .strip () for p in args_platforms .split ("," )]
115
125
if any (p not in SUPPORTED_PLATFORMS for p in platforms ):
116
126
raise ValueError (
117
- f"Unsupported platform in --platforms '{ args . platform } '. Supported platforms: { ', ' .join (SUPPORTED_PLATFORMS )} "
127
+ f"Unsupported platform in --platforms '{ args_platforms } '. Supported platforms: { ', ' .join (SUPPORTED_PLATFORMS )} "
118
128
)
119
129
return platforms
120
130
0 commit comments