Skip to content

Commit

Permalink
[ARM] az bicep uninstall: Add new command to uninstall bicep (#18744)
Browse files Browse the repository at this point in the history
* Add az bicep uninstall and fix --stdout

* Add help for bicep uninstall
  • Loading branch information
shenglol authored Jul 7, 2021
1 parent 2ff1ad1 commit a481115
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/azure-cli/azure/cli/command_modules/resource/_bicep.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ def ensure_bicep_installation(release_tag=None, stdout=True):
raise ClientRequestError(f"Error while attempting to download Bicep CLI: {err}")


def remove_bicep_installation():
system = platform.system()
installation_path = _get_bicep_installation_path(system)

if os.path.exists(installation_path):
os.remove(installation_path)
if os.path.exists(_bicep_version_check_file_path):
os.remove(_bicep_version_check_file_path)


def is_bicep_file(file_path):
return file_path.lower().endswith(".bicep")

Expand Down
5 changes: 5 additions & 0 deletions src/azure-cli/azure/cli/command_modules/resource/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2457,6 +2457,11 @@
text: az bicep install --version v0.2.212
"""

helps['bicep uninstall'] = """
type: command
short-summary: Uninstall Bicep CLI.
"""

helps['bicep upgrade'] = """
type: command
short-summary: Upgrade Bicep CLI to the latest version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ def load_command_table(self, _):

with self.command_group('bicep') as g:
g.custom_command('install', 'install_bicep_cli')
g.custom_command('uninstall', 'uninstall_bicep_cli')
g.custom_command('upgrade', 'upgrade_bicep_cli')
g.custom_command('build', 'build_bicep_file')
g.custom_command('decompile', 'decompile_bicep_file')
Expand Down
7 changes: 7 additions & 0 deletions src/azure-cli/azure/cli/command_modules/resource/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
run_bicep_command,
is_bicep_file,
ensure_bicep_installation,
remove_bicep_installation,
get_bicep_latest_release_tag,
get_bicep_available_release_tags,
validate_bicep_target_scope
Expand Down Expand Up @@ -3413,6 +3414,10 @@ def install_bicep_cli(cmd, version=None):
ensure_bicep_installation(release_tag=version)


def uninstall_bicep_cli(cmd):
remove_bicep_installation()


def upgrade_bicep_cli(cmd):
latest_release_tag = get_bicep_latest_release_tag()
ensure_bicep_installation(release_tag=latest_release_tag)
Expand All @@ -3426,6 +3431,8 @@ def build_bicep_file(cmd, file, stdout=None, outdir=None, outfile=None):
args += ["--outfile", outfile]
if stdout:
args += ["--stdout"]
print(run_bicep_command(args))
return
run_bicep_command(args)


Expand Down

0 comments on commit a481115

Please sign in to comment.