Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bicep build produces arm templates with LF line endings on Windows #14383

Closed
josoklas opened this issue Jun 21, 2024 · 3 comments
Closed

bicep build produces arm templates with LF line endings on Windows #14383

josoklas opened this issue Jun 21, 2024 · 3 comments
Assignees
Labels
Needs: Upvote This issue requires more votes to be considered
Milestone

Comments

@josoklas
Copy link

Bicep version
This reproduces starting with bicep CLI version 0.25.3. The previous version 0.24.24 outputs CRLF endings.

Describe the bug
On Windows, starting with bicep 0.25.3 the arm templates output by "bicep build" have LF line endings. Previously the behavior was to use CRLF on Windows. Ideally this would be configurable.

To Reproduce
Create a file test.bicep with the following content:

targetScope = 'subscription'

resource ResourceGroup 'Microsoft.Resources/resourceGroups@2018-05-01' = {
  name: 'testrg'
  location: 'eastus'
}

Run bicep build test.bicep with both versions 0.24.24 and 0.25.3.

The test.json produced by 0.24.24 will have CRLF line endings.
The test.json produced by 0.25.3 will have LF line endings.

Additional context

@stephaniezyen
Copy link
Contributor

How does this issue impact your workflow? This seems to be an unintentional change on our end

@stephaniezyen stephaniezyen added Needs: Author Feedback Awaiting feedback from the author of the issue Needs: Upvote This issue requires more votes to be considered and removed Needs: Triage 🔍 labels Jun 26, 2024
@stephaniezyen stephaniezyen added this to the v0.29 milestone Jun 26, 2024
@josoklas
Copy link
Author

Thanks for taking a look!

This impacts our workflow because we check in ARM templates into our git repo and perform a bicep build as part of CI. We then check if there are any changes to the bicep output by utilizing "git status". So, not having control over the line endings results in errant diffs.

It also is a bit weird if we try to normalize the line endings in our repo because these are explicitly generated with LF.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Triage 🔍 and removed Needs: Author Feedback Awaiting feedback from the author of the issue labels Jun 26, 2024
@shenglol shenglol modified the milestones: v0.29, v0.30 Jul 10, 2024
@shenglol
Copy link
Contributor

@josoklas This was actually a by design change we made to make sure we produce consistent line endings across all platforms.

Since this is a one-time change, it shouldn't affect your workflow in the future. We'll add tests to ensure Bicep produces consistent line endings going forward.

shenglol added a commit that referenced this issue Jul 17, 2024
Currently, Bicep generates inconsistent newlines depending on whether
the template is built using the Build command (and with or without the
`--stdout` flag) or through the VS Code extension.

This PR updates the emission code to consistently use `\n` for newlines.
This change should prevent issues like
#14383 in the future.
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/14581)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Upvote This issue requires more votes to be considered
Projects
Status: Done
Development

No branches or pull requests

3 participants