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 cache list support #2272

Merged
merged 5 commits into from
Dec 8, 2017
Merged

Add cache list support #2272

merged 5 commits into from
Dec 8, 2017

Conversation

kairen
Copy link
Contributor

@kairen kairen commented Dec 5, 2017

This commit added cache list support. Because currently cannot know which images are cached.

For command result as below:

$ ./out/minikube cache add ubuntu:16.04 redis:3
$ ./out/minikube cache list
redis:3
ubuntu:16.04

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 5, 2017
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@dlorenc
Copy link
Contributor

dlorenc commented Dec 5, 2017

@minikube-bot test this please

@dlorenc
Copy link
Contributor

dlorenc commented Dec 5, 2017

@minikube-bot ok to test

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 6, 2017
@kairen
Copy link
Contributor Author

kairen commented Dec 7, 2017

Hi, @r2d4 Do you mind reviewing this PR?


func cacheList(images map[string]interface{}) error {
for imageName := range images {
tmpl, err := template.New("list").Parse(cacheListFormat)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you move this up out of the for loop? It looks like the format here is always a constant, so there's no need to do it in each iteration of the loop.

Copy link
Contributor Author

@kairen kairen Dec 8, 2017

Choose a reason for hiding this comment

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

I added a new flag to custom format for cache list, for future work, we could extend the CacheListTemplate to add more image detail, such as below:

var cacheListFormat  = "{{.CacheImageName}}:{{.CacheImageTag}}\n"

type CacheListTemplate struct {
	CacheImageName   string
        CacheImageTag    string
}

But we need to ensure minikube cache add <image> use latest tag to save in config.

This <Image> does not have a tag.

For example:

$ minikube cache add redis
$ cat .minikube/config/config.json
{
    "WantReportError": true,
    "WantReportErrorPrompt": false,
    "cache": {
        "redis:latest": null
    },
    "ingress": false
}

"k8s.io/minikube/pkg/minikube/constants"
)

const cacheListFormat = "- {{.CacheImageName}}\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: do we need the "-" character here? It would make automatic parsing of stdout a little tricker (like if you wanted to use this in a bash for loop, etc.).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I ignored this usage scenario, I'll remove this character to bring about this results:

$ minikube cache add redis ubuntu
$ minikube cache delete $(minikube cache list)

if err != nil {
return nil, err
}
newImages := make(map[string]interface{})
Copy link
Contributor

Choose a reason for hiding this comment

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

Would a "slice" of images work instead of a map? It looks like you only set "nil" as the value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem, I'll do it!

@dlorenc dlorenc merged commit 777b446 into kubernetes:master Dec 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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.

4 participants