Add option to create parent folders when copying files or folders to Windows containers#230
Add option to create parent folders when copying files or folders to Windows containers#230wbpascal wants to merge 3 commits into
Conversation
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes Have you signed the CLA already but the status is still pending? Recheck it. |
2c50c65 to
5c30b7f
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Docker builder configuration option, windows_create_parent_dirs, to optionally create missing destination parent directories when uploading files/directories into Windows containers, aligning behavior more closely with Linux container uploads.
Changes:
- Added
windows_create_parent_dirsto the Docker builder config/schema with docs and changelog updates. - Implemented parent-directory creation in the Windows container communicator prior to
Copy-Itemoperations. - Added config validation warning behavior and unit tests covering defaulting and warnings.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/builders/docker.mdx | Documents the new option and shows it in Windows container examples. |
| docs-partials/builder/docker/Config-not-required.mdx | Adds the option to the generated config reference list. |
| CHANGELOG.md | Notes the new feature under “Unreleased”. |
| builder/docker/windows_container_communicator.go | Adds parent-dir creation logic for Windows uploads (and related helpers). |
| builder/docker/config.hcl2spec.go | Extends HCL2 spec to include windows_create_parent_dirs. |
| builder/docker/config.go | Adds config field and emits a warning if set without windows_container. |
| builder/docker/config_test.go | Adds tests for default value and warning behavior. |
Files not reviewed (1)
- builder/docker/config.hcl2spec.go: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| containerDst := dst | ||
| if src[len(src)-1] != '/' { | ||
| containerDst = filepath.Join(dst, filepath.Base(src)) | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Description
This PR adds a boolean option
windows_create_parent_dirsto the plugin config with a default value offalse(for backwards compatibility). When this value istrue, the parent folders of the destination are created within the Windows container during copying of files or folders into a Windows container. This makes the behavior closer to the way it works for Linux containers currently and also helps when reusing Packer files between VMs (e.g., utilizing the vSphere plugin) and containers (using this plugin).For more context, please also see #208.
Resolved Issues
Closes #208
Rollback Plan
If a change needs to be reverted, we will roll out an update to the code within 7 days.
Changes to Security Controls
There are no changes to security controls in this PR.