diff --git a/config/contexts_test.go b/config/contexts_test.go index 12e3de3d6..95c6374a8 100644 --- a/config/contexts_test.go +++ b/config/contexts_test.go @@ -502,7 +502,8 @@ func setupForGetContext() error { Context: "test-context", }, AdditionalMetadata: map[string]interface{}{ - OrgIDKey: "fake-org-id", + OrgIDKey: "fake-org-id", + OrgNameKey: "fake-org-name", }, }, }, diff --git a/config/tanzu_context.go b/config/tanzu_context.go index dd0bd6607..f7e4d2ef0 100644 --- a/config/tanzu_context.go +++ b/config/tanzu_context.go @@ -39,6 +39,8 @@ const ( type ResourceInfo struct { // OrgID ID of the Organization OrgID string + // OrgName name of the Organization + OrgName string // ProjectName name of the Project ProjectName string // ProjectID ID of the Project. @@ -321,6 +323,7 @@ func GetTanzuContextActiveResource(contextName string) (*ResourceInfo, error) { } activeResourceInfo := &ResourceInfo{ OrgID: stringValue(ctx.AdditionalMetadata[OrgIDKey]), + OrgName: stringValue(ctx.AdditionalMetadata[OrgNameKey]), ProjectName: stringValue(ctx.AdditionalMetadata[ProjectNameKey]), ProjectID: stringValue(ctx.AdditionalMetadata[ProjectIDKey]), SpaceName: stringValue(ctx.AdditionalMetadata[SpaceNameKey]), diff --git a/config/tanzu_context_test.go b/config/tanzu_context_test.go index 4258024a4..3d4d77510 100644 --- a/config/tanzu_context_test.go +++ b/config/tanzu_context_test.go @@ -19,6 +19,7 @@ import ( const ( fakeOrgID = "fake-org-id" + fakeOrgName = "fake-org-name" fakeProjectName = "fake-project" fakeProjectID = "fake-project-id" fakeSpace = "fake-space" @@ -226,6 +227,7 @@ func TestGetTanzuContextActiveResource(t *testing.T) { activeResources, err := GetTanzuContextActiveResource("test-tanzu") assert.NoError(t, err) assert.Equal(t, activeResources.OrgID, fakeOrgID) + assert.Equal(t, activeResources.OrgName, fakeOrgName) assert.Empty(t, activeResources.ProjectName) assert.Empty(t, activeResources.ProjectID) assert.Empty(t, activeResources.SpaceName) @@ -239,6 +241,7 @@ func TestGetTanzuContextActiveResource(t *testing.T) { activeResources, err = GetTanzuContextActiveResource("test-tanzu") assert.NoError(t, err) assert.Equal(t, activeResources.OrgID, fakeOrgID) + assert.Equal(t, activeResources.OrgName, fakeOrgName) assert.Equal(t, activeResources.ProjectName, fakeProjectName) assert.Equal(t, activeResources.ProjectID, fakeProjectID) assert.Equal(t, activeResources.SpaceName, fakeSpace) @@ -254,6 +257,7 @@ func TestGetTanzuContextActiveResource(t *testing.T) { activeResources, err = GetTanzuContextActiveResource("test-tanzu") assert.NoError(t, err) assert.Equal(t, activeResources.OrgID, fakeOrgID) + assert.Equal(t, activeResources.OrgName, fakeOrgName) assert.Equal(t, activeResources.ProjectName, fakeProjectName) assert.Equal(t, activeResources.ProjectID, fakeProjectID) assert.Equal(t, activeResources.ClusterGroupName, fakeClusterGroupName)