Skip to content

Commit 1ec1a85

Browse files
authored
Use the same env key(bluemix-go) for global catalog and fix the path (IBM-Cloud#6217)
1 parent b50e5db commit 1ec1a85

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

ibm/conns/config.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"log"
1414
"net"
1515
gohttp "net/http"
16+
"net/url"
1617
"os"
1718
"strings"
1819
"time"
@@ -3649,19 +3650,26 @@ func (c *Config) ClientSession() (interface{}, error) {
36493650

36503651
// CATALOG MANAGEMENT Service
36513652
globalcatalogURL := globalcatalogv1.DefaultServiceURL
3652-
if c.Visibility == "private" {
3653-
if c.Region == "us-south" || c.Region == "us-east" {
3654-
rmURL = ContructEndpoint(fmt.Sprintf("private.%s.globalcatalog/api/v1", c.Region), fmt.Sprintf("%s", cloudEndpoint))
3655-
} else {
3656-
fmt.Println("Private Endpoint supports only us-south and us-east region specific endpoint")
3657-
rmURL = ContructEndpoint("private.us-south.globalcatalog/api/v1", fmt.Sprintf("%s", cloudEndpoint))
3658-
}
3653+
if c.Visibility == "private" || c.Visibility == "public-and-private" {
3654+
globalcatalogURL = ContructEndpoint("private.globalcatalog", cloudEndpoint)
36593655
}
36603656
if fileMap != nil && c.Visibility != "public-and-private" {
3661-
catalogManagementURL = fileFallBack(fileMap, c.Visibility, "IBMCLOUD_GLOBAL_CATALOG_API_ENDPOINT", c.Region, catalogManagementURL)
3657+
globalcatalogURL = fileFallBack(fileMap, c.Visibility, "IBMCLOUD_RESOURCE_CATALOG_API_ENDPOINT", c.Region, globalcatalogURL)
3658+
}
3659+
gurl := EnvFallBack([]string{"IBMCLOUD_RESOURCE_CATALOG_API_ENDPOINT"}, globalcatalogURL)
3660+
parsedURL, err := url.Parse(gurl)
3661+
if err != nil {
3662+
fmt.Println("Error parsing global catalog url:", err)
3663+
}
3664+
if parsedURL.Path == "" {
3665+
globalURL, err := url.Parse(globalcatalogv1.DefaultServiceURL)
3666+
if err != nil {
3667+
fmt.Println("Error parsing global catalog default url:", err)
3668+
}
3669+
gurl = gurl + globalURL.Path
36623670
}
36633671
globalCatalogClientOptions := &globalcatalogv1.GlobalCatalogV1Options{
3664-
URL: EnvFallBack([]string{"IBMCLOUD_GLOBAL_CATALOG_API_ENDPOINT"}, globalcatalogURL),
3672+
URL: gurl,
36653673
Authenticator: authenticator,
36663674
}
36673675
// Construct the service client.

0 commit comments

Comments
 (0)