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

Change packer_fmt to write to files by default #48

Merged
merged 3 commits into from
Oct 18, 2024

Conversation

mcdonnnj
Copy link
Member

@mcdonnnj mcdonnnj commented Oct 18, 2024

🗣 Description

This pull request changes the packer_fmt hook to use the default behavior of the packer fmt command instead of providing arguments. This results in the hook writing changes to files instead of failing and outputting paths that failed to pass a format check.

💭 Motivation and context

This mirrors the behavior of the terraform_fmt hook we use from antonbabenko/pre-commit-terraform and in retrospect makes the most sense for the hook's behavior.

🧪 Testing

Automated tests pass. I confirmed the expected functionality with the pre-release.

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • Changes are limited to a single goal - eschew scope creep!
  • All relevant type-of-change labels have been added.
  • I have read the CONTRIBUTING document.
  • These code changes follow cisagov code standards.
  • All relevant repo and/or project documentation has been updated
    to reflect the changes in this PR.
  • All new and existing tests pass.

✅ Pre-merge checklist

  • Finalize version.

✅ Post-merge checklist

  • Create a release.

Instead of providing default arguments to the `packer_fmt` hook we
instead use the default behavior of the `packer fmt` command. This
will result in files being written to if formatting is needed instead
of just warning that a file is improperly formatted. An important note
is that `packer fmt` returns 0 even if changing a file with the default
arguments. The existing exit code check is left in place in case the
arguments for the hook are changed.
@mcdonnnj mcdonnnj added breaking change This issue or pull request involves changes to existing functionality improvement This issue or pull request will add or improve functionality, maintainability, or ease of use labels Oct 18, 2024
@mcdonnnj mcdonnnj self-assigned this Oct 18, 2024
@mcdonnnj mcdonnnj requested a review from a team October 18, 2024 18:27
Copy link
Member

@dav3r dav3r left a comment

Choose a reason for hiding this comment

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

👍

@mcdonnnj mcdonnnj merged commit 7361323 into develop Oct 18, 2024
4 checks passed
@mcdonnnj mcdonnnj deleted the improvement/format_files_instead_of_checking branch October 18, 2024 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This issue or pull request involves changes to existing functionality improvement This issue or pull request will add or improve functionality, maintainability, or ease of use
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants