@@ -108,17 +108,7 @@ def generate(node_id, # pylint: disable=too-many-arguments, too-many-locals
108
108
configs ['storage' ][storage ]
109
109
if storage else None
110
110
)
111
- if not runtime :
112
- raise click .ClickException ("No runtime provided (--runtime)" )
113
- runtimes_section = configs .get ('runtimes' , None )
114
- if runtimes_section is None :
115
- raise click .ClickException ("No runtimes section found in the config" )
116
- runtime_config = runtimes_section .get (runtime , None )
117
- if runtime_config is None :
118
- raise click .ClickException (f"Runtime { runtime } not found in the config" )
119
- runtime = kernelci .runtime .get_runtime (
120
- runtime_config , token = secrets .api .runtime_token ,
121
- custom_template_dir = config [0 ] if config else None )
111
+ runtime = _get_runtime (runtime , config , secrets )
122
112
params = runtime .get_params (job , api .config )
123
113
if not params :
124
114
raise click .ClickException ("Invalid job parameters, aborting..." )
@@ -138,6 +128,16 @@ def generate(node_id, # pylint: disable=too-many-arguments, too-many-locals
138
128
click .echo (job_data )
139
129
140
130
131
+ def _get_runtime (runtime , config , secrets ):
132
+ configs = kernelci .config .load (config )
133
+ runtime_config = configs ['runtimes' ][runtime ]
134
+ runtime = kernelci .runtime .get_runtime (
135
+ runtime_config , token = secrets .api .runtime_token ,
136
+ custom_template_dir = config [0 ] if config else None
137
+ )
138
+ return runtime
139
+
140
+
141
141
@kci_job .command (secrets = True )
142
142
@click .argument ('job-path' )
143
143
@click .option ('--wait' , is_flag = True )
0 commit comments