Add --chdir flag
- Dominant language
- Go
- Stars
- 15.8k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
#### Community Note
* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment
Please search the existing issues for relevant feature requests, and use the
reaction feature
(https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
to add upvotes to pre-existing requests.
#### Description
Hello! When using packer on my repo it would be very useful to be able to "chdir" o a folder when execution `packer build`.
The idea is the same on Terraform: https://developer.hashicorp.com/terraform/cli/commands#switching-working-directory-with-chdir
#### Use Case(s)
My repo structure is as follows:
```
repo/
Makefile
packer/
variables/
variables.pkrvars.hcl
frontend/
packer.pkr.hcl
backend/
packer.pkr.hcl
terraform/
terraform stuff
```
I would like to be able to execute packer from the root of my repo, from a Makefile, to make it very easy to build my images.
#### Potential configuration
An example of execution would be, using my repo structure above:
```
packer init -chdir packer/frontend/packer.pkr.hcl
packer build -chdir packer/frontend/packer.pkr.hcl -var-file packer/variables/variables.pkrvars.hcl
```
Contributor guide
Research direction
Start by tracing the CLI handling for the init and build commands, then compare the requested behavior with Terraform's chdir option. Done means packer can accept -chdir for these commands and run from the repository root while resolving the example configuration and variable paths correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100