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 format flag to the image ls command #12996

Merged
merged 4 commits into from
Dec 23, 2021

Conversation

presztak
Copy link
Member

This PR adds format flag which can modify output of image ls command.
format flag supports following values: short, table, json, yaml. Examples:

minikube image ls - default value for format flag is short so it is backward compatible with previous versions

k8s.gcr.io/pause:3.5
k8s.gcr.io/kube-scheduler:v1.22.3
k8s.gcr.io/kube-proxy:v1.22.3
k8s.gcr.io/kube-controller-manager:v1.22.3
k8s.gcr.io/kube-apiserver:v1.22.3
k8s.gcr.io/etcd:3.5.0-0
k8s.gcr.io/coredns/coredns:v1.8.4
gcr.io/k8s-minikube/storage-provisioner:v5
docker.io/kubernetesui/metrics-scraper:v1.0.7
docker.io/kubernetesui/dashboard:v2.3.1
docker.io/kindest/kindnetd:v20210326-1e038dc5

minikube image ls --format table

|-----------------------------------------|--------------------|---------------|--------|
|                  Image                  |        Tag         |   Image ID    |  Size  |
|-----------------------------------------|--------------------|---------------|--------|
| k8s.gcr.io/coredns/coredns              | v1.8.4             | 8d147537fb7d1 | 47.7MB |
| k8s.gcr.io/etcd                         | 3.5.0-0            | 0048118155842 | 296MB  |
| k8s.gcr.io/kube-proxy                   | v1.22.3            | 6120bd723dced | 105MB  |
| k8s.gcr.io/pause                        | 3.5                | ed210e3e4a5ba | 690kB  |
| docker.io/kindest/kindnetd              | v20210326-1e038dc5 | 6de166512aa22 | 120MB  |
| docker.io/kubernetesui/dashboard        | v2.3.1             | e1482a24335a6 | 223MB  |
| docker.io/kubernetesui/metrics-scraper  | v1.0.7             | 7801cfc6d5c07 | 34.5MB |
| gcr.io/k8s-minikube/storage-provisioner | v5                 | 6e38f40d628db | 31.5MB |
| k8s.gcr.io/kube-apiserver               | v1.22.3            | 53224b502ea4d | 130MB  |
| k8s.gcr.io/kube-controller-manager      | v1.22.3            | 05c905cef780c | 123MB  |
| k8s.gcr.io/kube-scheduler               | v1.22.3            | 0aa9c7e31d307 | 53.9MB |
|-----------------------------------------|--------------------|---------------|--------|

minikube image ls --format yaml

- id: 53224b502ea4de7925ca5ed3d8a43dd4b500b2e8e4872bf9daea1fc3fec05edc
  repoDigests:
  - k8s.gcr.io/kube-apiserver@sha256:412c3b47185fd1c665ee15bcd6a3b04a79752a875230c6530e170c5344328293
  - k8s.gcr.io/kube-apiserver@sha256:6ee1c59e9c1fb570e7958e267a6993988eaa22448beb70d99de7afb21e862e9d
  repoTags:
  - k8s.gcr.io/kube-apiserver:v1.22.3
  size: "129549551"
- id: 0aa9c7e31d307d1012fb9e63c274f1110868709a2c39f770dd82120cd2b8fe0f
  repoDigests:
  - k8s.gcr.io/kube-scheduler@sha256:7f8233b2bfeb39bd9c6c2f34f6f634678133f78008e98dee5ec73f0a87ac66cd
  - k8s.gcr.io/kube-scheduler@sha256:cac7ea67201a84c00f3e8d9be51877c25fb539055ac404c4a9d2dd4c79d3fdab
  repoTags:
  - k8s.gcr.io/kube-scheduler:v1.22.3
  size: "53912661"
- id: ed210e3e4a5bae1237f1bb44d72a05a2f1e5c6bfe7a7e73da179e2534269c459
  repoDigests:
  - k8s.gcr.io/pause@sha256:1ff6c18fbef2045af6b9c16bf034cc421a29027b800e4f9b68ae9b1cb3e9ae07
  - k8s.gcr.io/pause@sha256:369201a612f7b2b585a8e6ca99f77a36bcdbd032463d815388a96800b63ef2c8
  repoTags:
  - k8s.gcr.io/pause:3.5
  size: "689969

Closes #11165

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 21, 2021
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 21, 2021

CLA Signed

The committers are authorized under a signed CLA.

@k8s-ci-robot
Copy link
Contributor

Hi @presztak. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 21, 2021
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@presztak
Copy link
Member Author

@afbjorklund

  1. ListImages returns list of ListImage struct (not json) and then in
    func ListImages(profile *config.Profile) error {
    this is converted to the right format. Is this approach ok for you?
  2. Images printing (in above function) was moved out from for loop because images were printed for every Node. Now, I collect images from all nodes and display only unique items.

@afbjorklund
Copy link
Collaborator

Yes, I think this looks good - don't think the multinode case was considered before

@presztak presztak marked this pull request as ready for review December 18, 2021 18:05
@presztak presztak changed the title WIP: Add format flag to the image ls command Add format flag to the image ls command Dec 18, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 18, 2021
Copy link
Member

@spowelljr spowelljr left a comment

Choose a reason for hiding this comment

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

It's looking good, I just left a single comment, but could you also add some basic testing.

For example, add a test for each option and just check the output somewhat matches
table: expect | k8s.gcr.io/kube-apiserver
yaml: expect - k8s.gcr.io/kube-apiserver
json: etc.

cmd/minikube/cmd/image.go Outdated Show resolved Hide resolved
Copy link
Member

@spowelljr spowelljr 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, thanks for the feature!

@spowelljr spowelljr merged commit b6e2ee2 into kubernetes:master Dec 23, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: presztak, spowelljr

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add some format to the ListImages, such as templates or JSON
5 participants