Skip to content

Commit 367e46b

Browse files
ravinitpjotruon
authored andcommitted
Added support for realm specific service endpoints
1 parent 392af96 commit 367e46b

File tree

6 files changed

+60
-28
lines changed

6 files changed

+60
-28
lines changed

examples/apm/apm_domains/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ data "oci_apm_data_keys" "test_data_keys" {
7171

7272
#Optional
7373
data_key_type = var.data_key_data_key_type
74-
}
74+
}

examples/object_storage/bucket_with_replication/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,3 @@ resource "oci_objectstorage_replication_policy" "bucket_rp" {
129129
destination_region_name = var.region
130130
destination_bucket_name = oci_objectstorage_bucket.bucket2.name
131131
}
132-

internal/client/provider_clients.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ package client
55

66
import (
77
"fmt"
8+
"github.com/oracle/oci-go-sdk/v65/common"
9+
"github.com/oracle/terraform-provider-oci/internal/tfresource"
10+
"strconv"
811
"strings"
912

1013
oci_identity_domains "github.com/oracle/oci-go-sdk/v65/identitydomains"
@@ -160,3 +163,17 @@ func CreateSDKClients(clients *OracleClients, configProvider oci_common.Configur
160163

161164
return
162165
}
166+
func setCustomConfiguration(oClient interface {
167+
SetCustomClientConfiguration(config common.CustomClientConfiguration)
168+
}) error {
169+
if tfresource.RealmSpecificServiceEndpointTemplateEnabled != "" {
170+
value, err := strconv.ParseBool(tfresource.RealmSpecificServiceEndpointTemplateEnabled)
171+
if err != nil {
172+
return err
173+
}
174+
oClient.SetCustomClientConfiguration(oci_common.CustomClientConfiguration{
175+
RealmSpecificServiceEndpointTemplateEnabled: oci_common.Bool(value),
176+
})
177+
}
178+
return nil
179+
}

internal/globalvar/constants.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,22 @@ const (
2727
AcceptLocalCerts = "accept_local_certs"
2828
JobOCID = "job-ocid"
2929

30-
AuthAttrName = "auth"
31-
TenancyOcidAttrName = "tenancy_ocid"
32-
BoatTenancyOcidAttrName = "boat_tenancy_ocid"
33-
UserOcidAttrName = "user_ocid"
34-
FingerprintAttrName = "fingerprint"
35-
PrivateKeyAttrName = "private_key"
36-
PrivateKeyPathAttrName = "private_key_path"
37-
PrivateKeyPasswordAttrName = "private_key_password"
38-
RegionAttrName = "region"
39-
DisableAutoRetriesAttrName = "disable_auto_retries"
40-
RetryDurationSecondsAttrName = "retry_duration_seconds"
41-
OboTokenAttrName = "obo_token"
42-
OboTokenPath = "obo_token_path"
43-
ConfigFileProfileAttrName = "config_file_profile"
44-
DefinedTagsToIgnore = "ignore_defined_tags"
30+
AuthAttrName = "auth"
31+
TenancyOcidAttrName = "tenancy_ocid"
32+
BoatTenancyOcidAttrName = "boat_tenancy_ocid"
33+
UserOcidAttrName = "user_ocid"
34+
FingerprintAttrName = "fingerprint"
35+
PrivateKeyAttrName = "private_key"
36+
PrivateKeyPathAttrName = "private_key_path"
37+
PrivateKeyPasswordAttrName = "private_key_password"
38+
RegionAttrName = "region"
39+
DisableAutoRetriesAttrName = "disable_auto_retries"
40+
RetryDurationSecondsAttrName = "retry_duration_seconds"
41+
OboTokenAttrName = "obo_token"
42+
OboTokenPath = "obo_token_path"
43+
ConfigFileProfileAttrName = "config_file_profile"
44+
DefinedTagsToIgnore = "ignore_defined_tags"
45+
RealmSpecificServiceEndpointTemplateEnabled = "realm_specific_service_endpoint_template_enabled"
4546

4647
DefaultConfigFileName = "config"
4748
DefaultConfigDirName = ".oci"

internal/provider/provider.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ func init() {
104104
"Automatic retries were introduced to solve some eventual consistency problems but it also introduced performance issues on destroy operations.",
105105
globalvar.RetryDurationSecondsAttrName: "(Optional) The minimum duration (in seconds) to retry a resource operation in response to an error.\n" +
106106
"The actual retry duration may be longer due to jittering of retry operations. This value is ignored if the `disable_auto_retries` field is set to true.",
107-
globalvar.ConfigFileProfileAttrName: "(Optional) The profile name to be used from config file, if not set it will be DEFAULT.",
108-
globalvar.DefinedTagsToIgnore: "(Optional) List of defined tags keys that Terraform should ignore when planning creates and updates to the associated remote object",
107+
globalvar.ConfigFileProfileAttrName: "(Optional) The profile name to be used from config file, if not set it will be DEFAULT.",
108+
globalvar.DefinedTagsToIgnore: "(Optional) List of defined tags keys that Terraform should ignore when planning creates and updates to the associated remote object",
109+
globalvar.RealmSpecificServiceEndpointTemplateEnabled: "(Optional) flags to enable realm specific service endpoint.",
109110
}
110111
}
111112

@@ -199,6 +200,11 @@ func SchemaMap() map[string]*schema.Schema {
199200
Description: descriptions[globalvar.DefinedTagsToIgnore],
200201
MaxItems: 100,
201202
},
203+
globalvar.RealmSpecificServiceEndpointTemplateEnabled: {
204+
Type: schema.TypeBool,
205+
Optional: true,
206+
Description: descriptions[globalvar.RealmSpecificServiceEndpointTemplateEnabled],
207+
},
202208
}
203209
}
204210

@@ -227,6 +233,7 @@ func ResourcesMap() map[string]*schema.Resource {
227233

228234
func ProviderConfig(d *schema.ResourceData) (interface{}, error) {
229235
tf_resource.DefinedTagsToSuppress = IgnoreDefinedTags(d)
236+
tf_resource.RealmSpecificServiceEndpointTemplateEnabled = realmSpecificServiceEndpointTemplateEnabled(d)
230237
clients := &tf_client.OracleClients{
231238
SdkClientMap: make(map[string]interface{}, len(tf_client.OracleClientRegistrationsVar.RegisteredClients)),
232239
Configuration: make(map[string]string),
@@ -502,6 +509,12 @@ func IgnoreDefinedTags(d schemaResourceData) []string {
502509
}
503510
return nil
504511
}
512+
func realmSpecificServiceEndpointTemplateEnabled(d schemaResourceData) string {
513+
if flag, ok := d.GetOkExists(globalvar.RealmSpecificServiceEndpointTemplateEnabled); ok {
514+
return strconv.FormatBool(flag.(bool))
515+
}
516+
return ""
517+
}
505518

506519
func (p ResourceDataConfigProvider) KeyID() (string, error) {
507520
tenancy, err := p.TenancyOCID()

internal/tfresource/crud_helpers.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,17 @@ import (
3535
)
3636

3737
var (
38-
FifteenMinutes = 15 * time.Minute
39-
TwentyMinutes = 20 * time.Minute
40-
ThirtyMinutes = 30 * time.Minute
41-
OneHour = 60 * time.Minute
42-
TwoHours = 120 * time.Minute
43-
TwoAndHalfHours = 150 * time.Minute
44-
ThreeHours = 180 * time.Minute
45-
TwelveHours = 12 * time.Hour
46-
ZeroTime time.Duration = 0
38+
//string value can store true,false and empty. Empty value can identify that user has not set the flag.
39+
RealmSpecificServiceEndpointTemplateEnabled = ""
40+
FifteenMinutes = 15 * time.Minute
41+
TwentyMinutes = 20 * time.Minute
42+
ThirtyMinutes = 30 * time.Minute
43+
OneHour = 60 * time.Minute
44+
TwoHours = 120 * time.Minute
45+
TwoAndHalfHours = 150 * time.Minute
46+
ThreeHours = 180 * time.Minute
47+
TwelveHours = 12 * time.Hour
48+
ZeroTime time.Duration = 0
4749

4850
DefaultTimeout = &schema.ResourceTimeout{
4951
Create: &TwentyMinutes,

0 commit comments

Comments
 (0)