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

Refactor ListInstalledPlugins #558

Merged

Conversation

chriskim06
Copy link
Member

Small refactor that I think will be necessary for updating search/list/upgrade to work with custom indexes.

Related issue: #483

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 27, 2020
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 27, 2020
if err != nil {
return errors.Wrap(err, "failed to load installed plugins")
}
installed := make(map[string]string)
for _, receipt := range receipts {
installed[receipt.Name] = receipt.Spec.Version
Copy link
Member

Choose a reason for hiding this comment

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

this sounds wrong. what if two plugins with identical names from different indexes exist? it'll show both as installed.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is here to preserve the existing functionality. I'm not trying to update search to work with custom indexes in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah makes sense. That said do you mind adding a TODO so we don't forget these things? The same works below, too.

Comment on lines 123 to 132
receipts, err := installation.GetInstalledPluginReceipts(paths.InstallReceiptsPath())
if err != nil {
return errors.Wrap(err, "failed to load installed plugins list after update")
}
installedPlugins := make(map[string]string)
for _, receipt := range receipts {
installedPlugins[receipt.Name] = receipt.Spec.Version
}

showUpdatedPlugins(os.Stderr, preUpdateIndex, posUpdateIndex, installedPlugins)
Copy link
Member

Choose a reason for hiding this comment

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

this part need more comprehensive and careful refactoring.
I think we need to think heavier refactoring of this part because of

  1. plugin name collisions between indexes
  2. we ought to show index/ prefix to updated plugins as well.

Maybe let's comment out this feature (showing updated stuff) and let's add a TODO to reactivate in upcoming PRs. Not sure. @corneliusweig thoughts?

@@ -129,6 +129,7 @@ func ensureIndexUpdated(_ *cobra.Command, _ []string) error {
installedPlugins[receipt.Name] = receipt.Spec.Version
}

// TODO(chriskim06) consider commenting this out when refactoring for custom indexes
Copy link
Member

Choose a reason for hiding this comment

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

not quite commenting out, but I think we need to pass a similar Pair<indexName,plugin> here as well :) :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ya pluginEntry would be available here. I was just making a note of possibly commenting out the show updated plugins feature like you mentioned in your other comment

@ahmetb
Copy link
Member

ahmetb commented Mar 28, 2020

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 28, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Mar 28, 2020
@k8s-ci-robot k8s-ci-robot merged commit 3bf3882 into kubernetes-sigs:master Mar 28, 2020
@chriskim06 chriskim06 deleted the list-installed-plugins-refactor branch June 11, 2020 15:05
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.

None yet

3 participants