Skip to content

feat(builtins): add packer fmt formatter - #1708

Merged
jdx merged 3 commits into
jdx:mainfrom
illesnagy1:feat/packer-fmt-builtin
Oct 15, 2026
Merged

jdx merged 3 commits into
jdx:mainfrom
illesnagy1:feat/packer-fmt-builtin

Conversation

@illesnagy1

@illesnagy1 illesnagy1 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Add a packer_fmt builtin that formats Packer HCL2 templates (*.pkr.hcl) and variable files (*.pkrvars.hcl) with packer fmt. check runs packer fmt -check, check_diff builds a patch from packer fmt - via hk util format-diff, and fix rewrites files in place.

hk init suggests the builtin when the project contains *.pkr.hcl files.

Summary by CodeRabbit

  • Tests
    • Added coverage for hk init with a Packer template nested under images/, verifying successful initialization, the packer_fmt report, and its entry in hk.pkl.

Add a `packer_fmt` builtin that formats Packer HCL2 templates
(`*.pkr.hcl`) and variable files (`*.pkrvars.hcl`) with `packer fmt`.
`check` runs `packer fmt -check`, `check_diff` builds a patch from
`packer fmt -` via `hk util format-diff`, and `fix` rewrites files in
place.

`hk init` suggests the builtin when the project contains `*.pkr.hcl`
files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters: 1
  • pkl/builtins/packer_fmt.pkl is excluded by !**/*.pkl

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration
  • Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 78ebed68-e4f2-4dc8-b299-a9ea6791a52e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f767a209-0eae-4103-ac32-6265ea4b8dc0
📥 Commits

Reviewing files that changed from the base of the PR and between bf059ce and 2172494.

⛔ Files ignored due to path filters: 2
  • mise.lock is excluded by !**/*.lock
  • pkl/builtins/packer_fmt.pkl is excluded by !**/*.pkl
📒 Files selected for processing: 2
  • test/builtin_tool_stubs/packer
  • test/init_creates_hk_pkl.bats

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Walkthrough

The test setup now includes Packer version 1.16.1. A new hk init test checks detection of a nested Packer template and confirms that hk.pkl includes Builtins.packer_fmt.

Changes: Packer initialization detection

Layer / File(s) Summary
Packer detection test
test/builtin_tool_stubs/packer, test/init_creates_hk_pkl.bats
Adds a Packer tool stub at version 1.16.1. Tests that hk init detects a nested Packer template and writes Builtins.packer_fmt to hk.pkl.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Feature

Suggested reviewers: jdx

Merge Risk: ⚪ Minimal · up to 21724

This change adds test coverage for Packer initialization detection and a pinned test stub without establishing a production behavior regression. No concrete merge-blocking risk is identified.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies the main change: adding the Packer formatter builtin.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with the previous test-coverage finding addressed.

Summary

Adds packer_fmt for Packer templates and variable files.

  • Packer files can now be checked and formatted with hk.
  • hk init suggests Packer formatting when it finds a template.

No new actionable issues were found in the changes since the previous review.

Reviews (2) · Last reviewed commit: "test(builtins): cover multiple files in ..." · Reviewed by Greptile

Comment thread pkl/builtins/packer_fmt.pkl Outdated
@jdx
jdx merged commit ec01fc6 into jdx:main Oct 15, 2026
25 checks passed
@jdx jdx mentioned this pull request Oct 15, 2026
@illesnagy1
illesnagy1 deleted the feat/packer-fmt-builtin branch October 15, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants