diff --git a/pkg/command/context.go b/pkg/command/context.go index f7beff9f4..498353b81 100644 --- a/pkg/command/context.go +++ b/pkg/command/context.go @@ -656,8 +656,21 @@ func globalTanzuLoginUAA(c *configtypes.Context, generateContextNameFunc func(or return err } - // UAA-based authentication does not provide org id or name yet - orgName := "" + // UAA-based authentication does not provide org id or name yet. + // Note: org id/name may be discoverable in UAA-based auth in the future. + var orgID string + orgName := "self-managed" + uaaOrgIDValue, ok := os.LookupEnv(constants.UAALoginOrgID) + if ok { + orgID = uaaOrgIDValue + } + claims.OrgID = orgID + uaaOrgNameValue, ok := os.LookupEnv(constants.UAALoginOrgName) + if ok { + orgName = uaaOrgNameValue + } else if orgID != "" { + orgName = orgID + } if err := updateContextOnTanzuLogin(c, generateContextNameFunc, claims, orgName); err != nil { return err diff --git a/pkg/command/context_test.go b/pkg/command/context_test.go index 64fedb9f1..47cdc2145 100644 --- a/pkg/command/context_test.go +++ b/pkg/command/context_test.go @@ -942,7 +942,7 @@ var _ = Describe("create new context", func() { fakeTanzuEndpoint = "https://fake.tanzu.cloud.vmware.com" fakeAlternateTanzuEndpoint = "https://fake.acme.com" expectedAlternateTanzuHubEndpoint = "https://fake.acme.com/hub" - expectedAlternateTanzuUCPEndpoint = "https://fake.acme.com/ucp" + expectedAlternateTanzuUCPEndpoint = "https://fake.acme.com" expectedAlternateTanzuTMCEndpoint = "https://fake.acme.com" expectedTanzuHubEndpoint = "https://api.fake.tanzu.cloud.vmware.com/hub" @@ -1156,7 +1156,6 @@ var _ = Describe("create new context", func() { Expect(string(idpType)).To(ContainSubstring("uaa")) }) }) - Context("context name already exists", func() { It("should return error", func() { endpoint = fakeTanzuEndpoint diff --git a/pkg/command/login_helper.go b/pkg/command/login_helper.go index 6fcd7dd4d..f6c6ece86 100644 --- a/pkg/command/login_helper.go +++ b/pkg/command/login_helper.go @@ -95,7 +95,7 @@ func configureTanzuPlatformServiceEndpointsForSM(tpEndpoint string) error { tanzuHubEndpoint = fmt.Sprintf("%s://%s/hub", u.Scheme, u.Host) tanzuTMCEndpoint = fmt.Sprintf("%s://%s", u.Scheme, u.Host) - tanzuUCPEndpoint = fmt.Sprintf("%s://%s/ucp", u.Scheme, u.Host) + tanzuUCPEndpoint = fmt.Sprintf("%s://%s", u.Scheme, u.Host) tanzuAuthEndpoint = fmt.Sprintf("%s://%s/auth", u.Scheme, u.Host) return nil diff --git a/pkg/constants/env_variables.go b/pkg/constants/env_variables.go index 956320c6e..43baa9df1 100644 --- a/pkg/constants/env_variables.go +++ b/pkg/constants/env_variables.go @@ -58,6 +58,14 @@ const ( // https://docs.vmware.com/en/VMware-Cloud-services/services/Using-VMware-Cloud-Services/GUID-CF9E9318-B811-48CF-8499-9419997DC1F8.html CSPLoginOrgID = "TANZU_CLI_CLOUD_SERVICES_ORGANIZATION_ID" + // UaaLoginOrgID overrides OrgID associated with the UAA based endpoint + // This may not be necessary or could be discoverable in the future, at which point this will be ignored. + UAALoginOrgID = "TANZU_CLI_SM_ORGANIZATION_ID" + + // UaaLoginOrgName overrides name of the Org associated with the UAA based endpoint + // This may not be necessary or could be discoverable in the future, at which point this will be ignored. + UAALoginOrgName = "TANZU_CLI_SM_ORGANIZATION_NAME" + // TanzuCLIOAuthLocalListenerPort is the port to be used by local listener for OAuth authorization flow TanzuCLIOAuthLocalListenerPort = "TANZU_CLI_OAUTH_LOCAL_LISTENER_PORT"