Skip to content

Commit

Permalink
Patch COS Bucket data source for test env endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
cjschaef committed Oct 2, 2024
1 parent a4423c9 commit 31ae4aa
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions ibm/service/cos/data_source_ibm_cos_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,10 +811,18 @@ func dataSourceIBMCosBucketRead(d *schema.ResourceData, meta interface{}) error
bucketCRN := fmt.Sprintf("%s:%s:%s", strings.Replace(serviceID, "::", "", -1), "bucket", bucketName)
d.Set("crn", bucketCRN)
d.Set("resource_instance_id", serviceID)
apiEndpoint, apiEndpointPrivate, directApiEndpoint = SelectCosApi(bucketLocationConvert(bucketType), bucketRegion, strings.Contains(apiEndpoint, "test"))
d.Set("s3_endpoint_public", apiEndpoint)
d.Set("s3_endpoint_private", apiEndpointPrivate)
d.Set("s3_endpoint_direct", directApiEndpoint)

testEnv := strings.Contains(apiEndpoint, ".test.")
apiEndpointPublic, apiEndpointPrivate, directApiEndpoint := SelectCosApi(bucketLocationConvert(bucketType), bucketRegion, testEnv)

if testEnv {
d.Set(fmt.Sprintf("s3_endpoint_%s", endpointType), apiEndpoint)
} else {
d.Set("s3_endpoint_public", apiEndpointPublic)
d.Set("s3_endpoint_private", apiEndpointPrivate)
d.Set("s3_endpoint_direct", directApiEndpoint)
}

sess, err := meta.(conns.ClientSession).CosConfigV1API()
if err != nil {
return err
Expand Down

0 comments on commit 31ae4aa

Please sign in to comment.