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

feat: copy from host to container #2782

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

stevenh
Copy link
Collaborator

@stevenh stevenh commented Sep 16, 2024

Add CopyHostPathTo to container methods, which is capable of copying files and directories from the host to a container. It identifies the correct copy semantics based on inspecting the source and target, replicating the behaviour of docker cp and other OS copy tools.

This deprecates CopyDirToContainer and CopyFileToContainer while still correcting their behaviour to also match docker cp behaviour.

Replace nonamedreturns linter with nakedret, as nonamedreturns prevents naming returned parameters which has a number of valid uses including: disambiguating return values and error checking.

Copying files to the container now doesn't compression as this is slower and consumes more resources for the typical local transfer case.

Fix docker copy tests to they validate the correct behaviour by ensuring that done is reported to the container log.

Clean up some error wrapping.

Fixes #2780

Copy link

netlify bot commented Sep 16, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 85930b2
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/66eca506f642c20009ddcf08
😎 Deploy Preview https://deploy-preview-2782--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@stevenh stevenh force-pushed the feat/copy-host-path-to branch 6 times, most recently from 3f6c23d to edb9d04 Compare September 17, 2024 03:41
Add CopyHostPathTo to container methods, which is capable of copying files
and directories from the host to a container. It identifies the correct
copy semantics based on inspecting the source and target, replicating
the behaviour of docker cp and other OS copy tools.

This deprecates CopyDirToContainer and CopyFileToContainer while still
correcting their behaviour to also match docker cp behaviour.

Replace nonamedreturns linter with nakedret, as nonamedreturns prevents
naming returned parameters which has a number of valid uses including:
disambiguating return values and error checking.

Copying files to the container now doesn't compression as this is
slower and consumes more resources for the typical local transfer case.

Fix docker copy tests to they validate the correct behaviour by ensuring
that done is reported to the container log.

Clean up some error wrapping.

Fix testdata wait scripts.

Fix invalid FileMode values, so tests don't fail with the new FileMode
validation.

Switch to exists check for copy instead of running it as a shell.

Disable linter check for deprecated methods as we use them internally
and test them.

Fixes #2780
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.

[Bug]: CopyDirToContainer doesn't behave as expected
2 participants