Skip to content

Commit 7ef8f9e

Browse files
[ARM] Fix #26216: az bicep format: Fix the TypeError expected str, bytes or os.PathLike object, not bool (#26249)
1 parent 3e7a96f commit 7ef8f9e

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def load_arguments(self, _):
106106
bicep_indentkind_type = CLIArgumentType(options_list=['--indent-kind'], help="Set indentation kind. Valid values are ( Space | Tab ).")
107107
bicep_indentsize_type = CLIArgumentType(options_list=['--indent-size'], help="Number of spaces to indent with (Only valid with --indent-kind set to Space).")
108108
bicep_insertfinalnewline_type = CLIArgumentType(options_list=['--insert-final-newline'], action='store_true', help="Insert a final newline.")
109-
bicep_newline_type = CLIArgumentType(options_list=['--newline'], action='store_true', help="Set newline char. Valid values are ( Auto | LF | CRLF | CR ).")
109+
bicep_newline_type = CLIArgumentType(options_list=['--newline'], help="Set newline char. Valid values are ( Auto | LF | CRLF | CR ).")
110110
bicep_target_platform_type = CLIArgumentType(options_list=['--target-platform', '-t'],
111111
arg_type=get_enum_type(
112112
["win-x64", "linux-musl-x64", "linux-x64", "osx-x64", "linux-arm64", "osx-arm64"]),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3764,7 +3764,7 @@ def format_bicep_file(cmd, file, stdout=None, outdir=None, outfile=None, newline
37643764
if indent_size:
37653765
args += ["--indentSize", indent_size]
37663766
if insert_final_newline:
3767-
args += ["--insertFinalNewline", insert_final_newline]
3767+
args += ["--insertFinalNewline"]
37683768

37693769
output = run_bicep_command(cmd.cli_ctx, args)
37703770

src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4102,6 +4102,22 @@ def test_restore(self):
41024102
os.remove(out_path)
41034103

41044104

4105+
class BicepFormatTest(LiveScenarioTest):
4106+
def test_format(self):
4107+
curr_dir = os.path.dirname(os.path.realpath(__file__))
4108+
bf = os.path.join(curr_dir, 'storage_account_deploy.bicep').replace('\\', '\\\\')
4109+
out_file = os.path.join(curr_dir, 'storage_account_deploy.formatted.bicep').replace('\\', '\\\\')
4110+
self.kwargs.update({
4111+
'bf': bf,
4112+
'out_file': out_file,
4113+
})
4114+
4115+
self.cmd('az bicep format --file {bf} --outfile {out_file} --newline lf --indent-kind space --indent-size 2 --insert-final-newline')
4116+
4117+
if os.path.exists(out_file):
4118+
os.remove(out_file)
4119+
4120+
41054121
class DeploymentWithBicepScenarioTest(LiveScenarioTest):
41064122
def setup(self):
41074123
super.setup()

0 commit comments

Comments
 (0)