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 filtering to the inventory for plugin groups and ignore hidden/deactivated groups #217

Merged
merged 1 commit into from
Apr 19, 2023

Conversation

marckhouzam
Copy link
Contributor

What this PR does / why we need it

This PR is a step towards properly handling hidden/deactivated plugin groups and improving "plugin group search".
Instead of posting a big PR doing everything, I'm going incrementally to make the review process easier.

So, this PR adds support for filtering plugin group when querying the plugin inventory database.

Thanks to this filtering mechanism, hidden plugin groups are no longer returned by the plugin inventory.
In a follow-up PR I will provide a configuration option to toggle this behaviour.

Which issue(s) this PR fixes

Fixes # N/A

Describe testing done for PR

First publish some plugins and plugin groups to the local test DB:

$ make plugin-build-and-publish-packages
$ make inventory-init
$ make inventory-plugin-add
$ make inventory-plugin-group-add PLUGIN_GROUP_NAME_VERSION=test:v0.0.1

# Configure the CLI to use the local test repository
$ tz config set env.TANZU_CLI_PRE_RELEASE_REPO_IMAGE localhost:5001/test/v1/tanzu-cli/plugins/plugin-inventory:latest
$ tz config set env.TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST localhost:5001/test/v1/tanzu-cli/plugins/plugin-inventory:latest

# Make sure we can see the plugin group
$ tz plugin group search
[i] Reading plugin inventory for "localhost:5001/test/v1/tanzu-cli/plugins/plugin-inventory:latest", this will take a few seconds.
[!] Skipping the plugins discovery image signature verification for "localhost:5001/test/v1/tanzu-cli/plugins/plugin-inventory:latest"

  GROUP
  vmware-tzcli/test:v0.0.1

Now we deactivate the group and check that is not shown anymore:

$ make inventory-plugin-group-deactivate PLUGIN_GROUP_NAME_VERSION=test:v0.0.1
$ tz plugin group search
  GROUP
$ tz plugin install --group vmware-tzcli/test:v0.0.1
[x] : could not find group 'vmware-tzcli/test:v0.0.1'

Reactivate the group and see that it can be used again:

$ make inventory-plugin-group-activate PLUGIN_GROUP_NAME_VERSION=test:v0.0.1

$ tz plugin group search
[i] Reading plugin inventory for "localhost:5001/test/v1/tanzu-cli/plugins/plugin-inventory:latest", this will take a few seconds.
[!] Skipping the plugins discovery image signature verification for "localhost:5001/test/v1/tanzu-cli/plugins/plugin-inventory:latest"

  GROUP
  vmware-tzcli/test:v0.0.1

$ tz plugin install --group vmware-tzcli/test:v0.0.1
[i] Installing plugin 'builder:v0.90.0-alpha.0' with target 'global'
[i] Installing plugin 'test:v0.90.0-alpha.0' with target 'global'
[ok] successfully installed all plugins from group 'vmware-tzcli/test:v0.0.1'

Release note

Plugin groups that are marked as "deactivated" in the repository of plugins are now ignored by the CLI.

Additional information

Special notes for your reviewer

@marckhouzam marckhouzam requested a review from a team as a code owner April 14, 2023 18:37
@marckhouzam marckhouzam changed the title Add filtering to the inventory for plugin groups Add filtering to the inventory for plugin groups and ignore hidden/deactivated groups Apr 14, 2023
Thanks to this filtering mechanism, hidden plugin groups are no longer
returned by the plugin inventory. Later we can provide a configuration
option to toggle this behaviour.

This filtering also sets the stage to improve "plugin group search".

Signed-off-by: Marc Khouzam <kmarc@vmware.com>
Comment on lines +321 to +324
if !filter.IncludeHidden {
// Unless we want to also get the hidden plugins, we only request the ones that are not hidden
whereClause = fmt.Sprintf("%s Hidden='false' AND", whereClause)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@anujc25 anujc25 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@marckhouzam marckhouzam merged commit 61ae668 into vmware-tanzu:main Apr 19, 2023
@marckhouzam marckhouzam deleted the feat/filterGroups branch April 19, 2023 11:58
vuil pushed a commit that referenced this pull request May 3, 2023
Thanks to this filtering mechanism, hidden plugin groups are no longer
returned by the plugin inventory. Later we can provide a configuration
option to toggle this behaviour.

This filtering also sets the stage to improve "plugin group search".

Signed-off-by: Marc Khouzam <kmarc@vmware.com>
@marckhouzam marckhouzam added this to the v0.90.0 milestone Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants