Skip to content

Commit

Permalink
Custom actions fail when action not defined in pipeline (#3647)
Browse files Browse the repository at this point in the history
* Custom actions fail in release 0.12
Fixes #3646

* up api version

* up api version

* Make DRY

* Fix case where calling dict on empty pipeline
  • Loading branch information
marrobi authored Aug 2, 2023
1 parent 6f20e79 commit 1c6ff35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ FEATURES:
ENHANCEMENTS:

BUG FIXES:
* Cusotm actions fail on resources with a pipline ([#3646](https://github.com/microsoft/AzureTRE/issues/3646))

## 0.12.0 (July 27, 2023)

Expand Down
2 changes: 1 addition & 1 deletion api_app/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.15.6"
__version__ = "0.15.7"
12 changes: 9 additions & 3 deletions api_app/service_bus/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,24 @@ async def update_resource_for_step(operation_step: OperationStep, resource_repo:

parent_template = await resource_template_repo.get_template_by_name_and_version(step_resource.templateName, step_resource.templateVersion, step_resource.resourceType, step_resource_parent_service_name)

# if there are no pipelines, no need to continue with substitutions.
# if there are no pipelines, or custom action, no need to continue with substitutions.
if not parent_template.pipeline:
return step_resource

pipeline_primary_action = parent_template.pipeline.dict()[primary_action]
parent_template_pipeline_dict = parent_template.pipeline.dict()

# if action not defined as a pipeline, custom action, no need to continue with substitutions.
if primary_action not in parent_template_pipeline_dict:
return step_resource

pipeline_primary_action = parent_template_pipeline_dict[primary_action]
is_first_main_step = pipeline_primary_action and len(pipeline_primary_action) == 1 and pipeline_primary_action[0]['stepId'] == 'main'
if not pipeline_primary_action or is_first_main_step:
return step_resource

# get the template step
template_step = None
for step in parent_template.pipeline.dict()[primary_action]:
for step in parent_template_pipeline_dict[primary_action]:
if step["stepId"] == operation_step.templateStepId:
template_step = parse_obj_as(PipelineStep, step)
break
Expand Down

0 comments on commit 1c6ff35

Please sign in to comment.