diff --git a/TestRandomCode/main.go b/TestRandomCode/main.go new file mode 100644 index 0000000000..e6428d976b --- /dev/null +++ b/TestRandomCode/main.go @@ -0,0 +1,41 @@ +package main + +import "fmt" + +var cloudEndpoint = "cloud.ibm.com" + +func main() { + var visibility, region string + region = "us-south" + visibility = "private" + fmt.Println("Hello") + globalTaggingEndpoint := "https://tags.global-search-tagging.cloud.ibm.com" + if visibility == "private" || visibility == "public-and-private" { + var globalTaggingRegion string + if region != "us-south" && region != "us-east" { + globalTaggingRegion = "us-south" + } else { + globalTaggingRegion = region + } + globalTaggingEndpoint = ContructEndpoint(fmt.Sprintf("tags.private.%s", globalTaggingRegion), fmt.Sprintf("global-search-tagging.%s", cloudEndpoint)) + } + fmt.Println(globalTaggingEndpoint) + // if fileMap != nil && visibility != "public-and-private" { + // globalTaggingEndpoint = fileFallBack(fileMap, visibility, "IBMCLOUD_GT_API_ENDPOINT", region, globalTaggingEndpoint) + // } +} +func ContructEndpoint(subdomain, domain string) string { + endpoint := fmt.Sprintf("https://%s.%s", subdomain, domain) + return endpoint +} + +func fileFallBack(fileMap map[string]interface{}, visibility, key, region, defaultValue string) string { + if val, ok := fileMap[key]; ok { + if v, ok := val.(map[string]interface{})[visibility]; ok { + if r, ok := v.(map[string]interface{})[region]; ok && r.(string) != "" { + return r.(string) + } + } + } + return defaultValue +} diff --git a/ibm/conns/config.go b/ibm/conns/config.go index 3931be130d..78d71547ce 100644 --- a/ibm/conns/config.go +++ b/ibm/conns/config.go @@ -2136,13 +2136,7 @@ func (c *Config) ClientSession() (interface{}, error) { // GLOBAL TAGGING Service globalTaggingEndpoint := "https://tags.global-search-tagging.cloud.ibm.com" if c.Visibility == "private" || c.Visibility == "public-and-private" { - var globalTaggingRegion string - if c.Region != "us-south" && c.Region != "us-east" { - globalTaggingRegion = "us-south" - } else { - globalTaggingRegion = c.Region - } - globalTaggingEndpoint = ContructEndpoint(fmt.Sprintf("tags.private.%s", globalTaggingRegion), fmt.Sprintf("global-search-tagging.%s", cloudEndpoint)) + globalTaggingEndpoint = ContructEndpoint("tags.private.", fmt.Sprintf("global-search-tagging.%s", cloudEndpoint)) } if fileMap != nil && c.Visibility != "public-and-private" { globalTaggingEndpoint = fileFallBack(fileMap, c.Visibility, "IBMCLOUD_GT_API_ENDPOINT", c.Region, globalTaggingEndpoint) @@ -2165,13 +2159,7 @@ func (c *Config) ClientSession() (interface{}, error) { // GLOBAL TAGGING Service globalSearchEndpoint := "https://api.global-search-tagging.cloud.ibm.com" if c.Visibility == "private" || c.Visibility == "public-and-private" { - var globalSearchRegion string - if c.Region != "us-south" && c.Region != "au-syd" && c.Region != "eu-gb" { - globalSearchRegion = "us-south" - } else { - globalSearchRegion = c.Region - } - globalSearchEndpoint = ContructEndpoint(fmt.Sprintf("api.private.%s", globalSearchRegion), fmt.Sprintf("global-search-tagging.%s", cloudEndpoint)) + globalSearchEndpoint = ContructEndpoint("api.private.", fmt.Sprintf("global-search-tagging.%s", cloudEndpoint)) } if fileMap != nil && c.Visibility != "public-and-private" { globalSearchEndpoint = fileFallBack(fileMap, c.Visibility, "IBMCLOUD_GS_API_ENDPOINT", c.Region, searchv2.DefaultServiceURL)