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

oc get images --show-labels doesn't show labels #17736

Closed
cben opened this issue Dec 12, 2017 · 0 comments
Closed

oc get images --show-labels doesn't show labels #17736

cben opened this issue Dec 12, 2017 · 0 comments
Assignees
Labels
component/cli kind/bug Categorizes issue or PR as related to a bug. priority/P2

Comments

@cben
Copy link

cben commented Dec 12, 2017

--show-labels works for most resource types but not images — it only adds a LABELS headers but doesn't actually add a column with labels.

Version

oc v3.7.0+7ed6862
kubernetes v1.7.6+a08f5eeb62
features: Basic-Auth GSSAPI Kerberos SPNEGO

Server https://192.168.99.100:8443
openshift v3.7.0+7ed6862
kubernetes v1.7.6+a08f5eeb62

(via minishift 1.9.0)

Steps To Reproduce
$ oc label image sha256:01eed3f3b8c323b6074c77256c82c7fb94293ff35c65bdde93a21bbcd4bad358 foo=bar
$ oc get images 
NAME                                                                      DOCKER REF
sha256:01eed3f3b8c323b6074c77256c82c7fb94293ff35c65bdde93a21bbcd4bad358   centos/ruby-24-centos7@sha256:01eed3f3b8c323b6074c77256c82c7fb94293ff35c65bdde93a21bbcd4bad358
sha256:0ba509791429be8e2ad63eed6012e391a42b69ef710b8f4815d321b84f069166   openshift/wildfly-100-centos7@sha256:0ba509791429be8e2ad63eed6012e391a42b69ef710b8f4815d321b84f069166
...
$  oc get images --show-labels
NAME                                                                      DOCKER REF   LABELS
sha256:01eed3f3b8c323b6074c77256c82c7fb94293ff35c65bdde93a21bbcd4bad358   centos/ruby-24-centos7@sha256:01eed3f3b8c323b6074c77256c82c7fb94293ff35c65bdde93a21bbcd4bad358
sha256:0ba509791429be8e2ad63eed6012e391a42b69ef710b8f4815d321b84f069166   openshift/wildfly-100-centos7@sha256:0ba509791429be8e2ad63eed6012e391a42b69ef710b8f4815d321b84f069166
...
$ oc get images --template $'{{range .items}}{{.metadata.name}}\t{{.dockerImageReference}}\t{{.metadata.labels}}\n{{end}}' | column -t -s $'\t'
sha256:01eed3f3b8c323b6074c77256c82c7fb94293ff35c65bdde93a21bbcd4bad358  centos/ruby-24-centos7@sha256:01eed3f3b8c323b6074c77256c82c7fb94293ff35c65bdde93a21bbcd4bad358           map[foo:bar]
sha256:0ba509791429be8e2ad63eed6012e391a42b69ef710b8f4815d321b84f069166  openshift/wildfly-100-centos7@sha256:0ba509791429be8e2ad63eed6012e391a42b69ef710b8f4815d321b84f069166    <no value>
...
Current Result
NAME                                                                      DOCKER REF   LABELS
sha256:01eed3f3b8c323b6074c77256c82c7fb94293ff35c65bdde93a21bbcd4bad358   centos/ruby-24-centos7@sha256:01eed3f3b8c323b6074c77256c82c7fb94293ff35c65bdde93a21bbcd4bad358
Expected Result
NAME                                                                      DOCKER REF   LABELS
sha256:01eed3f3b8c323b6074c77256c82c7fb94293ff35c65bdde93a21bbcd4bad358   centos/ruby-24-centos7@sha256:01eed3f3b8c323b6074c77256c82c7fb94293ff35c65bdde93a21bbcd4bad358   foo=bar
P.S. custom-columns doesn't help

This is the kind of thing where custom-columns could be friendlier than go templates, but alas it fails if any of the images has no labels. Is it because of omitempty and jsonpath expressions not handling nil? I found no way to explicitly iterate over a map, nor a way to explicitly check for nil.
Is this why --show-labels was important in the first place?

$ oc get images -o 'custom-columns=NAME:.metadata.name,DOCKER REF:.dockerImageReference,LABELS:.metadata.labels' 
error: labels is not found
$ oc get images -o 'custom-columns=NAME:.metadata.name,DOCKER REF:.dockerImageReference,LABELS:.metadata.labels' sha256:01eed3f3b8c323b6074c77256c82c7fb94293ff35c65bdde93a21bbcd4bad358
NAME                                                                      DOCKER REF                                                                                       LABELS
sha256:01eed3f3b8c323b6074c77256c82c7fb94293ff35c65bdde93a21bbcd4bad358   centos/ruby-24-centos7@sha256:01eed3f3b8c323b6074c77256c82c7fb94293ff35c65bdde93a21bbcd4bad358   map[foo:bar]
@pweil- pweil- added component/cli kind/bug Categorizes issue or PR as related to a bug. priority/P2 labels Dec 13, 2017
openshift-merge-robot added a commit that referenced this issue Dec 30, 2017
Automatic merge from submit-queue.

Add labels column to `oc get images --show-labels` output

Fixes #17736 

This is my first code contribution to the project. Please let me know if I missed anything or if I should have branched off of a release instead of master.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/cli kind/bug Categorizes issue or PR as related to a bug. priority/P2
Projects
None yet
Development

No branches or pull requests

3 participants