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 --compat-auth-file to login and logout #5143

Merged
merged 4 commits into from
Nov 17, 2023

Conversation

mtrmac
Copy link
Contributor

@mtrmac mtrmac commented Nov 7, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

Add --compat-auth-file to login/logout, allowing to update Docker-compatible files.

This mostly inherits the feature from c/common/pkg/auth.

Completely untested at this point.

How to verify it

Existing CI for existing features.
Some minimal smoke tests; and manual tests that the updated files can be correctly consumed by Docker.

Which issue(s) this PR fixes:

None

Special notes for your reviewer:

Does this PR introduce a user-facing change?

`login` and `logout` now support editing Docker-compatible config files, using a `--compat-auth-file` option.

@mtrmac
Copy link
Contributor Author

mtrmac commented Nov 7, 2023

Also depends on #5129 .

@@ -152,3 +167,31 @@ EOM
expect_output --substring "authentication required" \
"buildah push after buildah logout"
}

@test "authenticate: --compat-auth-file" {
skip_if_no_docker
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apparently no instance of our CI runs with Docker, so this code is completely untested (and right now, incomplete WRT expected output).

I’ll smoke-test the operation manually, and drop this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dropped.

@@ -192,7 +192,7 @@ tests/testreport/testreport: tests/testreport/testreport.go
.PHONY: test-unit
test-unit: tests/testreport/testreport
$(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" -cover $(RACEFLAGS) $(shell $(GO) list ./... | grep -v vendor | grep -v tests | grep -v cmd | grep -v chroot | grep -v copier) -timeout 45m
$(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" $(RACEFLAGS) ./chroot ./copier -timeout 45m
$(GO_TEST) -v -tags "$(STORAGETAGS) $(SECURITYTAGS)" $(RACEFLAGS) ./chroot ./copier -timeout 60m
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note this unrelated change. The tests keep timing out, so I just bumped the maximum.

One recent success took 47m.

It would probably be worthwhile to spend some time speeding up the tests, but that’s not this PR.

@mtrmac
Copy link
Contributor Author

mtrmac commented Nov 10, 2023

Manually smoke-tested operation and interoperability with

# docker pull localhost:5000/foo
Using default tag: latest
Error response from daemon: Head "http://localhost:5000/v2/foo/manifests/latest": no basic auth credentials
# bin/buildah login --tls-verify=false --compat-auth-file ~/.docker/config.json localhost:5000
Username: …
Password: 
Login Succeeded!
# docker pull localhost:5000/foo
Using default tag: latest
Error response from daemon: manifest for localhost:5000/foo:latest not found: manifest unknown: manifest unknown
# bin/buildah logout --compat-auth-file ~/.docker/config.json localhost:5000
Removed login credentials for localhost:5000
# docker pull localhost:5000/foo
Using default tag: latest
Error response from daemon: Head "http://localhost:5000/v2/foo/manifests/latest": no basic auth credentials

@mtrmac mtrmac force-pushed the docker-compat-login branch from 906a599 to 881337e Compare November 10, 2023 01:12
@rhatdan
Copy link
Member

rhatdan commented Nov 10, 2023

Tests are passing...

@mtrmac
Copy link
Contributor Author

mtrmac commented Nov 10, 2023

Yes; c/image and c/common must be merged first.

@mtrmac
Copy link
Contributor Author

mtrmac commented Nov 16, 2023

Rebased on top of merged main branches, please review & merge.

Cc: @flouthoc .

@mtrmac mtrmac marked this pull request as ready for review November 16, 2023 15:09
@mtrmac mtrmac changed the title WIP: Add --compat-auth-file to login and logout Add --compat-auth-file to login and logout Nov 16, 2023
@mtrmac mtrmac force-pushed the docker-compat-login branch from 956f2ec to a3910f4 Compare November 16, 2023 16:40
Copy link
Collaborator

@flouthoc flouthoc 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 Nov 16, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, mtrmac

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

... to include containers/image#2173
and containers/common#1731 .

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This mostly just inherits the c/common/pkg/auth implementation,
except that AuthFilePath and DockerCompatAuthFilePath can not be set
simultaneously, so don't always set AuthFilePath. c/common already
defaults to the same locations internally.

Test handle only invalid commands; a true interoperability test
would require a running Docker on the CI systems, which is not currently
available. That interoperability was tested manually
(and is presumed to be integration-tested in the Podman repo).

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Warning: I don't know what I'm doing, I just don't care
to deal with this now.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
@TomSweeneyRedHat
Copy link
Member

LGTM

@TomSweeneyRedHat
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Nov 17, 2023
@openshift-merge-bot openshift-merge-bot bot merged commit 644f312 into containers:main Nov 17, 2023
36 checks passed
@mtrmac mtrmac deleted the docker-compat-login branch November 17, 2023 04:38
mtrmac added a commit to mtrmac/libpod that referenced this pull request Nov 17, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants