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

Add podman machine cp subcommand #25331

Merged
merged 1 commit into from
Feb 28, 2025

Conversation

jakecorrenti
Copy link
Member

Does this PR introduce a user-facing change?

Adds a new podman machine cp subcommand. This will allow users to copy files or directories between a running Podman Machine and their host.

Add a new `podman machine cp` subcommand

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

Note we generally squash all commits into one for a new feature, i.e. code, docs, test should be in one commit. Of course if there are doing different features/bugs then not but in this case it is only one.

@jakecorrenti jakecorrenti force-pushed the machine-cp branch 2 times, most recently from 914a438 to 55cf202 Compare February 17, 2025 23:24
@jakecorrenti jakecorrenti force-pushed the machine-cp branch 3 times, most recently from eaf21be to 0ed0ba3 Compare February 18, 2025 18:50
@baude
Copy link
Member

baude commented Feb 19, 2025

one question i guess else LGTM

@jakecorrenti jakecorrenti force-pushed the machine-cp branch 3 times, most recently from 602102f to b7b6dc7 Compare February 19, 2025 19:50
}

// Passing an absolute windows path of the format <volume>:\<path> will cause
// `copy.ParseSourceAndDestination` to think the volume is a Machine. Check
Copy link
Member

Choose a reason for hiding this comment

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

just thinking about it does podman cp not have the exact same issue, i.e. should this fix be moved into ParseSourceAndDestination()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Wouldn't that result in the same issue mentioned below having to do with single name containers?

Comment on lines 70 to 78
if specgen.IsHostWinPath(args[0]) {
srcMachine = ""
srcPath = args[0]
}

if specgen.IsHostWinPath(args[1]) {
destMachine = ""
destPath = args[1]
}
Copy link
Member

Choose a reason for hiding this comment

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

Also isn't this breaking for machine names with one letter? i.e. I think it runs into the same issue as shown in #25323

We do allow a machine called C so that can be a problem although super unlikely that anyone would be using single letter machine names hopefully so I am fine to ignore that part for now. Though adding this issue in a comment here might help future readers.

@jakecorrenti jakecorrenti force-pushed the machine-cp branch 2 times, most recently from f99e5fe to a69cc67 Compare February 24, 2025 20:00
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

openshift-ci bot commented Feb 25, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jakecorrenti, Luap99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 25, 2025
directory = "foo-dir"
directoryPath = filepath.Join(GinkgoT().TempDir(), directory)

fileInDirectory = "bar.txt"
Copy link
Member

Choose a reason for hiding this comment

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

For some reason tests are failing during cleanup for me on Windows because this file cannot be removed. The error message is "The process cannot access the file because it is being used by another process.". This can be specific to my machine though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm relying on the CI for my windows machine, but I'll keep an eye on it.

@jakecorrenti jakecorrenti force-pushed the machine-cp branch 2 times, most recently from b775a29 to 9e12f5c Compare February 28, 2025 14:56
Add a new `podman machine cp` subcommand to allow users to copy files or
directories between a running Podman Machine and their host.

Tests cover the following cases:
- Copy a file from the host machine to the VM
- Copy a directory from the host machine to the VM
- Copy a file from the VM to the host machine
- Copy a directory from the VM to the host machine
- Copy a file to a directory
- Copy a directory to a file

Signed-off-by: Jake Correnti <[email protected]>
@mheon
Copy link
Member

mheon commented Feb 28, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 28, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit d91d424 into containers:main Feb 28, 2025
89 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. machine release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants