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

Allow getting PluginGroup and installing plugins with PluginGroup with vMAJOR or vMAJOR.MINOR or vMAJOR.MINOR.PATCH versions #494

Conversation

anujc25
Copy link
Contributor

@anujc25 anujc25 commented Sep 21, 2023

What this PR does / why we need it

  • Allow getting PluginGroup and installing plugins with PluginGroup with vMAJOR or vMAJOR.MINOR or vMAJOR.MINOR.PATCH versions

Which issue(s) this PR fixes

Fixes #493

Describe testing done for PR

  • Added Unit tests and E2E tests
$ export TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST=localhost:9876/tanzu-cli/plugins/central:small

$ tz plugin source update default --uri localhost:9876/tanzu-cli/plugins/central:small
[i] Reading plugin inventory for "localhost:9876/tanzu-cli/plugins/central:small", this will take a few seconds.
[!] Skipping the plugins discovery image signature verification for "localhost:9876/tanzu-cli/plugins/central:small"
 
[ok] updated discovery source default
$ tz plugin group search --show-details
[i] The tanzu cli essential plugins are outdated and are being updated now. The update may take a few seconds.

name: vmware-tmc/tmc-user
description: Desc for vmware-tmc/tmc-user:v9.9.9
latest: v9.9.9
versions:
    - v0.0.1
    - v9.9.9

name: vmware-tanzucli/essentials
description: Desc for vmware-tanzucli/essentials:v9.9.9
latest: v9.9.9
versions:
    - v0.0.1
    - v9.9.9

name: vmware-tkg/default
description: Desc for vmware-tkg/default:v9.9.9
latest: v9.9.9
versions:
    - v0.0.1
    - v9.9.9

name: vmware-tkg/shortversion
description: Desc for vmware-tkg/shortversion:v1.2.0
latest: v1.2.0
versions:
    - v1.1.0-beta.1
    - v1.1.0
    - v1.1.1
    - v1.2.0
$ tz plugin group get vmware-tkg/shortversion:v1.1
Plugins in Group:  vmware-tkg/shortversion:v1.1.1
  NAME     TARGET      VERSION  
  cluster  kubernetes  v1       
  package  kubernetes  v1       
  secret   kubernetes  v1
$ tz plugin group get vmware-tkg/shortversion:v1
Plugins in Group:  vmware-tkg/shortversion:v1.2.0
  NAME     TARGET      VERSION  
  cluster  kubernetes  v2.3     
  package  kubernetes  v2.3     
  secret   kubernetes  v2.3
$ tz plugin group get vmware-tkg/shortversion:v2                                                                                                                                                                                           (base) 
[x] : plugin-group "vmware-tkg/shortversion:v2" cannot be found
$ tz plugin group get vmware-tkg/shortversion:v1.1.0-beta.1
Plugins in Group:  vmware-tkg/shortversion:v1.1.0-beta.1
  NAME     TARGET      VERSION        
  cluster  kubernetes  v1.9.2-beta.1  
  package  kubernetes  v1.9.2-beta.1  
  secret   kubernetes  v1.9.2-beta.1  
$ tz plugin install --group vmware-tkg/shortversion:v1.1
[i] Installing plugins from plugin group 'vmware-tkg/shortversion:v1.1.1'
[i] Installing plugin 'cluster:v1.11.3' with target 'kubernetes'
[i] Plugin binary for 'cluster:v1.11.3' found in cache
[i] Installing plugin 'package:v1.11.3' with target 'kubernetes'
[i] Plugin binary for 'package:v1.11.3' found in cache
[i] Installing plugin 'secret:v1.11.3' with target 'kubernetes'
[i] Plugin binary for 'secret:v1.11.3' found in cache
[ok] successfully installed all plugins from group 'vmware-tkg/shortversion:v1.1.1'
$ tz plugin install --group vmware-tkg/shortversion:v1
[i] Installing plugins from plugin group 'vmware-tkg/shortversion:v1.2.0'
[i] Installing plugin 'cluster:v2.3.5' with target 'kubernetes'
[i] Plugin binary for 'cluster:v2.3.5' found in cache
[i] Installing plugin 'package:v2.3.5' with target 'kubernetes'
[i] Plugin binary for 'package:v2.3.5' found in cache
[i] Installing plugin 'secret:v2.3.5' with target 'kubernetes'
[i] Plugin binary for 'secret:v2.3.5' found in cache
[ok] successfully installed all plugins from group 'vmware-tkg/shortversion:v1.2.0'
$ tz plugin install --group vmware-tkg/shortversion:v2
[x] : unable to find plugin group with name 'vmware-tkg/shortversion' matching version 'v2'
$ tz plugin install --group vmware-tkg/shortversion:v1.1.0-beta.1
[i] Installing plugins from plugin group 'vmware-tkg/shortversion:v1.1.0-beta.1'
[i] Installing plugin 'cluster:v1.9.2-beta.1' with target 'kubernetes'
[i] Installing plugin 'package:v1.9.2-beta.1' with target 'kubernetes'
[i] Installing plugin 'secret:v1.9.2-beta.1' with target 'kubernetes'
[ok] successfully installed all plugins from group 'vmware-tkg/shortversion:v1.1.0-beta.1'

Release note

Allow getting/installing plugins by specifying plugin-group version as `vMAJOR` or `vMAJOR.MINOR` or `vMAJOR.MINOR.PATCH` with `tanzu plugin install --group` and `tanzu plugin group get` commands

Additional information

Special notes for your reviewer

@anujc25 anujc25 requested a review from a team as a code owner September 21, 2023 23:36
Copy link
Contributor

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

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

This looks great!

Some very minor nits and two bigger points below.

  1. The behaviour when using shortened versions with air-gap download should be discussed (the change is probably from Allow installing plugins with vMAJOR or vMAJOR.MINOR or vMAJOR.MINOR.PATCH versions #486). From what I can see the group vmware-tkg/shortversion:v1.1.1 contains plugins with a shortened version of v1. Using that group, when I run a tz plugin download-bundle --group vmware-tkg/shortversion:v1.1.1 I see that it download all plugins that match version v1. I was wondering if it should instead only download the latest patch that matches v1, as we do for plugin install.

  2. While trying this out I notice that when we use a shortened version (for plugins or groups), a pre-release is considered newer than the previous patch. I wonder if that is what we want? For example, in the local test repos we have the secret plugin with versions v1.9.1 and v1.9.2-beta.1 and when install the shorted version v1.9 it installs v1.9.2-beta.1. From an end-user perspective, I don't think this is correct.
    If you agree, we can open an issue for that and not delay this PR.

pkg/command/plugin.go Outdated Show resolved Hide resolved
pkg/command/plugin.go Outdated Show resolved Hide resolved
pkg/command/plugin.go Outdated Show resolved Hide resolved
pkg/command/plugin.go Outdated Show resolved Hide resolved
pkg/plugininventory/sqlite_inventory.go Show resolved Hide resolved
pkg/pluginmanager/manager.go Show resolved Hide resolved
@anujc25 anujc25 force-pushed the support-major-minor-install-for-plugin-group-v2 branch from b927a5b to 49fece8 Compare September 23, 2023 00:11
@anujc25
Copy link
Contributor Author

anujc25 commented Sep 23, 2023

  1. The behaviour when using shortened versions with air-gap download should be discussed (the change is probably from Allow installing plugins with vMAJOR or vMAJOR.MINOR or vMAJOR.MINOR.PATCH versions #486). From what I can see the group vmware-tkg/shortversion:v1.1.1 contains plugins with a shortened version of v1. Using that group, when I run a tz plugin download-bundle --group vmware-tkg/shortversion:v1.1.1 I see that it download all plugins that match version v1. I was wondering if it should instead only download the latest patch that matches v1, as we do for plugin install.

Thanks for pointing this out. I would agree with the suggestion of only downloading latest minor/patch version of the plugin in this case. I have made minor changes in the latest commit to handle this situation. Please take a look.

  1. While trying this out I notice that when we use a shortened version (for plugins or groups), a pre-release is considered newer than the previous patch. I wonder if that is what we want? For example, in the local test repos we have the secret plugin with versions v1.9.1 and v1.9.2-beta.1 and when install the shorted version v1.9 it installs v1.9.2-beta.1.

From an end-user perspective, I don't think this is correct. If you agree, we can open an issue for that and not delay this PR.

I will file a separate issue to handle this as this might require more discussion.

Copy link
Contributor

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks @anujc25 .

LGTM

@anujc25 anujc25 merged commit e4e6b74 into vmware-tanzu:main Sep 25, 2023
4 checks passed
@marckhouzam marckhouzam added this to the v1.1.0 milestone Oct 20, 2023
@anujc25 anujc25 added the docs-impact issues with documentation impact label Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-not-required docs-impact issues with documentation impact
Projects
None yet
3 participants