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

Allow customizing the Tanzu Hub endpoint when creating tanzu context #782

Closed anujc25 closed 2 months ago

anujc25 commented 2 months ago

What this PR does / why we need it

Which issue(s) this PR fixes

Fixes #

Describe testing done for PR

Verify with tanzu login

$ tz login --tanzu-hub-endpoint https://api.be-tis.symphony-dev.com/hub
[i] Opening the browser window to complete the login
Log in by visiting this link:

    https://console.cloud.vmware.com/csp/gateway/discovery?client_id=tanzu-cli-client-id&code_challenge=pVnmvp7umB7r0cGI-cvnU6yT8GVwj8vINhw_ASevFtM&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%3A52346%2Fcallback&response_type=code&state=ff12de5be3480b15c797115d05380dd1

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

[!] This tanzu context is being created with the custom Tanzu Hub endpoint: "https://api.be-tis.symphony-dev.com/hub"

[ok] Successfully logged into 'Tanzu Platform for K8s SaaS - Internal 1' organization and created a tanzu context

----

$ tz context get Tanzu_Platform_for_K8s_SaaS_-_Internal_1
name: Tanzu_Platform_for_K8s_SaaS_-_Internal_1
target: tanzu
contextType: tanzu
...
additionalMetadata:
    tanzuClusterGroupName: ""
    tanzuHubEndpoint: https://api.be-tis.symphony-dev.com/hub
    tanzuMissionControlEndpoint: https://tmc.tanzu.cloud.vmware.com
    tanzuOrgID: 8406e52e-6e36-445a-be7b-9dab6903341e
    tanzuOrgName: Tanzu Platform for K8s SaaS - Internal 1
    tanzuProjectID: 0f49c031-6294-4bdf-b363-55ae96788402
    tanzuProjectName: longevity-project
    tanzuSpaceName: tshaine

Verify with tanzu context create:

$ tz context create TP-context-with-custom-hub-endpoint --type tanzu --tanzu-hub-endpoint https://api.be-tis.symphony-dev.com/hub
? Enter control plane endpoint https://api.tanzu.cloud.vmware.com
[i] Opening the browser window to complete the login
Log in by visiting this link:

    https://console.cloud.vmware.com/csp/gateway/discovery?client_id=tanzu-cli-client-id&code_challenge=YDlk-X3c7vgZc98K_VdSb9-OxS_os2bNZA4ADc1GEKo&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%3A52981%2Fcallback&response_type=code&state=e0d2bf13bc93e612d2b5b77d6ac4dd7e

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

[!] This tanzu context is being created with the custom Tanzu Hub endpoint: "https://api.be-tis.symphony-dev.com/hub"

[ok] Successfully logged into 'Tanzu Platform for K8s SaaS - Internal 1' organization and created a tanzu context

---

$ tz context get TP-context-with-custom-hub-endpoint
name: TP-context-with-custom-hub-endpoint
target: tanzu
contextType: tanzu
...
additionalMetadata:
    tanzuHubEndpoint: https://api.be-tis.symphony-dev.com/hub
    tanzuMissionControlEndpoint: https://tmc.tanzu.cloud.vmware.com
    tanzuOrgID: 8406e52e-6e36-445a-be7b-9dab6903341e
    tanzuOrgName: Tanzu Platform for K8s SaaS - Internal 1

Release note

None

Additional information

Special notes for your reviewer

vuil commented 2 months ago

can we add a test case for this in context_test.go?