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

Deprecate the kubernetes target command #781

Closed marckhouzam closed 2 months ago

marckhouzam commented 3 months ago

What this PR does / why we need it

Today plugins created with TargetK8s target type have their commands visible/invocable via both tanzu <pluginname> ... and tanzu kubernetes|k8s <plugingname> ...

The form without a target prefix is available only to kubernetes target for historical and compatibility reasons, but is the predominant invocation style. Since Tanzu Platform's plugin functionality are delivered through a mix of kubernetes-targeted and nonkubernetes-targeted plugins, encouraging this more compact form is important in promoting consistent and intuitive invocation styles.

This PR deprecates the invocation of plugins using the kubernetes prefix. Due to backward compatibility invoking tanzu kubernetes ... remains possible with this PR, but the top-level help no longer shows this target/command group. Furthermore the help for tanzu kubernetes will print a deprecation message to stderr guiding the user to use the short form.

Take notice that the deprecation message will only be shown for tanzu kubernetes and not for tanzu kubernetes <subcmd>. This is to avoid hiding all the sub-commands under the kubernetes target (a deprecated command is automatically hidden).

To remove the invocation using the kubernetes prefix from the help, I have opened: https://github.com/vmware-tanzu/tanzu-plugin-runtime/pull/192.

Which issue(s) this PR fixes

Fixes # N/A

Describe testing done for PR

# No kubernetes target shown in the help
$ tz
The Tanzu CLI

Usage:
  tanzu [command]

Available command groups:

  Admin
    builder                 Build Tanzu components
  Build
    app                     Applications on Tanzu Platform
    build                   Generate app image from source code
    services                Commands for working with services, classes and claims
  Manage
    availability-target     Availability-target lifecycle management
    deploy                  Deploy resources
    kubectl                 Provides the kubectl functionality kubectl functionality
    profile                 Profile lifecycle management
    project                 View, list and use Tanzu Projects.
    rbac                    Impose role based access restrictions on spaces
    resource                manage resources in a Kubernetes cluster
    space                   Tanzu space lifecycle management
    trait                   Trait lifecycle management
  Run
    kubetool                Invokes any binary after setting KUBECONFIG to match the tanzu CLI
    package                 tanzu package management
    secret                  Tanzu secret management
    telemetry               configure cluster-wide settings for vmware tanzu telemetry
  System
    completion              Output shell completion code
    config                  Configuration for the CLI
    context                 Configure and manage contexts for the Tanzu CLI
    login                   Login to Tanzu Platform for Kubernetes
    plugin                  Manage CLI plugins
    version                 Version information
  Target
    operations              Commands that support Kubernetes operations for Tanzu Platform for Kubernetes

Flags:
  -h, --help   help for tanzu

Use "tanzu [command] --help" for more information about a command.

# Kuberetes target still accessible but with a deprecation message
# and its sub commands are visiable
$ tz k8s -h
Command "kubernetes" is deprecated, you should invoke its sub-commands directly without the "kubernetes" prefix.
Commands that interact with a Kubernetes endpoint

Usage:
  tanzu kubernetes [command]

Aliases:
  kubernetes, k8s

Available command groups:

  Build
    services                Commands for working with services, classes and claims
  Run
    package                 tanzu package management
    secret                  Tanzu secret management

Flags:
  -h, --help   help for kubernetes

Use "tanzu kubernetes [command] --help" for more information about a command.

# K8s plugins can still be invoked with the target
$ tz k8s secret -h
Tanzu secret management

Usage:
  tanzu secret [command]
  tanzu kubernetes secret [command]

Available Commands:
  registry      Registry secret operations

Flags:
  -h, --help                help for secret
      --kubeconfig string   The path to the kubeconfig file, optional
      --verbose int32       Number for the log level verbosity(0-9)

Use "tanzu secret [command] --help" for more information about a command.
Use "tanzu kubernetes secret [command] --help" for more information about a command.

Release note

Deprecate the plugin invocation form `tanzu kubernetes <plugin>` in favour of the shorter and more consistent `tanzu <plugin>`

Additional information

Special notes for your reviewer