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

multi-index: Add default index if none exists #595

Merged
merged 2 commits into from
Apr 28, 2020

Conversation

ahmetb
Copy link
Member

@ahmetb ahmetb commented Apr 20, 2020

When user runs krew {install,update,upgrade} for the first time, if there are
no indexes, default index (with krew-index repo) is now automatically added.

Right now this code path only runs behind multi-index feature gate.

Related issue: #566
/assign @chriskim06
/area multi-index

@k8s-ci-robot k8s-ci-robot added area/multi-index cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 20, 2020
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 20, 2020
"failed to add default plugin index in absence of no indexes")
}

// ensureDefaultIndexIfNoneExist iterates over all indexes and updates them
Copy link
Member

Choose a reason for hiding this comment

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

Should be ensureIndexesUpdated

Copy link
Member

Choose a reason for hiding this comment

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

Hey just wanted to check in on this, it LGTM except this minor typo in the godoc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah fixing now. I'll make sure cornelius reviews too.

ensureIndexListHasDefaultIndex(t, string(test.Krew("index", "list").RunOrFailOutput()))
}

func ensureIndexListHasDefaultIndex(t *testing.T, output string) {
Copy link
Member

Choose a reason for hiding this comment

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

Seems like you could just pass *ITest here as the param.

Copy link
Member Author

@ahmetb ahmetb Apr 20, 2020

Choose a reason for hiding this comment

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

🤔 why? Only testing.T seems sufficient?

For now I prefer we do list exec outside this.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I only mentioned since the string(test.Krew("index", "list").RunOrFailOutput()) is being passed to each one. I thought it might be better to put that in the ensureIndexListHasDefaultIndex function rather than relying on the caller to pass the desired output.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah got it now. I think that's fine. this way we can actually see the error from RunOrFail at the correct line number.


func ensureIndexListHasDefaultIndex(t *testing.T, output string) {
t.Helper()
if !regexp.MustCompile(`(?m)^default\b`).MatchString(output) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: isn't it better to put this at the package level so that the regular expression is only parsed once instead of for each time this function is called?

Copy link
Member Author

Choose a reason for hiding this comment

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

since it's only part of integration tests, I figured it doesn't matter a whole lot.

@chriskim06 chriskim06 mentioned this pull request Apr 20, 2020
22 tasks
@ahmetb
Copy link
Member Author

ahmetb commented Apr 23, 2020

/hold
/assign @corneliusweig
quick reviews appreciated.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 23, 2020
Copy link
Contributor

@corneliusweig corneliusweig left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
/hold
These tests cover the new behavior quite nicely. My only concern is that nearly all our integration tests use a cached repository to avoid slow network operations. However, most of the added tests clone from remote. We should keep an eye on the test speed. Maybe we can make DefaultIndexURI configurable for tests via an env variable, to avoid the network?

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 23, 2020
When user runs krew {install,update,upgrade} for the first time, if there are
no indexes, default index (with krew-index repo) is now automatically added.

Right now this code path only runs behind multi-index feature gate.

Signed-off-by: Ahmet Alp Balkan <[email protected]>
Signed-off-by: Ahmet Alp Balkan <[email protected]>
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 24, 2020
@ahmetb
Copy link
Member Author

ahmetb commented Apr 27, 2020

@corneliusweig please re-lgtm.

@corneliusweig
Copy link
Contributor

/lgtm
/approve
/hold cancel
Thanks for taking care of this!

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Apr 28, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahmetb, corneliusweig

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:
  • OWNERS [ahmetb,corneliusweig]

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 merged commit 321f52d into kubernetes-sigs:master Apr 28, 2020
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. area/multi-index cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants