Skip to content

Commit b0cdaee

Browse files
[Blueprint] Support removing depends_on in update (Azure#2679)
1 parent e293266 commit b0cdaee

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

src/blueprint/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Release History
44
===============
55

6+
0.2.1
7+
+++++
8+
* Support removing depends_on relationships for artifacts in update command
9+
610
0.2.0
711
+++++
812
* `az blueprint assignment create/update`: Support user assigned identity with `--user-assigned-identity`

src/blueprint/azext_blueprint/_params.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def load_arguments(self, _):
113113
c.argument('artifact_name', help='A unique name of this resource group artifact.')
114114
c.argument('display_name', help='Display name of this resource group artifact.')
115115
c.argument('description', help='Description of the blueprint artifact.')
116-
c.argument('depends_on', nargs='+', help='Artifacts which need to be deployed before the specified artifact.')
116+
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.")
117117
c.argument('tags', tags_type, arg_group='Resource Group', help='Tags to be assigned to this resource group.')
118118

119119
with self.argument_context('blueprint resource-group remove') as c:
@@ -142,7 +142,7 @@ def load_arguments(self, _):
142142
c.argument('artifact_name', help='Name of the blueprint artifact.')
143143
c.argument('display_name', help='DisplayName of this artifact.')
144144
c.argument('description', help='Description of the blueprint artifact.')
145-
c.argument('depends_on', nargs='+', help='Artifacts which need to be deployed before the specified artifact.')
145+
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.")
146146
c.argument('resource_group_art', help='Name of the resource group artifact to which the policy will be assigned.')
147147
c.argument('parameters', arg_type=parameter_type, help='Parameters for policy assignment artifact. It can be a JSON string or JSON file path.')
148148

@@ -161,7 +161,7 @@ def load_arguments(self, _):
161161
c.argument('artifact_name', help='Name of the blueprint artifact.')
162162
c.argument('display_name', help='DisplayName of this artifact.')
163163
c.argument('description', help='Description of the blueprint artifact.')
164-
c.argument('depends_on', nargs='+', help='Artifacts which need to be deployed before the specified artifact.')
164+
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.")
165165
c.argument('resource_group_art', help='Name of the resource group artifact to which the policy will be assigned.')
166166

167167
with self.argument_context('blueprint artifact template create') as c:
@@ -179,7 +179,7 @@ def load_arguments(self, _):
179179
c.argument('artifact_name', help='Name of the blueprint artifact.')
180180
c.argument('display_name', help='DisplayName of this artifact.')
181181
c.argument('description', help='Description of the blueprint artifact.')
182-
c.argument('depends_on', nargs='+', help='Artifacts which need to be deployed before the specified artifact.')
182+
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.")
183183
c.argument('resource_group_art', help='Name of the resource group artifact to which the policy will be assigned.')
184184
c.argument('parameters', arg_type=parameter_type, help='Parameters for ARM template artifact. It can be a JSON string or JSON file path.')
185185
c.argument('template', arg_type=template_type)

src/blueprint/azext_blueprint/custom.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def update_blueprint_resource_group(cmd,
210210
if description is not None:
211211
resource_group['description'] = description # str
212212
if depends_on is not None:
213-
resource_group['depends_on'] = depends_on
213+
resource_group['depends_on'] = _process_depends_on_for_update(depends_on)
214214
if tags is not None:
215215
resource_group['tags'] = tags
216216

@@ -298,7 +298,7 @@ def update_blueprint_artifact_policy(cmd,
298298
if description is not None:
299299
body['description'] = description
300300
if depends_on is not None:
301-
body['depends_on'] = depends_on
301+
body['depends_on'] = _process_depends_on_for_update(depends_on)
302302

303303
return client.create_or_update(scope=scope,
304304
blueprint_name=blueprint_name,
@@ -360,7 +360,7 @@ def update_blueprint_artifact_role(cmd,
360360
if description is not None:
361361
body['description'] = description
362362
if depends_on is not None:
363-
body['depends_on'] = depends_on
363+
body['depends_on'] = _process_depends_on_for_update(depends_on)
364364

365365
return client.create_or_update(scope=scope,
366366
blueprint_name=blueprint_name,
@@ -424,7 +424,7 @@ def update_blueprint_artifact_template(cmd,
424424
if description is not None:
425425
body['description'] = description
426426
if depends_on is not None:
427-
body['depends_on'] = depends_on
427+
body['depends_on'] = _process_depends_on_for_update(depends_on)
428428

429429
return client.create_or_update(scope=scope,
430430
blueprint_name=blueprint_name,
@@ -627,3 +627,11 @@ def wait_for_blueprint_assignment(cmd, client, assignment_name, management_group
627627

628628
def who_is_blueprint_blueprint_assignment(cmd, client, assignment_name, management_group=None, subscription=None, scope=None):
629629
return client.who_is_blueprint(scope=scope, assignment_name=assignment_name)
630+
631+
632+
def _process_depends_on_for_update(depends_on):
633+
if not depends_on: # [] for case: --depends-on
634+
return None
635+
if not any(depends_on): # [''] for case: --depends-on= /--depends-on ""
636+
return None
637+
return depends_on

src/blueprint/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

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

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

0 commit comments

Comments
 (0)