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

login and context create commands informs user when `TANZU_CLI_CLOUD_SERVICES_ORGANIZATION_ID` is being used #771

Closed prkalle closed 3 months ago

prkalle commented 3 months ago

What this PR does / why we need it

This PR has changes in login and context create commands to inform user when TANZU_CLI_CLOUD_SERVICES_ORGANIZATION_ID is being used

Which issue(s) this PR fixes

Fixes #

Describe testing done for PR

exported env variable TANZU_CLI_CLOUD_SERVICES_ORGANIZATION_ID by both means ( using tanzu config set env.TANZU_CLI_CLOUD_SERVICES_ORGANIZATION_ID xxx and using export TANZU_CLI_CLOUD_SERVICES_ORGANIZATION_ID=xxx) and verified the exported variable previals and the log message is appropriate. Later tested by unset the environment variable followed by unsetting the CLI config environment variable.

❯ tanzu config set env.TANZU_CLI_CLOUD_SERVICES_ORGANIZATION_ID ae93ebb4-a249-4553-aa1e-c87c4b7f75e5

❯ export TANZU_CLI_CLOUD_SERVICES_ORGANIZATION_ID=34561018-0a88-4029-a01a-4620c10cdce8

❯ ./bin/tanzu login --staging --endpoint https://api.tanzu-dev.cloud.vmware.com
[i] This tanzu context is being created using organization ID 34561018-0a88-4029-a01a-4620c10cdce8 as set in the TANZU_CLI_CLOUD_SERVICES_ORGANIZATION_ID environment variable.
[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=ygUm5C59_JNACa3hawZKdbNUA050j7c4zETLb0LIwW0&code_challenge_method=S256&orgId=34561018-0a88-4029-a01a-4620c10cdce8&redirect_uri=http%3A%2F%2F127.0.0.1%3A62027%2Fcallback&response_type=code&state=464f3abdf6421b3f2efd8e4fbcb5661f

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

[ok] Successfully logged into 'TAP staging' organization and created a tanzu context

❯ unset TANZU_CLI_CLOUD_SERVICES_ORGANIZATION_ID
❯ ./bin/tanzu login --staging --endpoint https://api.tanzu-dev.cloud.vmware.com
[i] This tanzu context is being created using organization ID ae93ebb4-a249-4553-aa1e-c87c4b7f75e5 as set in the tanzu configuration (to unset, use `tanzu config unset env.TANZU_CLI_CLOUD_SERVICES_ORGANIZATION_ID`).
[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=Yqzk6oGsLMLq6iKA7CU6SLmcSwcTGbX2SJ1jw-sea7c&code_challenge_method=S256&orgId=ae93ebb4-a249-4553-aa1e-c87c4b7f75e5&redirect_uri=http%3A%2F%2F127.0.0.1%3A62076%2Fcallback&response_type=code&state=d5b0bb2f796266c5d55641dc8c69f4b1

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

[ok] Successfully logged into 'TAP pre-integration' organization and created a tanzu context

❯ tanzu config unset env.TANZU_CLI_CLOUD_SERVICES_ORGANIZATION_ID
❯ ./bin/tanzu login --staging --endpoint https://api.tanzu-dev.cloud.vmware.com
[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=kKBDt6rFQ8b8CrjLi6lgtEOvZ9Sxpe-T4_b2Efdayak&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%3A62318%2Fcallback&response_type=code&state=370c4cb55463460b8bc440a671ddcd6e

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

[ok] Successfully logged into 'TAP staging' organization and created a tanzu context

Release note

Additional information

Special notes for your reviewer