@@ -2,6 +2,7 @@ package logs
22
33import (
44 "fmt"
5+ "log"
56 "os"
67 "strings"
78
@@ -51,20 +52,34 @@ func getClientWithLogsInstanceEndpoint(originalClient *logsv0.LogsV0, instanceId
5152 if strings .Contains (os .Getenv ("IBMCLOUD_IAM_API_ENDPOINT" ), "test" ) {
5253 domain = testCloudEndpoint
5354 }
55+ // getting originalConfigServiceURL to not miss filemap precedence from the url constructed in config.go file
56+ originalConfigServiceURL := originalClient .GetServiceURL ()
57+
58+ log .Printf ("Service URL from the config.go file %s" , originalConfigServiceURL )
59+
5460 var endpoint string
5561 if endpointType == "private" {
56- endpoint = fmt .Sprintf ("https://%s.api.private.%s.logs.%s" , instanceId , region , domain )
62+ if strings .Contains (originalConfigServiceURL , fmt .Sprintf ("https://%s.api.private.%s.logs.%s" , instanceId , region , domain )) {
63+ endpoint = originalConfigServiceURL
64+ } else {
65+ endpoint = fmt .Sprintf ("https://%s.api.private.%s.logs.%s:3443" , instanceId , region , domain )
66+ }
5767 } else {
58- endpoint = fmt .Sprintf ("https://%s.api.%s.logs.%s" , instanceId , region , domain )
68+ if strings .Contains (originalConfigServiceURL , fmt .Sprintf ("https://%s.api.%s.logs.%s" , instanceId , region , domain )) {
69+ endpoint = originalConfigServiceURL
70+ } else {
71+ endpoint = fmt .Sprintf ("https://%s.api.%s.logs.%s" , instanceId , region , domain )
72+ }
5973 }
60-
6174 // clone the client and set endpoint
6275 newClient := & logsv0.LogsV0 {
6376 Service : originalClient .Service .Clone (),
6477 }
6578
6679 endpoint = conns .EnvFallBack ([]string {"IBMCLOUD_LOGS_API_ENDPOINT" }, endpoint )
6780
81+ log .Printf ("Constructing client with new service URL %s" , endpoint )
82+
6883 newClient .Service .SetServiceURL (endpoint )
6984
7085 return newClient
0 commit comments