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
35
stars
22
forks
source link
Update the tanzu login command to log in to TAP SaaS #715
This PR update the tanzu login command to log in to TAP SaaS platform
Changes Summary:
Refactor/update the existing deprecated tanzu login command to login to TAP SaaS
login command would create a context and user has to use tanzu context command to manage(delete/use) the context.
user can perform re-login and the context would be updated with the new tokens and kubeconfig would be re-generated( this would help users if they manully edit and mess-up the kube context associated with the context)
Which issue(s) this PR fixes
Fixes #
Login to production using tanzu login and was able to create a context. Also the tanzu project list and tanzu project use and tanzu space list working as expected.
❯ tanzu context list
NAME ISACTIVE TYPE PROJECT SPACE
mytmc-ctx true mission-control n/a n/a
prem-ucp-prod-test false tanzu sre-project test
tkg-mgmt-vc false kubernetes n/a n/a
tt-test-selfmg false mission-control n/a n/a
[i] Use '--wide' flag to view additional columns.
❯ ./bin/tanzu login
[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=EyFVCaDWz30XjyY2U-sam-KmccLSykyTBvF8kYjAgwg&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%3A50840%2Fcallback&response_type=code&state=a26639750fd0ced0be1d056f5033509b
Optionally, paste your authorization code: [...]
[ok] Successfully logged into 'TAP SAAS PRD' organization and created a tanzu context
[i] Checking for required plugins for context 'TAP_SAAS_PRD'...
[i] All required plugins are already installed and up-to-date
❯ ./bin/tanzu context list
NAME ISACTIVE TYPE PROJECT SPACE
TAP_SAAS_PRD true tanzu
mytmc-ctx true mission-control n/a n/a
prem-ucp-prod-test false tanzu sre-project test
tkg-mgmt-vc false kubernetes n/a n/a
tt-test-selfmg false mission-control n/a n/a
[i] Use '--wide' flag to view additional columns.
❯ ./bin/tanzu project list
Listing projects from bc6f01a5-8618-4fed-a457-161d3a138052 org
NAME ACTIVE AGE
default false 11d
sre-project false 11d
e2e false 10d
beta2-prod-validation false 9d
project-tap-saas-tap-ci-prod-gql-103 false 7d6h
e2e-sre false 7d10h
wjimenez false 5d19h
e2e-project false 5d11h
vpaul false 5d5h
mfine false 5d3h
scorsonea false 4d3h
beta2-fix-validation false 3d4h
pedersenju-project false 27h
ramanav-e2-validation false 27h
dwyer false 26h
pete-project false 23h
nebhale false 20h
project-tap-saas-prod-gql-153 false 15h
ksedky-project-3 false 13h
project-tap-saas-prod-gql-1 false 12h
project-tap-saas-prod-gql-4 false 9h
project-tap-saas-prod-gql-5 false 9h
project-tap-saas-prod-gql-6 false 9h
project-tap-saas-prod-gql-7 false 8h
fabio-b2-prod2 false 6h18m
project-tap-saas-prod-gql-8 false 6h10m
project-tap-saas-prod-gql-9 false 152m
🔎 To set your active project use 'tanzu project use NAME'
❯ ./bin/tanzu project use sre-project
✓ Successfully set project to sre-project
❯ ./bin/tanzu space list
Listing spaces from bc6f01a5-8618-4fed-a457-161d3a138052 org, current context is sre-project project
NAME READY PROFILES RESOLVED REPLICAS AGE ACTIVE
test True 0/0 0/0 4d4h false
🔎 For more details use 'tanzu space get NAME'
With the current active resource of tanzu context set to project, did a re-login to verify the users current context is handled gracefully. The login was successful and the kubeconfig(pointing to the project resource) and context active resources are set in tact.
❯ #relogin with current tanzu context set to project resource
❯ ./bin/tanzu login
[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=YHR64ndYI0s_p21zIY9eB3p2pAKHwBenpRyxdCYcmt8&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%3A50892%2Fcallback&response_type=code&state=6a81cf3e14fd5f56b3f1db954bcf2a8c
Optionally, paste your authorization code: [...]
[ok] Successfully logged into 'TAP SAAS PRD' organization and created a tanzu context
[i] Checking for required plugins for context 'TAP_SAAS_PRD'...
[i] All required plugins are already installed and up-to-date
❯ ./bin/tanzu context list
NAME ISACTIVE TYPE PROJECT SPACE
TAP_SAAS_PRD true tanzu sre-project
mytmc-ctx true mission-control n/a n/a
prem-ucp-prod-test false tanzu sre-project test
tkg-mgmt-vc false kubernetes n/a n/a
tt-test-selfmg false mission-control n/a n/a
[i] Use '--wide' flag to view additional columns.
❯ ./bin/tanzu space list
Listing spaces from bc6f01a5-8618-4fed-a457-161d3a138052 org, current context is sre-project project
NAME READY PROFILES RESOLVED REPLICAS AGE ACTIVE
test True 0/0 0/0 4d4h false
🔎 For more details use 'tanzu space get NAME'
Removed the kube context related to the tanzu context from the kubeconfig file and did re-login. The login was success and kubeconfig is generated again.
❯ #remove the kube context related to tanzu context from the kubeconfig file and relogin. It should regenerate the kubeconfig again
❯ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
gke_developer-framework-team_us-central1-c_downstream-adhol gke_developer-framework-team_us-central1-c_downstream-adhol gke_developer-framework-team_us-central1-c_downstream-adhol
gke_kshaheer-playground_us-east4_tap-sc gke_kshaheer-playground_us-east4_tap-sc gke_kshaheer-playground_us-east4_tap-sc
kind-ucp kind-ucp kind-ucp
* tanzu-cli-TAP_SAAS_PRD tanzu-cli-TAP_SAAS_PRD/current tanzu-cli-TAP_SAAS_PRD-user
tanzu-cli-prem-ucp-prod-test tanzu-cli-prem-ucp-prod-test/current tanzu-cli-prem-ucp-prod-test-user
❯ kubectl config delete-context tanzu-cli-TAP_SAAS_PRD
warning: this removed your active context, use "kubectl config use-context" to select a different one
deleted context tanzu-cli-TAP_SAAS_PRD from /Users/pkalle/.kube/config
❯ ./bin/tanzu login
[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=stDi8o_EzoU133jSb-z19U_JIpmDe4XJ_i1TpSNt8_M&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%3A50923%2Fcallback&response_type=code&state=da5f4c6291979ae1a11b0383daf92aa9
Optionally, paste your authorization code: [...]
[ok] Successfully logged into 'TAP SAAS PRD' organization and created a tanzu context
[i] Checking for required plugins for context 'TAP_SAAS_PRD'...
[i] All required plugins are already installed and up-to-date
❯ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
gke_developer-framework-team_us-central1-c_downstream-adhol gke_developer-framework-team_us-central1-c_downstream-adhol gke_developer-framework-team_us-central1-c_downstream-adhol
gke_kshaheer-playground_us-east4_tap-sc gke_kshaheer-playground_us-east4_tap-sc gke_kshaheer-playground_us-east4_tap-sc
kind-ucp kind-ucp kind-ucp
* tanzu-cli-TAP_SAAS_PRD tanzu-cli-TAP_SAAS_PRD/current tanzu-cli-TAP_SAAS_PRD-user
tanzu-cli-prem-ucp-prod-test tanzu-cli-prem-ucp-prod-test/current tanzu-cli-prem-ucp-prod-test-user
❯ ./bin/tanzu space list
Listing spaces from bc6f01a5-8618-4fed-a457-161d3a138052 org, current context is sre-project project
NAME READY PROFILES RESOLVED REPLICAS AGE ACTIVE
test True 0/0 0/0 4d5h false
🔎 For more details use 'tanzu space get NAME'
tanzu context was set to space and did re-login. The login was successful and the context active resource was kept in tact( honoured the users existing context setting).
❯ ./bin/tanzu space use test
✓ Successfully set space to test
❯ ./bin/tanzu context list
NAME ISACTIVE TYPE PROJECT SPACE
TAP_SAAS_PRD true tanzu sre-project test
mytmc-ctx true mission-control n/a n/a
prem-ucp-prod-test false tanzu sre-project test
tkg-mgmt-vc false kubernetes n/a n/a
tt-test-selfmg false mission-control n/a n/a
[i] Use '--wide' flag to view additional columns.
❯ ./bin/tanzu space profile list
No Profiles found.
❯ ./bin/tanzu login
[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=OU2ns4qrpg0epDlGrlcVXDIY2OW4TjtZeFFp_iNaEnY&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%3A51021%2Fcallback&response_type=code&state=9bf887893e67036ec145fa4994271384
Optionally, paste your authorization code: [...]
[ok] Successfully logged into 'TAP SAAS PRD' organization and created a tanzu context
[i] Checking for required plugins for context 'TAP_SAAS_PRD'...
[i] All required plugins are already installed and up-to-date
❯ ./bin/tanzu space profile list
No Profiles found.
Logged in to staging env. It was successful and the context name was appended with -staging and hash string of the endpoint.
❯ ./bin/tanzu login --endpoint https://test-project-syncer.stacks.bluesky.tmc-dev.cloud.vmware.com --staging
[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=jPOXWt55goqrlP0nP7lhD1JrJ-YjxRc-82FqEvY6X4c&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%3A51259%2Fcallback&response_type=code&state=3eb6596263a5ce56ba5f6dd231a0ab2e
Optionally, paste your authorization code: [...]
[ok] Successfully logged into 'TestProjectSyncer' organization and created a tanzu context
[i] Checking for required plugins for context 'TestProjectSyncer-staging-3d4f75b3'...
[i] All required plugins are already installed and up-to-date
❯ ./bin/tanzu context list
NAME ISACTIVE TYPE PROJECT SPACE
TAP_SAAS_PRD false tanzu sre-project test
TestProjectSyncer-staging-3d4f75b3 true tanzu
mytmc-ctx true mission-control n/a n/a
prem-ucp-prod-test false tanzu sre-project test
tkg-mgmt-vc false kubernetes n/a n/a
tt-test-selfmg false mission-control n/a n/a
[i] Use '--wide' flag to view additional columns.
❯ ./bin/tanzu project list
Listing projects from dcd7e146-57e6-4a1b-905c-0d4079dc9f38 org
NAME ACTIVE AGE
9ba6ba75-9782-48a2-ae3b-eaa11c6e5316 false 35h
3351bd40-5150-46f7-96c5-d368b5f99932 false 29h
fd72b29b-bd90-40a6-a684-3e78de397028 false 29h
default false 13h
🔎 To set your active project use 'tanzu project use NAME'
Describe testing done for PR
Release note
Repurpose the deprecated tanzu login command to log in to TAP SaaS
What this PR does / why we need it
This PR update the tanzu login command to log in to TAP SaaS platform
Changes Summary:
tanzu context
command to manage(delete/use) the context.Which issue(s) this PR fixes
Fixes #
Login to production using
tanzu login
and was able to create a context. Also thetanzu project list
andtanzu project use
andtanzu space list
working as expected.With the current active resource of tanzu context set to
project
, did a re-login to verify the users current context is handled gracefully. The login was successful and the kubeconfig(pointing to the project resource) and context active resources are set in tact.Removed the kube context related to the tanzu context from the kubeconfig file and did re-login. The login was success and kubeconfig is generated again.
tanzu context was set to space and did re-login. The login was successful and the context active resource was kept in tact( honoured the users existing context setting).
Logged in to staging env. It was successful and the context name was appended with
-staging
and hash string of the endpoint.Describe testing done for PR
Release note
Additional information
Special notes for your reviewer