@@ -251,7 +251,10 @@ def get_asset_names(job_definition: Dict[str, Any]) -> Set[str]:
251
251
def get_file_assets (job_definition : Dict [str , Any ]) -> List [Dict [str , str ]]:
252
252
"""Given a Job definition this function returns the list of all the
253
253
file-based assets declared. What's returned is the asset 'name' and the
254
- 'image file' the asset is expected to mapped to.
254
+ 'image file' the asset is expected to be mapped to.
255
+
256
+ In order to get the asset the caller will need to interact with the
257
+ Account Server (AS), what is returned here is the asset name, not the asset.
255
258
"""
256
259
file_assets : List [Dict [str , str ]] = []
257
260
@@ -269,6 +272,32 @@ def get_file_assets(job_definition: Dict[str, Any]) -> List[Dict[str, str]]:
269
272
return file_assets
270
273
271
274
275
+ def get_environment_assets (job_definition : Dict [str , Any ]) -> List [Dict [str , str ]]:
276
+ """Given a Job definition this function returns the list of all the
277
+ environment-based assets declared. What's returned is the asset 'name' and the
278
+ environment 'variable' the asset is expected to be mapped to.
279
+
280
+ In order to get the asset the caller will need to interact with the
281
+ Account Server (AS), what is returned here is the asset name, not the asset.
282
+ """
283
+ env_assets : List [Dict [str , str ]] = []
284
+
285
+ # Iterate through the environment block...
286
+ environment : List [Dict [str , Any ]] = job_definition .get ("image" , {}).get (
287
+ "environment" , []
288
+ )
289
+ for item in environment :
290
+ if "account-server-asset" in item ["value-from" ]:
291
+ env_assets .append (
292
+ {
293
+ "asset" : item ["value-from" ]["account-server-asset" ]["name" ],
294
+ "variable" : item ["name" ],
295
+ }
296
+ )
297
+
298
+ return env_assets
299
+
300
+
272
301
def decode (
273
302
template_text : str ,
274
303
variable_map : Optional [Dict [str , str ]],
0 commit comments