Skip to content

Commit 2a184be

Browse files
authored
[ARM] az deployment: Fix the issue where the Bicep installation message is printed in the command output (#32552)
1 parent 7fc76c6 commit 2a184be

File tree

1 file changed

+13
-14
lines changed
  • src/azure-cli/azure/cli/command_modules/resource

1 file changed

+13
-14
lines changed

src/azure-cli/azure/cli/command_modules/resource/_bicep.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ def run_bicep_command(cli_ctx, args, auto_install=True, custom_env=None):
115115

116116

117117
def ensure_bicep_installation(cli_ctx, release_tag=None, target_platform=None, stdout=True):
118+
def output(message):
119+
if stdout:
120+
print(message)
121+
else:
122+
_logger.info(message)
123+
118124
if _use_binary_from_path(cli_ctx) and release_tag is None:
119125
# Only use the Bicep executable from PATH when no specific version is requested.
120126
from shutil import which
@@ -134,25 +140,24 @@ def ensure_bicep_installation(cli_ctx, release_tag=None, target_platform=None, s
134140

135141
if os.path.isfile(installation_path):
136142
if not release_tag:
137-
print(f"Bicep CLI is already installed at '{installation_path}'. Skipping installation as no specific version was requested.") # pylint: disable=line-too-long
143+
output(f"Bicep CLI is already installed at '{installation_path}'. Skipping installation as no specific version was requested.") # pylint: disable=line-too-long
138144
return
139145

140146
installed_version = _get_bicep_installed_version(installation_path)
141147
target_version = _extract_version(release_tag)
142148
if installed_version and target_version and installed_version == target_version:
143-
print(f"Bicep CLI {installed_version} is already installed at '{installation_path}'.")
149+
output(f"Bicep CLI {installed_version} is already installed at '{installation_path}'.")
144150
return
145151

146152
installation_dir = os.path.dirname(installation_path)
147153
os.makedirs(installation_dir, exist_ok=True)
148154

149155
try:
150156
release_tag = release_tag if release_tag else get_bicep_latest_release_tag()
151-
if stdout:
152-
if release_tag:
153-
print(f"Installing Bicep CLI {release_tag}...")
154-
else:
155-
print("Installing Bicep CLI...")
157+
if release_tag:
158+
output(f"Installing Bicep CLI {release_tag}...")
159+
else:
160+
output("Installing Bicep CLI...")
156161
os.environ.setdefault("CURL_CA_BUNDLE", certifi.where())
157162

158163
download_url = _get_bicep_download_url(system, machine, release_tag, target_platform=target_platform)
@@ -172,13 +177,7 @@ def ensure_bicep_installation(cli_ctx, release_tag=None, target_platform=None, s
172177
_logger.warning("The configuration value of bicep.use_binary_from_path has been set to 'false'.")
173178
set_use_binary_from_path_config(cli_ctx, "false")
174179

175-
if stdout:
176-
print(f'Successfully installed Bicep CLI to "{installation_path}".')
177-
else:
178-
_logger.info(
179-
"Successfully installed Bicep CLI to %s",
180-
installation_path,
181-
)
180+
output(f'Successfully installed Bicep CLI to "{installation_path}".')
182181
except OSError as err:
183182
raise ClientRequestError(f"Error while attempting to download Bicep CLI: {err}")
184183

0 commit comments

Comments
 (0)