-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Support login to the integrated registry via CLI #18930
Support login to the integrated registry via CLI #18930
Conversation
9659e75
to
ea39c80
Compare
@bparees for 90% of clusters this will do the right thing once we start forcing registryExternalHostname, since everyone is going to have stuff in openshift. Eventually when david's changes for logging /metrics route publishing to config map land we can also push the registry URL. |
i don't suppose i could convince you that it should be "oc registry" and not "oc image"? |
if we have commands that work on both images and registries would we want
two top level commands?
oc image mirror
oc image rebase
oc image login
oc image import
oc image add-layer
oc registry mirror
oc registry rebase
oc registry login
oc registry import
oc registry add-layer
? Agree registry sounds better for some, but I'd also prefer for a top
level command to have more related subcommands (i.e. two almost empty top
level commands makes me sad).
Agree registry will be more discoverable for some.
…On Sun, Mar 11, 2018 at 6:35 PM, Ben Parees ***@***.***> wrote:
i don't suppose i could convince you that it should be "oc registry" and
not "oc image"?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18930 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_p_r2NuwozFuhaw4ucNUETsnQJSwoks5tdaaugaJpZM4SlfK4>
.
|
I would not say we have commands that work on both images+registries, i'd say we have some commands that work on registries, and commands that work on images.
operates on images
operates on images
operates on registries
operates on images
operates on images If we later want to have a registry info command are we going to be happy calling it "oc image info"? |
ea39c80
to
ad685e1
Compare
/retest |
d63f899
to
d79b771
Compare
/test all |
this is updated with feedback and adds a |
/retest |
d79b771
to
fd7dd78
Compare
/retest |
c89cae9
to
d2b937c
Compare
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.
One small nit but overall lgtm.
if ref, err := imageapi.ParseDockerImageReference(registry); err == nil { | ||
o.HostPort = ref.Registry | ||
if internal { | ||
fmt.Fprintf(o.ErrOut, "info: Using internal registry hostname %s\n", o.HostPort) |
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.
If this is info, use o.Out
not o.ErrOut
, the latter is only for warning and errors.
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 should be using stderr for anything that is not directly tied to the output of the 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.
Info, warning, and error are all stderr.
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.
Warning and error -> stderr, if info should be possible to hide use glog with different levels. Any other info is info that should put to stdout just like the rest of the output b/c it's relevant to the user.
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.
No, it shouldn’t. Info is not glog. Info is information relevant to the user that is not a warning. It is not normal output. Stdout is data for processing. Glog is not human facing the way info is.
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.
$ grep -R --include=*.go -E "\"info:" pkg/
pkg//oc/admin/migrate/etcd/ttl.go: fmt.Fprintf(o.Out, "info: Lease #%d with TTL %d created\n", lease.ID, lease.TTL)
pkg//oc/admin/migrate/etcd/ttl.go: fmt.Fprintf(o.Out, "info: Attaching lease to %d entries\n", len(objectsResp.Kvs))
pkg//oc/admin/migrate/etcd/ttl.go: fmt.Fprintf(o.Out, "info: Lease already attached to %d entries, no change made\n", alreadyAttached)
pkg//oc/admin/migrate/migrator.go: fmt.Fprintf(out, "info: to rerun only failing resources, add --include=%s\n", strings.Join(t.resourcesWithErrors.List(), ","))
pkg//oc/admin/router/router.go: fmt.Fprintf(errout, "info: password for stats user %s has been set to %s\n", cfg.StatsUsername, cfg.StatsPassword)
pkg//oc/cli/cmd/image/mirror/mirror.go: fmt.Fprintf(o.ErrOut, "info: Filtered all images from %s, skipping\n", src.ref)
pkg//oc/cli/cmd/logs.go: o.KubeLogOptions.Out.Write([]byte(fmt.Sprintf("info: Logs available at %s\n", urlString)))
pkg//oc/cli/cmd/set/buildhook.go: fmt.Fprintf(o.Err, "info: %s %q was not changed\n", info.Mapping.Resource, info.Name)
pkg//oc/cli/cmd/set/buildsecret.go: fmt.Fprintf(o.Err, "info: %s %q was not changed\n", info.Mapping.Resource, info.Name)
pkg//oc/cli/cmd/set/deploymenthook.go: fmt.Fprintf(o.Err, "info: %s %q was not changed\n", info.Mapping.Resource, info.Name)
pkg//oc/cli/cmd/set/imagelookup.go: fmt.Fprintf(o.Err, "info: %s %q was not changed\n", info.Mapping.Resource, info.Name)
pkg//oc/cli/cmd/set/probe.go: fmt.Fprintf(o.Err, "info: %s %q was not changed\n", info.Mapping.Resource, info.Name)
pkg//oc/cli/cmd/set/routebackends.go: fmt.Fprintf(o.Err, "info: %s %q was not changed\n", info.Mapping.Resource, info.Name)
pkg//oc/cli/cmd/set/triggers.go: fmt.Fprintf(o.Err, "info: %s %q was not changed\n", info.Mapping.Resource, info.Name)
pkg//oc/cli/cmd/set/volume.go: fmt.Fprintf(v.Err, "info: %s %q was not changed\n", info.Mapping.Resource, info.Name)
pkg//oc/cli/cmd/set/volume.go: fmt.Fprintf(v.Err, "info: Generated volume name: %s\n", name)
pkg//oc/cli/util/clientcmd/factory.go: glog.V(1).Infof("info: the output version specified is invalid. %s\n", defaultVersionInfo)
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.
All glog output goes to stderr, but info:
is effectively v(0) without the prefix (the prefix is not useful for a human interacting with a cli). The user should have the information. The user should not have to filter that out, i.e.:
$ curl https://$( oc registry info )
shouldn't send info: The registry is internal
to curl - it should print that on stderr so the shell captures only the url, not the output
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.
The TTL command is outputting to stdout because it prints nothing else.
d2b937c
to
e07916c
Compare
If no other comments marking. |
/retest |
nothing from me |
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 lied
pkg/oc/cli/cmd/registry/info/info.go
Outdated
) | ||
|
||
var ( | ||
loginDesc = templates.LongDesc(` |
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.
infoDesc
pkg/oc/cli/cmd/registry/info/info.go
Outdated
|
||
Experimental: This command is under active development and may change without notice.`) | ||
|
||
loginExample = templates.Examples(` |
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.
infoExample
pkg/oc/cli/cmd/registry/info/info.go
Outdated
Use: "info ", | ||
Short: "Print info about the integrated registry", | ||
Long: loginDesc, | ||
Example: fmt.Sprintf(loginExample, name+" login"), |
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.
infoExample
pkg/oc/cli/cmd/registry/info/info.go
Outdated
cmd := &cobra.Command{ | ||
Use: "info ", | ||
Short: "Print info about the integrated registry", | ||
Long: loginDesc, |
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.
infoDesc
/hold |
e07916c
to
5cfdfa5
Compare
New changes are detected. LGTM label has been removed. |
/retest |
2 similar comments
/retest |
/retest |
/retest
|
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest |
Adds a new `oc registry login` command that allows the user to easily log in to the integrated registry. By default it tries to use the current user token (but supports `-z` for service accounts) and looks up the public or internal hostname by finding image streams in the current namespace or the 'openshift' namespace (which is usually populated). Also add `oc registry info` for fetching the current registry DNS name.
5cfdfa5
to
886132f
Compare
New changes are detected. LGTM label has been removed. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: smarterclayton 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 |
Adds a new
oc image login
command that allows the user to easily login to the integrated registry. By default it tries to use the current
user token (but supports
-z
for service accounts) and looks up thepublic or internal hostname by finding image streams in the current
namespace or the 'openshift' namespace (which is usually populated).
This did highlight that openshift ansible is not setting externalRegistryHostname by default in the install which it should be doing.