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

fix: Run popd to return to original working folder #53

Closed
wants to merge 2 commits into from

Conversation

stanleyz
Copy link

fix: pushd issue on multiple directories for packer build files

When there are multiple folders containing individual Packer build files, with pushd only, the packer_validate.sh hook can't switch to the next folder for validation, popd at the end of each loop changes the working directory to original directory so that the pushd can work against multiple packer build directories

🗣 Description

This change adds a popd to switch to previous working directory on each loop in the packer_validate hook

💭 Motivation and context

Without this change, the packer_validate will run into the below errors

/Users/xxx/.cache/pre-commit/repox6kqm38u/hooks/packer_validate.sh: line 27: pushd: packer/windows: No such file or directory

on folder structure like below

packer/
├── linux
│   ├── linux.pkr.hcl
│   ├── plugins.pkr.hcl
│   └── variables.pkr.hcl
└── windows
    ├── plugins.pkr.hcl
    ├── variables.pkr.hcl
    └── windows.pkr.hcl

🧪 Testing

Tested locally, working fine

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • Changes are limited to a single goal - eschew scope creep!
  • All future TODOs are captured in issues, which are referenced
    in code comments.
  • 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.
  • Tests have been added and/or modified to cover the changes in this PR.
  • All new and existing tests pass.

✅ Pre-merge checklist

  • Revert dependencies to default branches.
  • Finalize version.

✅ Post-merge checklist

  • Create a release.

When there are multiple folders containing individual Packer build
files, with pushd only, the packer_validate.sh hook can't switch to the
next folder for validation, popd at the end of each loop changes the
working directory to original directory so that the pushd can work
against multiple packer build directories
@mcdonnnj mcdonnnj mentioned this pull request Dec 17, 2024
6 tasks
@mcdonnnj
Copy link
Member

I am closing this because as of #54 I believe this is a non-issue. If you believe this is in error please let me know and I can reopen the pull request.

@mcdonnnj mcdonnnj closed this Dec 17, 2024
@stanleyz stanleyz deleted the feat/pushd-issue branch December 17, 2024 22:00
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