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/copy: make sure we handle relative path names correctly #5050

Merged

Conversation

nalind
Copy link
Member

@nalind nalind commented Sep 15, 2023

What type of PR is this?

/kind bug

What this PR does / why we need it:

Make sure that add and copy handle relative paths given as input correctly, both with and without a context directory being specified.

How to verify it

New integration tests!

Which issue(s) this PR fixes:

Fixes #5049.

Special notes for your reviewer:

Does this PR introduce a user-facing change?

`buildah add` and `buildah copy` should correctly handle relative path names for sources when the `--context-directory` flag is used.

Make sure that `add` and `copy` handle relative paths given as input
correctly, both with and without a context directory being specified.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Sep 15, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 15, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nalind

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

if err != nil {
return fmt.Errorf("computing path of %q relative to %q: %w", glob, contextDir, err)
rel := glob
if filepath.IsAbs(glob) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this correct? We only append contextDir, if the glob is a Absolute path?

Copy link
Member Author

Choose a reason for hiding this comment

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

It isn't appended - we're conditionalizing whether or not we want to convert the matched value to a relative path. We don't need to do that when it's already a relative path.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, now I understand.

@rhatdan
Copy link
Member

rhatdan commented Sep 18, 2023

LGTM

1 similar comment
@TomSweeneyRedHat
Copy link
Member

LGTM

@TomSweeneyRedHat
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Sep 18, 2023
@openshift-merge-robot openshift-merge-robot merged commit 1fee8d4 into containers:main Sep 18, 2023
36 checks passed
@nalind nalind deleted the copy-context-dir-relative branch September 18, 2023 17:25
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved kind/bug Categorizes issue or PR as related to a bug. lgtm locked - please file new issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

buildah-copy unexpected behavior when using --context-dir and relative source path
4 participants