Skip to content

Commit

Permalink
Configure tanzuHubEndpoint as part of updateTanzuContextMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
anujc25 committed May 1, 2024
1 parent 515f859 commit 47752df
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/command/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,6 @@ func globalTanzuLogin(c *configtypes.Context, generateContextNameFunc func(orgNa
tanzuHubEndpoint, err := csp.GetTanzuHubEndpointForTAP(claims.OrgID, c.GlobalOpts.Auth.AccessToken, staging)
if err != nil {
log.V(7).Infof("unable to get Tanzu Hub endpoint. Error: %v", err.Error())
} else {
c.AdditionalMetadata[config.TanzuHubEndpointKey] = tanzuHubEndpoint
}

// update the context name using the context name generator
Expand All @@ -667,7 +665,7 @@ func globalTanzuLogin(c *configtypes.Context, generateContextNameFunc func(orgNa
}

// update the context metadata
if err := updateTanzuContextMetadata(c, claims.OrgID, orgName); err != nil {
if err := updateTanzuContextMetadata(c, claims.OrgID, orgName, tanzuHubEndpoint); err != nil {
return err
}

Expand Down Expand Up @@ -711,14 +709,15 @@ the Tanzu Application Platform service. Please ensure correct organization authe
}

// updateTanzuContextMetadata updates the context additional metadata
func updateTanzuContextMetadata(c *configtypes.Context, orgID, orgName string) error {
func updateTanzuContextMetadata(c *configtypes.Context, orgID, orgName, tanzuHubEndpoint string) error {
exists, err := config.ContextExists(c.Name)
if err != nil {
return err
}
if !exists {
c.AdditionalMetadata[config.OrgIDKey] = orgID
c.AdditionalMetadata[config.OrgNameKey] = orgName
c.AdditionalMetadata[config.TanzuHubEndpointKey] = tanzuHubEndpoint
return nil
}
// This is possible only for contexts created using "tanzu login" command because
Expand All @@ -730,6 +729,7 @@ func updateTanzuContextMetadata(c *configtypes.Context, orgID, orgName string) e
// If the context exists with the same name, honor the users current context additional metadata
// which includes the org/project/space details.
c.AdditionalMetadata = existingContext.AdditionalMetadata
c.AdditionalMetadata[config.TanzuHubEndpointKey] = tanzuHubEndpoint

return nil
}
Expand Down

0 comments on commit 47752df

Please sign in to comment.