Skip to content

Commit 012b18c

Browse files
committed
Enable customization of org id and name when connecting to uaa-based endpoint
Also: update the ucp url to the correct one for uaa-based endpoints Signed-off-by: Vui Lam <[email protected]>
1 parent 48d2e12 commit 012b18c

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

pkg/command/context.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,23 @@ func globalTanzuLoginUAA(c *configtypes.Context, generateContextNameFunc func(or
656656
return err
657657
}
658658

659-
// UAA-based authentication does not provide org id or name yet
660-
orgName := ""
659+
// UAA-based authentication does not provide org id or name yet.
660+
// Note: org id/name may be discoverable in UAA-based auth in the future.
661+
var orgID string
662+
orgName := "self-managed"
663+
uaaOrgIDValue, ok := os.LookupEnv(constants.UAALoginOrgID)
664+
if ok {
665+
orgID = uaaOrgIDValue
666+
}
667+
claims.OrgID = orgID
668+
uaaOrgNameValue, ok := os.LookupEnv(constants.UAALoginOrgName)
669+
if ok {
670+
orgName = uaaOrgNameValue
671+
} else {
672+
if orgID != "" {
673+
orgName = orgID
674+
}
675+
}
661676

662677
if err := updateContextOnTanzuLogin(c, generateContextNameFunc, claims, orgName); err != nil {
663678
return err

pkg/command/context_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ var _ = Describe("create new context", func() {
942942
fakeTanzuEndpoint = "https://fake.tanzu.cloud.vmware.com"
943943
fakeAlternateTanzuEndpoint = "https://fake.acme.com"
944944
expectedAlternateTanzuHubEndpoint = "https://fake.acme.com/hub"
945-
expectedAlternateTanzuUCPEndpoint = "https://fake.acme.com/ucp"
945+
expectedAlternateTanzuUCPEndpoint = "https://fake.acme.com"
946946
expectedAlternateTanzuTMCEndpoint = "https://fake.acme.com"
947947

948948
expectedTanzuHubEndpoint = "https://api.fake.tanzu.cloud.vmware.com/hub"
@@ -1156,7 +1156,6 @@ var _ = Describe("create new context", func() {
11561156
Expect(string(idpType)).To(ContainSubstring("uaa"))
11571157
})
11581158
})
1159-
11601159
Context("context name already exists", func() {
11611160
It("should return error", func() {
11621161
endpoint = fakeTanzuEndpoint

pkg/command/login_helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func configureTanzuPlatformServiceEndpointsForSM(tpEndpoint string) error {
9595

9696
tanzuHubEndpoint = fmt.Sprintf("%s://%s/hub", u.Scheme, u.Host)
9797
tanzuTMCEndpoint = fmt.Sprintf("%s://%s", u.Scheme, u.Host)
98-
tanzuUCPEndpoint = fmt.Sprintf("%s://%s/ucp", u.Scheme, u.Host)
98+
tanzuUCPEndpoint = fmt.Sprintf("%s://%s", u.Scheme, u.Host)
9999
tanzuAuthEndpoint = fmt.Sprintf("%s://%s/auth", u.Scheme, u.Host)
100100

101101
return nil

pkg/constants/env_variables.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ const (
5858
// https://docs.vmware.com/en/VMware-Cloud-services/services/Using-VMware-Cloud-Services/GUID-CF9E9318-B811-48CF-8499-9419997DC1F8.html
5959
CSPLoginOrgID = "TANZU_CLI_CLOUD_SERVICES_ORGANIZATION_ID"
6060

61+
// UaaLoginOrgID overrides OrgID associated with the UAA based endpoint
62+
// This may not be necessary or could be discoverable in the future, at which point this will be ignored.
63+
UAALoginOrgID = "TANZU_CLI_SM_ORGANIZATION_ID"
64+
65+
// UaaLoginOrgName overrides name of the Org associated with the UAA based endpoint
66+
// This may not be necessary or could be discoverable in the future, at which point this will be ignored.
67+
UAALoginOrgName = "TANZU_CLI_SM_ORGANIZATION_NAME"
68+
6169
// TanzuCLIOAuthLocalListenerPort is the port to be used by local listener for OAuth authorization flow
6270
TanzuCLIOAuthLocalListenerPort = "TANZU_CLI_OAUTH_LOCAL_LISTENER_PORT"
6371

0 commit comments

Comments
 (0)