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

Ignore command PreRun logic for tanzu context get-token command #754

Closed prkalle closed 4 months ago

prkalle commented 4 months ago

What this PR does / why we need it

This PR would ignore command PreRun logic for tanzu context get-token command.

Which issue(s) this PR fixes

Fixes #

Describe testing done for PR

Tested the kubectl command (which internally would call the tanzu context get-token command) after removing the CEIP and EULA opt-in status from the CLI config file. Verified that CLI binary without the fix get stuck and later with updated binary path , the CLI didn't get hang for prompt.

// removed the CEIP and EULA status form the config file.
❯ vim ~/.config/tanzu/config-ng.yaml

❯ kubectl api-resources
[x] : failed to get EULA status: prompt failed: interrupt
NAME   SHORTNAMES   APIVERSION   NAMESPACED   KIND
Unable to connect to the server: getting credentials: exec: executable tanzu failed with exit code 1

//updated the path of the tanzu binary in the exec plugin of the kubeconfig
❯ vim ~/.kube/config
- name: tanzu-cli-TAP_pre-integration-staging-d03c5c97-user
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1
      args:
      - context
      - get-token
      - TAP_pre-integration-staging-d03c5c97
      command: /Users/pkalle/projects/tanzu-cli/bin/tanzu
      env: []
      interactiveMode: IfAvailable
      provideClusterInfo: false

// now with updated CLI binary the login works

❯ kubectl api-resources
[i] Opening the browser window to complete the login
Log in by visiting this link:

    https://console-stg.cloud.vmware.com/csp/gateway/discovery?client_id=tanzu-cli-client-id&code_challenge=ND_rBKs_kxm_TPAyq-n4Qf3mzYGug2ceQuiz4TG5G40&code_challenge_method=S256&orgId=ae93ebb4-a249-4553-aa1e-c87c4b7f75e5&redirect_uri=http%3A%2F%2F127.0.0.1%3A56182%2Fcallback&response_type=code&state=63537b30798749af61469c7d21250095

    Optionally, paste your authorization code: [...]

NAME   SHORTNAMES   APIVERSION   NAMESPACED   KIND

Release note

Ignore command PreRun logic for the tanzu context get-token command 

Additional information

Special notes for your reviewer

marckhouzam commented 4 months ago

Thanks @prkalle. Could you also add it to shouldSkipVersionCheck()? The version check logic could print that a new version is available and we should avoid triggering that from kubectl

prkalle commented 4 months ago

Could you also add it to shouldSkipVersionCheck()? The version check logic could print that a new version is available and we should avoid triggering that from kubectl

Thanks @marckhouzam. Added tanzu context get-token command to shouldSkipVersionCheck().