Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions doc/extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ What is an Extension?
- Currently, we support one extension type, a [Python Wheel](http://pythonwheels.com/).
- All extension documentation here refers to this type of extension.

> Extensions should be built with wheel `0.29.0` or `0.30.0` until [#6441](https://github.com/Azure/azure-cli/issues/6441) is resolved


What an Extension is not
------------------------
Expand Down
3 changes: 3 additions & 0 deletions src/azure-cli/azure/cli/command_modules/resource/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,9 @@ def load_arguments(self, _):
with self.argument_context('group export') as c:
c.argument('include_comments', action='store_true')
c.argument('include_parameter_default_value', action='store_true')
c.argument('skip_resource_name_params', action='store_true')
c.argument('skip_all_params', action='store_true')
c.argument('resource_ids', nargs='+', options_list='--resource-ids')

with self.argument_context('group create') as c:
c.argument('rg_name', options_list=['--name', '--resource-group', '-n', '-g'],
Expand Down
25 changes: 21 additions & 4 deletions src/azure-cli/azure/cli/command_modules/resource/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,11 +1032,14 @@ def update_resource_group(instance, tags=None):


def export_group_as_template(
cmd, resource_group_name, include_comments=False, include_parameter_default_value=False):
cmd, resource_group_name, include_comments=False, include_parameter_default_value=False, resource_ids=None, skip_resource_name_params=False, skip_all_params=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we register all new arguments in _params.py? Especially for --resource-ids, which should be an array, right?

Copy link
Contributor Author

@jorgecotillo jorgecotillo May 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, had to add nargs to the param.

"""Captures a resource group as a template.
:param str resource_group_name:the name of the resoruce group.
:param bool include_comments:export template with comments.
:param str resource_group_name: the name of the resource group.
:param resource_ids: space-separated resource ids to filter the export by. To export all resources, do not specify this argument or supply "*".
:param bool include_comments: export template with comments.
:param bool include_parameter_default_value: export template parameter with default value.
:param bool skip_resource_name_params: export template and skip resource name parameterization.
:param bool skip_all_params: export template parameter and skip all parameterization.
Comment on lines +1041 to +1042
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these parameters, I will recommend you to add them as storage_true and give short name for them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

"""
rcf = _resource_client_factory(cmd.cli_ctx)

Expand All @@ -1045,10 +1048,24 @@ def export_group_as_template(
export_options.append('IncludeComments')
if include_parameter_default_value:
export_options.append('IncludeParameterDefaultValue')
if skip_resource_name_params:
export_options.append('SkipResourceNameParameterization')
if skip_all_params:
export_options.append('SkipAllParameterization')

resources = []
if resource_ids is None or resource_ids[0] == "*":
resources = ["*"]
else:
for i in resource_ids:
if is_valid_resource_id(i):
resources.append(i)
else:
raise CLIError('az resource: error: argument --resource-ids: invalid ResourceId value: \'%s\'' % i)

options = ','.join(export_options) if export_options else None

result = rcf.resource_groups.export_template(resource_group_name, ['*'], options=options)
result = rcf.resource_groups.export_template(resource_group_name, resources, options=options)

# pylint: disable=no-member
# On error, server still returns 200, with details in the error attribute
Expand Down
Loading