Skip to content

Add option to create parent folders when copying files or folders to Windows containers#230

Open
wbpascal wants to merge 3 commits into
hashicorp:mainfrom
wbpascal:FB/CreateParentFolderForWindows
Open

Add option to create parent folders when copying files or folders to Windows containers#230
wbpascal wants to merge 3 commits into
hashicorp:mainfrom
wbpascal:FB/CreateParentFolderForWindows

Conversation

@wbpascal

@wbpascal wbpascal commented May 4, 2026

Copy link
Copy Markdown

Description

This PR adds a boolean option windows_create_parent_dirs to the plugin config with a default value of false (for backwards compatibility). When this value is true, 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.

@wbpascal wbpascal requested a review from a team as a code owner May 4, 2026 06:53
@hashicorp-cla-app

hashicorp-cla-app Bot commented May 4, 2026

Copy link
Copy Markdown

CLA assistant check

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_dirs to the Docker builder config/schema with docs and changelog updates.
  • Implemented parent-directory creation in the Windows container communicator prior to Copy-Item operations.
  • 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.

Comment thread builder/docker/windows_container_communicator.go
Comment thread builder/docker/windows_container_communicator.go
Comment thread builder/docker/windows_container_communicator.go
Comment on lines 169 to 172
containerDst := dst
if src[len(src)-1] != '/' {
containerDst = filepath.Join(dst, filepath.Base(src))
}
wbpascal and others added 2 commits June 9, 2026 09:31
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

Automatically create parent folders for files in Windows containers-

2 participants