-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed the region variable from tagging and search private api const…
…ruction
- Loading branch information
1 parent
d841442
commit 8e5251c
Showing
2 changed files
with
43 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters