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

podman build --remote URI Dockerfile should not be treated as file #20476

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Oct 25, 2023

Podman build --remote is translating https://path as if it was a file path. This change will leave it as a URL so it can be parsed on the server side.

Fixed: #20475

Does this PR introduce a user-facing change?

Fix handling of https paths in podman --remote build

@openshift-ci openshift-ci bot added release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 25, 2023
@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Oct 25, 2023
@edsantiago edsantiago changed the title podman build --remote URI Dockerfile shoud not be treated as file podman build --remote URI Dockerfile should not be treated as file Oct 25, 2023
for _, containerfile := range m {
containerFiles = append(containerFiles, filepath.Join(contextDirectory, filepath.Clean(filepath.FromSlash(containerfile))))
if containerfile[0] == byte('/') {
Copy link
Collaborator

@flouthoc flouthoc Oct 25, 2023

Choose a reason for hiding this comment

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

Shouldn't this just check if containerfile is a valid URL using ParseRequestURI and treat every other value as a path ? I mean value could be a relative path which does not starts with /

Copy link
Member Author

Choose a reason for hiding this comment

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

A path is treated as a valid URI. Perhaps I can do the same check as before if the parsed requests path equals the path, then it is a path.

for _, containerfile := range m {
containerFiles = append(containerFiles, filepath.Join(contextDirectory, filepath.Clean(filepath.FromSlash(containerfile))))
u, err := url.ParseRequestURI(containerfile)
Copy link
Member

Choose a reason for hiding this comment

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

what happens if there IS an error?

Copy link
Member Author

Choose a reason for hiding this comment

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

We ignore it and treat it as a file path, which is status quo.

tmp/Dockerfile was causing an error, while
/tmp/Dockerfile passes. So we treat either case as a file.

Copy link
Member

@TomSweeneyRedHat TomSweeneyRedHat left a comment

Choose a reason for hiding this comment

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

LGTM

for _, containerfile := range m {
containerFiles = append(containerFiles, filepath.Join(contextDirectory, filepath.Clean(filepath.FromSlash(containerfile))))
u, err := url.ParseRequestURI(containerfile)
if err != nil || u.Path == containerfile {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment? I am just on my first cup of coffee and it took much longer than I wished to understand what this condition does.

Is the u.Path == contianerfile really needed? AFAIK a URL needs a schema and /tmp/Dockerfile doesn't have one.

Copy link
Member

Choose a reason for hiding this comment

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

Buildah does a strings.HasPrefix check for http{s}://. Should we do that here as well? This way, errors aren't ignored in case of syntax mistakes etc.

@@ -430,6 +430,11 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO

dontexcludes := []string{"!Dockerfile", "!Containerfile", "!.dockerignore", "!.containerignore"}
for _, c := range containerFiles {
u, err := url.ParseRequestURI(c)
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

Podman build --remote is translating https://path as if it was a file
path. This change will leave it as a URL so it can be parsed on the
server side.

Fixed: containers#20475

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
@rhatdan
Copy link
Member Author

rhatdan commented Oct 30, 2023

@vrothberg Mergeme...

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

/lgtm
mergeyou

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 31, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 31, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan, vrothberg

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 merged commit 3776446 into containers:main Oct 31, 2023
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Jan 30, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/api-change Change to remote API; merits scrutiny lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman build --file does not actually accept a URL
5 participants