vmware-tanzu / tanzu-cli

The Tanzu Core CLI project provides the core functionality of the Tanzu CLI. The CLI is based on a plugin architecture where CLI command functionality can be delivered through independently developed plugin binaries
Apache License 2.0
33 stars 21 forks source link

Use shared values of latest version of plugins #769

Closed marckhouzam closed 3 months ago

marckhouzam commented 3 months ago

What this PR does / why we need it

If we want to modify the description of a plugin, we can publish a new version with the new description. The problem is that the plugin search command shows the description of the oldest plugin version.

This commit makes sure the shared values of a plugin are taken from the most recent version.

This allows to change the description, the vendor and/or the publisher by publishing a new version of the plugin.

Which issue(s) this PR fixes

Fixes # N/A

Describe testing done for PR

Add unit tests.

We had the problem with the appsv2 plugin where we tried to change its description but plugin search still showed the old description. What we did was to deactivate the old appsv2 version v0.2.0 to only have the new description. I wanted to confirm this PR fixed the issue so I did:

  1. locally reactivate appsv2:v0.2.0 in my own DB cache
  2. run a plugin search with CLI v1.3.0 to see the old description
  3. run a plugin search with this PR to see the new description
# Broken CLI
$ /opt/homebrew/bin/tanzu version
version: v1.3.0
buildDate: 2024-05-09
sha: d59f47c8
arch: arm64

# Fixed CLI
$ tz version
version: v1.3.0-dev
buildDate: 2024-05-13
sha: c95c9ca4a
arch: arm64

# Check that only v0.2.1 is visible to start and check the description
$ /opt/homebrew/bin/tanzu plugin search --name appsv2 -t global --show-details
name: appsv2
description: Applications on Tanzu Platform
target: global
latest: v0.2.1
versions:
    - v0.2.1

# Re-activate appsv2:v0.2.0 locally
$ echo "UPDATE PluginBinaries SET hidden='false' where PluginName ='appsv2' and Version='v0.2.0'" |sqlite3 ~/.cache/tanzu/plugin_inventory/default/plugin_inventory.db

# Check that the description is now the old one with the broken CLI
$ /opt/homebrew/bin/tanzu plugin search --name appsv2 -t global --show-details
name: appsv2
description: Applications on Kubernetes for TAP (SaaS distribution)
target: global
latest: v0.2.1
versions:
    - v0.2.0
    - v0.2.1

$ /opt/homebrew/bin/tanzu plugin search --name appsv2 -t global
  NAME    DESCRIPTION                                             TARGET  LATEST
  appsv2  Applications on Kubernetes for TAP (SaaS distribution)  global  v0.2.1

# Check with the PR
$ tz plugin search --name appsv2 -t global
  NAME    DESCRIPTION                     TARGET  LATEST
  appsv2  Applications on Tanzu Platform  global  v0.2.1
$ tz plugin search --name appsv2 -t global --show-details
name: appsv2
description: Applications on Tanzu Platform
target: global
latest: v0.2.1
versions:
    - v0.2.0
    - v0.2.1

Release note

Show the description of the latest (instead of oldest) version of a plugin in the `tanzu plugin search` output.

Additional information

Special notes for your reviewer