Skip to content

Commit aa987bd

Browse files
kavya498hkantare
authored andcommitted
support CSE and filemap for cloud logs
1 parent d6375c4 commit aa987bd

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

ibm/conns/config.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,16 +1683,15 @@ func (c *Config) ClientSession() (interface{}, error) {
16831683
// Construct an "options" struct for creating the service client.
16841684
logsEndpoint := ContructEndpoint(fmt.Sprintf("api.%s.logs", c.Region), cloudEndpoint)
16851685

1686-
if fileMap != nil && c.Visibility != "public-and-private" {
1687-
logsEndpoint = fileFallBack(fileMap, c.Visibility, "IBMCLOUD_LOGS_API_ENDPOINT", c.Region, logsEndpoint)
1688-
}
16891686
if c.Visibility == "private" || c.Visibility == "public-and-private" {
16901687
logsEndpoint = ContructEndpoint(fmt.Sprintf("api.private.%s.logs", c.Region), cloudEndpoint)
16911688
}
1692-
1689+
if fileMap != nil && c.Visibility != "public-and-private" {
1690+
logsEndpoint = fileFallBack(fileMap, c.Visibility, "IBMCLOUD_LOGS_API_ENDPOINT", c.Region, logsEndpoint)
1691+
}
16931692
logsClientOptions := &logsv0.LogsV0Options{
16941693
Authenticator: authenticator,
1695-
URL: logsEndpoint,
1694+
URL: EnvFallBack([]string{"IBMCLOUD_LOGS_API_ENDPOINT"}, logsEndpoint),
16961695
}
16971696

16981697
// Construct the service client.

ibm/service/logs/utils.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package logs
22

33
import (
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

website/docs/guides/custom-service-endpoints.html.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ provider "ibm" {
5555
|Cloud Shell|IBMCLOUD_CLOUD_SHELL_API_ENDPOINT|
5656
|Compilance (Posture Management)|IBMCLOUD_COMPLIANCE_API_ENDPOINT|
5757
|Container Registry|IBMCLOUD_CR_API_ENDPOINT|
58+
|Cloud Logs | IBMCLOUD_LOGS_API_ENDPOINT |
5859
|Kubernetes Service|IBMCLOUD_CS_API_ENDPOINT|
5960
|Metrics Router| IBMCLOUD_METRICS_ROUTING_API_ENDPOINT|
6061
|MQ on Cloud| IBMCLOUD_MQCLOUD_CONFIG_ENDPOINT|

0 commit comments

Comments
 (0)