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 skopeo Login from c/common #865

Merged
merged 2 commits into from
May 11, 2020
Merged

Add skopeo Login from c/common #865

merged 2 commits into from
May 11, 2020

Conversation

QiWang19
Copy link
Contributor

@QiWang19 QiWang19 commented Mar 26, 2020

Used c/common/pkg/auth for skopeo login
Based on PR #857

@QiWang19
Copy link
Contributor Author

@rhatdan PTAL
This PR is on top of #857, but it's still under review.

@QiWang19 QiWang19 mentioned this pull request Mar 26, 2020
Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

What is the ultimate dependency graph envisioned to look like? This somewhat suggests Podman → CLI parsing + half of the implementation in Skopeo → another half of the implementation in Buildah.

And where does the actual Buildah CLI fit into this? It can’t call Skopeo, that would be a circular dependency.

@rhatdan
Copy link
Member

rhatdan commented Mar 28, 2020

Lets move the shared code to github.com/containers/common, And not vendor buildah into skopeo.

@QiWang19
Copy link
Contributor Author

How much code should be shared i c/common? If skopeo keeps OptionalBool, podman and buildah CLI cannot fully fit in skopeo. They can share a subset, and skopeo should defined its own cli for Optional.. flags.

@mtrmac
Copy link
Contributor

mtrmac commented Mar 30, 2020

(This should have been the first design concern before writing code I think.)

We can’t trivially share global code anyway, due to things like --debug vs --log-level=debug. (Well, we could work to make them all the same. But that’s non-trivial and a fair bit of work.)

My first guess would be, in Skopeo terms, to make the loginOptions, and loginOptions.run public, and let every application configure its CLI parsing. That would make all flags consistent within projects, but different across all the logins, and require a fair bit of code.

Alternatively, make globalOptions and func loginCommand(*globalOptions) *cobra.Command public, let every application configure CLI parsing for the global options, make the login options consistent between projects (but different from other subcommands in that project).

@mtrmac
Copy link
Contributor

mtrmac commented Mar 30, 2020

BTW making the “optional bool” flag type public and used elsewhere would make sense to me, if we can make it work with Cobra nicely.

@rhatdan
Copy link
Member

rhatdan commented Mar 30, 2020

Well if we need OptionalBool for Skopeo, I do not know why we don't need it for Buidlah And Podman.

@rhatdan
Copy link
Member

rhatdan commented Mar 30, 2020

All of the handling of certs an plugins can be isolated from the CLI Parsing can't it?

@mtrmac
Copy link
Contributor

mtrmac commented Mar 30, 2020

Well if we need OptionalBool for Skopeo, I do not know why we don't need it for Buidlah And Podman.

optionalBool and forbidding string-based parameter matching was an attempt to learn from #523 and make that kind of vulnerability impossible. Buildah/Podman could simply not make those kind of mistakes, I guess :)


All of the handling of certs an plugins can be isolated from the CLI Parsing can't it?

In principle, but that kind of depends on the adjustments that are not “CLI parsing”, e.g. Podman overriding the defaults in “rootless” mode and creating the directories in advance. Those kinds of activities are not “CLI parsing” but it must be possible to inject them into the operation at some point (or, well, they could be removed and pushed down into the backend libraries, as has been somewhat happening recently).

@QiWang19 QiWang19 force-pushed the login branch 2 times, most recently from 5502704 to 4226ca1 Compare April 1, 2020 16:08
@QiWang19 QiWang19 changed the title [WIP]Add skopeo Login from buildah [WIP]Add skopeo Login from c/common Apr 1, 2020
@QiWang19
Copy link
Contributor Author

QiWang19 commented Apr 1, 2020

@mtrmac @rhatdan PTAL. The skopeo uses public CLI definition from c/common/auth, keep its own cli parsing newSystemcontext

cmd/skopeo/login.go Outdated Show resolved Hide resolved
cmd/skopeo/login.go Outdated Show resolved Hide resolved
cmd/skopeo/login.go Outdated Show resolved Hide resolved
cmd/skopeo/login.go Outdated Show resolved Hide resolved
cmd/skopeo/login.go Outdated Show resolved Hide resolved
@QiWang19 QiWang19 force-pushed the login branch 3 times, most recently from 4bff92a to 501cac3 Compare April 7, 2020 21:18
@rhatdan
Copy link
Member

rhatdan commented Apr 8, 2020

@QiWang19 Needs a rebase.

@QiWang19 QiWang19 force-pushed the login branch 2 times, most recently from abc92bc to c8ef7d8 Compare April 8, 2020 16:56
@QiWang19
Copy link
Contributor Author

QiWang19 commented Apr 8, 2020

can the tests for login/logout use the registry set up in integration/registry.go?

@mtrmac
Copy link
Contributor

mtrmac commented Apr 8, 2020

can the tests for login/logout use the registry set up in integration/registry.go?

Sure; check_test.go and other parts already set up several registries that can maybe just be reused.

@QiWang19 QiWang19 force-pushed the login branch 7 times, most recently from fd799da to 43df415 Compare April 13, 2020 16:11
@QiWang19 QiWang19 force-pushed the login branch 6 times, most recently from 83bde40 to a1c646a Compare May 7, 2020 17:13
@QiWang19
Copy link
Contributor Author

QiWang19 commented May 7, 2020

@mtrmac PTAL

@QiWang19 QiWang19 changed the title [WIP]Add skopeo Login from c/common Add skopeo Login from c/common May 7, 2020
cmd/skopeo/login.go Outdated Show resolved Hide resolved
cmd/skopeo/login.go Outdated Show resolved Hide resolved
cmd/skopeo/utils_test.go Outdated Show resolved Hide resolved
SystemRegistriesConfPath: opts.registriesConfPath,
BigFilesTemporaryDir: opts.tmpDir,
}
// DEPRECATED: We support this for backward compatibility, but override it if a per-image flag is provided.
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be removed from imageOptions.newSystemContext now (and I guess replaced with a comment that explains that the imageOptions option overrides the global one if both are present.

Copy link
Contributor

Choose a reason for hiding this comment

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

(Non-blocking: I meant a comment specific to --tls-verify. I guess the current generic one works.)

cmd/skopeo/login.go Outdated Show resolved Hide resolved
completions/bash/skopeo Outdated Show resolved Hide resolved
docs/skopeo-login.1.md Outdated Show resolved Hide resolved
integration/login_logout_test.go Outdated Show resolved Hide resolved
integration/login_logout_test.go Outdated Show resolved Hide resolved
integration/login_logout_test.go Outdated Show resolved Hide resolved
@QiWang19 QiWang19 force-pushed the login branch 4 times, most recently from cf106d8 to fdd1111 Compare May 8, 2020 18:34
@QiWang19
Copy link
Contributor Author

QiWang19 commented May 8, 2020

@mtrmac PTAL

cmd/skopeo/logout.go Outdated Show resolved Hide resolved
SystemRegistriesConfPath: opts.registriesConfPath,
BigFilesTemporaryDir: opts.tmpDir,
}
// DEPRECATED: We support this for backward compatibility, but override it if a per-image flag is provided.
Copy link
Contributor

Choose a reason for hiding this comment

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

(Non-blocking: I meant a comment specific to --tls-verify. I guess the current generic one works.)

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Looks good, last nits.

integration/check_test.go Outdated Show resolved Hide resolved
@QiWang19
Copy link
Contributor Author

@mtrmac PTAL

@mtrmac
Copy link
Contributor

mtrmac commented May 11, 2020

#865 (comment) is still outstanding, and please rebase. Looks good otherwise.

Implements skopeo login&logout commands.

Signed-off-by: Qi Wang <[email protected]>
@QiWang19
Copy link
Contributor Author

@mtrmac PTAL

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@mtrmac mtrmac merged commit 4ca9b13 into containers:master May 11, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 29, 2023
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.

3 participants