Skip to content

Commit

Permalink
[Blueprint] Support removing depends_on in update (Azure#2679)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengzhou-msft authored Nov 26, 2020
1 parent e293266 commit b0cdaee
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/blueprint/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

0.2.1
+++++
* Support removing depends_on relationships for artifacts in update command

0.2.0
+++++
* `az blueprint assignment create/update`: Support user assigned identity with `--user-assigned-identity`
Expand Down
8 changes: 4 additions & 4 deletions src/blueprint/azext_blueprint/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def load_arguments(self, _):
c.argument('artifact_name', help='A unique name of this resource group artifact.')
c.argument('display_name', help='Display name of this resource group artifact.')
c.argument('description', help='Description of the blueprint artifact.')
c.argument('depends_on', nargs='+', help='Artifacts which need to be deployed before the specified artifact.')
c.argument('depends_on', nargs='*', help="Artifacts which need to be deployed before the specified artifact. Use '--depends-on' with no values to remove dependencies.")
c.argument('tags', tags_type, arg_group='Resource Group', help='Tags to be assigned to this resource group.')

with self.argument_context('blueprint resource-group remove') as c:
Expand Down Expand Up @@ -142,7 +142,7 @@ def load_arguments(self, _):
c.argument('artifact_name', help='Name of the blueprint artifact.')
c.argument('display_name', help='DisplayName of this artifact.')
c.argument('description', help='Description of the blueprint artifact.')
c.argument('depends_on', nargs='+', help='Artifacts which need to be deployed before the specified artifact.')
c.argument('depends_on', nargs='*', help="Artifacts which need to be deployed before the specified artifact. Use '--depends-on' with no values to remove dependencies.")
c.argument('resource_group_art', help='Name of the resource group artifact to which the policy will be assigned.')
c.argument('parameters', arg_type=parameter_type, help='Parameters for policy assignment artifact. It can be a JSON string or JSON file path.')

Expand All @@ -161,7 +161,7 @@ def load_arguments(self, _):
c.argument('artifact_name', help='Name of the blueprint artifact.')
c.argument('display_name', help='DisplayName of this artifact.')
c.argument('description', help='Description of the blueprint artifact.')
c.argument('depends_on', nargs='+', help='Artifacts which need to be deployed before the specified artifact.')
c.argument('depends_on', nargs='*', help="Artifacts which need to be deployed before the specified artifact. Use '--depends-on' with no values to remove dependencies.")
c.argument('resource_group_art', help='Name of the resource group artifact to which the policy will be assigned.')

with self.argument_context('blueprint artifact template create') as c:
Expand All @@ -179,7 +179,7 @@ def load_arguments(self, _):
c.argument('artifact_name', help='Name of the blueprint artifact.')
c.argument('display_name', help='DisplayName of this artifact.')
c.argument('description', help='Description of the blueprint artifact.')
c.argument('depends_on', nargs='+', help='Artifacts which need to be deployed before the specified artifact.')
c.argument('depends_on', nargs='*', help="Artifacts which need to be deployed before the specified artifact. Use '--depends-on' with no values to remove dependencies.")
c.argument('resource_group_art', help='Name of the resource group artifact to which the policy will be assigned.')
c.argument('parameters', arg_type=parameter_type, help='Parameters for ARM template artifact. It can be a JSON string or JSON file path.')
c.argument('template', arg_type=template_type)
Expand Down
16 changes: 12 additions & 4 deletions src/blueprint/azext_blueprint/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def update_blueprint_resource_group(cmd,
if description is not None:
resource_group['description'] = description # str
if depends_on is not None:
resource_group['depends_on'] = depends_on
resource_group['depends_on'] = _process_depends_on_for_update(depends_on)
if tags is not None:
resource_group['tags'] = tags

Expand Down Expand Up @@ -298,7 +298,7 @@ def update_blueprint_artifact_policy(cmd,
if description is not None:
body['description'] = description
if depends_on is not None:
body['depends_on'] = depends_on
body['depends_on'] = _process_depends_on_for_update(depends_on)

return client.create_or_update(scope=scope,
blueprint_name=blueprint_name,
Expand Down Expand Up @@ -360,7 +360,7 @@ def update_blueprint_artifact_role(cmd,
if description is not None:
body['description'] = description
if depends_on is not None:
body['depends_on'] = depends_on
body['depends_on'] = _process_depends_on_for_update(depends_on)

return client.create_or_update(scope=scope,
blueprint_name=blueprint_name,
Expand Down Expand Up @@ -424,7 +424,7 @@ def update_blueprint_artifact_template(cmd,
if description is not None:
body['description'] = description
if depends_on is not None:
body['depends_on'] = depends_on
body['depends_on'] = _process_depends_on_for_update(depends_on)

return client.create_or_update(scope=scope,
blueprint_name=blueprint_name,
Expand Down Expand Up @@ -627,3 +627,11 @@ def wait_for_blueprint_assignment(cmd, client, assignment_name, management_group

def who_is_blueprint_blueprint_assignment(cmd, client, assignment_name, management_group=None, subscription=None, scope=None):
return client.who_is_blueprint(scope=scope, assignment_name=assignment_name)


def _process_depends_on_for_update(depends_on):
if not depends_on: # [] for case: --depends-on
return None
if not any(depends_on): # [''] for case: --depends-on= /--depends-on ""
return None
return depends_on
2 changes: 1 addition & 1 deletion src/blueprint/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# TODO: Confirm this is the right version number you want and it matches your
# HISTORY.rst entry.
VERSION = '0.2.0'
VERSION = '0.2.1'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down

0 comments on commit b0cdaee

Please sign in to comment.