-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix bug check nonexist authfile #4337
fix bug check nonexist authfile #4337
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of nits, otherwise LGTM. Nicely done @QiWang19
30218b3
to
a094041
Compare
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mheon, QiWang19 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 |
cce152e
to
a8fb99d
Compare
search := podmanTest.Podman([]string{"search", "--authfile", "/tmp/nonexist", "alpine"}) | ||
search.WaitWithDefaultTimeout() | ||
Expect(search.ExitCode()).To(Not(Equal(0))) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add tests for the push, run and play-kube commands? Are any changes needed for cmd/podman/run.go or cmd/podman/play_kube.go too? I would suspect so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@QiWang19 can you answer this one please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests were added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a change to test/e2e/run_test.go, test/e2e/push_test.go or test/e2e/play_kube_test.go in this pr....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
push tests are in login_logout_test.go. I will add tests to run_test.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thx, I'd rather have an additional test in push_test.go, but I won't hold this up further for that.
Can't we just do the shared.GetAuthFile() in the options handling, so we check if the environment variable is set and then we don't need to change all this code? |
dd4a772
to
85f34b6
Compare
this will fail if I don't have default /run/user/1000/containers/auth.json, should we consider this situation that ? I think CI fails for this reason
|
cmd/podman/build.go
Outdated
@@ -155,6 +155,10 @@ func buildCmd(c *cliconfig.BuildValues) error { | |||
} | |||
} | |||
|
|||
if _, err := os.Stat(c.BudResults.Authfile); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the problem with the test is you first need to check if the Authfile has been set. This gets a little wonky due to the Cobra includes, but I think you can check that with c.Flag("authfile").Changed
. You'll need to play/test that making sure that gets tripped appropriately as you pass the auth-file option into the build command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this c.Flag("authfile").Changed
only works for those check that directory runs os.stats under /cmd.
maybe I should get rid of shared.GetSystemContext, just c.Flag("authfile").Changed
and os.stats for each cmd
85f34b6
to
fc9ed24
Compare
I would like to remove the /run/user... stuff from defaults and allow containers/image to handle it, especially if we move to Keyrings as the default, Then we can rely on C/I to specify the default localtion. |
fc9ed24
to
3dfcd1f
Compare
3dfcd1f
to
33fde6d
Compare
☔ The latest upstream changes (presumably #4310) made this pull request unmergeable. Please resolve the merge conflicts. |
b8ddd27
to
0eedbd9
Compare
7fc1b8f
to
29d543a
Compare
LGTM |
return errors.Wrapf(err, "error getting authfile %s", c.Authfile) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We seem to be doing this in many of the commands. Should we make a little utility function in cmd/podman/utils.go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I should add this kind of function in buildah and vendor from there. And add check nonexist authfile in buildah, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine by me if that works better.
search := podmanTest.Podman([]string{"search", "--authfile", "/tmp/nonexist", "alpine"}) | ||
search.WaitWithDefaultTimeout() | ||
Expect(search.ExitCode()).To(Not(Equal(0))) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@QiWang19 can you answer this one please?
29d543a
to
aba410e
Compare
Use GetDefaultAuthFile() from buildah. For podman command(except login), if authfile does not exist returns error. close containers#4328 Signed-off-by: Qi Wang <qiwan@redhat.com>
aba410e
to
d7c0f96
Compare
LGTM |
and green test buttons if someone wants to LGTM it and merge. |
merged this PR after buildah PR containers/buildah#1967 got merged so I can vendor in? |
@QiWang19 I'm a bit confused by your last comment. Do you want to merge this after containers/buildah#1967 gets merged? Then you want to vendor Buildah into Podman once that's in? |
@TomSweeneyRedHat yes #4337 (comment) if I should add this utility function. That function will be used both in buildah and podman. |
/lgtm |
For podman command(except login), if authfile does not exist returns error.
close #4328
Signed-off-by: Qi Wang qiwan@redhat.com