Skip to content

Commit 9cc7019

Browse files
committed
format changes for core
1 parent 9b31138 commit 9cc7019

23 files changed

+80
-97
lines changed

oci/core_app_catalog_subscription_resource.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,14 @@ func (s *CoreAppCatalogSubscriptionResourceCrud) SetData() error {
282282
s.D.Set("listing_id", *s.Res.ListingId)
283283
}
284284

285-
if s.Res.ListingResourceVersion != nil {
286-
s.D.Set("listing_resource_version", *s.Res.ListingResourceVersion)
287-
}
288-
289285
if s.Res.ListingResourceId != nil {
290286
s.D.Set("listing_resource_id", *s.Res.ListingResourceId)
291287
}
292288

289+
if s.Res.ListingResourceVersion != nil {
290+
s.D.Set("listing_resource_version", *s.Res.ListingResourceVersion)
291+
}
292+
293293
if s.Res.PublisherName != nil {
294294
s.D.Set("publisher_name", *s.Res.PublisherName)
295295
}

oci/core_console_history_content_data_source.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package provider
44

55
import (
66
"context"
7-
"fmt"
87

98
"github.com/hashicorp/terraform/helper/schema"
109
oci_core "github.com/oracle/oci-go-sdk/core"
@@ -21,21 +20,6 @@ func CoreConsoleHistoryContentDataSource() *schema.Resource {
2120
"length": {
2221
Type: schema.TypeInt,
2322
Optional: true,
24-
// GetConsoleHistoryContent returns an error with length < 10240, though this is not documented in the API doc.
25-
ValidateFunc: func(i interface{}, k string) (s []string, es []error) {
26-
v, ok := i.(int)
27-
if !ok {
28-
es = append(es, fmt.Errorf("expected type of %s to be int", k))
29-
return
30-
}
31-
32-
if v < 10240 {
33-
es = append(es, fmt.Errorf("expected %s to be less than %d, got %d", k, 10240, v))
34-
return
35-
}
36-
37-
return
38-
},
3923
},
4024
"offset": {
4125
Type: schema.TypeInt,

oci/core_cross_connect_group_resource.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,33 +105,33 @@ func (s *CoreCrossConnectGroupResourceCrud) CreatedPending() []string {
105105

106106
func (s *CoreCrossConnectGroupResourceCrud) CreatedTarget() []string {
107107
return []string{
108-
string(oci_core.CrossConnectGroupLifecycleStateInactive),
109108
string(oci_core.CrossConnectGroupLifecycleStateProvisioned),
109+
string(oci_core.CrossConnectGroupLifecycleStateInactive),
110110
}
111111
}
112112

113-
func (s *CoreCrossConnectGroupResourceCrud) UpdatedPending() []string {
113+
func (s *CoreCrossConnectGroupResourceCrud) DeletedPending() []string {
114114
return []string{
115-
string(oci_core.CrossConnectGroupLifecycleStateProvisioning),
115+
string(oci_core.CrossConnectGroupLifecycleStateTerminating),
116116
}
117117
}
118118

119-
func (s *CoreCrossConnectGroupResourceCrud) UpdatedTarget() []string {
119+
func (s *CoreCrossConnectGroupResourceCrud) DeletedTarget() []string {
120120
return []string{
121-
string(oci_core.CrossConnectGroupLifecycleStateInactive),
122-
string(oci_core.CrossConnectGroupLifecycleStateProvisioned),
121+
string(oci_core.CrossConnectGroupLifecycleStateTerminated),
123122
}
124123
}
125124

126-
func (s *CoreCrossConnectGroupResourceCrud) DeletedPending() []string {
125+
func (s *CoreCrossConnectGroupResourceCrud) UpdatedPending() []string {
127126
return []string{
128-
string(oci_core.CrossConnectGroupLifecycleStateTerminating),
127+
string(oci_core.CrossConnectGroupLifecycleStateProvisioning),
129128
}
130129
}
131130

132-
func (s *CoreCrossConnectGroupResourceCrud) DeletedTarget() []string {
131+
func (s *CoreCrossConnectGroupResourceCrud) UpdatedTarget() []string {
133132
return []string{
134-
string(oci_core.CrossConnectGroupLifecycleStateTerminated),
133+
string(oci_core.CrossConnectGroupLifecycleStateProvisioned),
134+
string(oci_core.CrossConnectGroupLifecycleStateInactive),
135135
}
136136
}
137137

oci/core_cross_connect_resource.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ func (s *CoreCrossConnectResourceCrud) CreatedTarget() []string {
159159
}
160160
}
161161

162+
func (s *CoreCrossConnectResourceCrud) DeletedPending() []string {
163+
return []string{
164+
string(oci_core.CrossConnectLifecycleStateTerminating),
165+
}
166+
}
167+
168+
func (s *CoreCrossConnectResourceCrud) DeletedTarget() []string {
169+
return []string{
170+
string(oci_core.CrossConnectLifecycleStateTerminated),
171+
}
172+
}
173+
162174
func (s *CoreCrossConnectResourceCrud) UpdatedPending() []string {
163175
return []string{
164176
string(oci_core.CrossConnectLifecycleStateProvisioning),
@@ -179,18 +191,6 @@ func (s *CoreCrossConnectResourceCrud) UpdatedTarget() []string {
179191
}
180192
}
181193

182-
func (s *CoreCrossConnectResourceCrud) DeletedPending() []string {
183-
return []string{
184-
string(oci_core.CrossConnectLifecycleStateTerminating),
185-
}
186-
}
187-
188-
func (s *CoreCrossConnectResourceCrud) DeletedTarget() []string {
189-
return []string{
190-
string(oci_core.CrossConnectLifecycleStateTerminated),
191-
}
192-
}
193-
194194
func (s *CoreCrossConnectResourceCrud) Create() error {
195195
request := oci_core.CreateCrossConnectRequest{}
196196

@@ -242,7 +242,6 @@ func (s *CoreCrossConnectResourceCrud) Create() error {
242242
}
243243

244244
s.Res = &response.CrossConnect
245-
246245
return nil
247246
}
248247

oci/core_dhcp_options_resource.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ package provider
44

55
import (
66
"context"
7+
"fmt"
78
"log"
89
"strings"
910

1011
"github.com/hashicorp/terraform/helper/schema"
11-
1212
"github.com/hashicorp/terraform/helper/validation"
1313

14-
"fmt"
15-
1614
oci_core "github.com/oracle/oci-go-sdk/core"
1715
)
1816

@@ -53,20 +51,23 @@ func CoreDhcpOptionsResource() *schema.Resource {
5351
"custom_dns_servers": {
5452
Type: schema.TypeList,
5553
Optional: true,
54+
Computed: true,
5655
Elem: &schema.Schema{
5756
Type: schema.TypeString,
5857
},
5958
},
6059
"search_domain_names": {
6160
Type: schema.TypeList,
6261
Optional: true,
62+
Computed: true,
6363
Elem: &schema.Schema{
6464
Type: schema.TypeString,
6565
},
6666
},
6767
"server_type": {
6868
Type: schema.TypeString,
6969
Optional: true,
70+
Computed: true,
7071
ValidateFunc: validation.StringInSlice([]string{
7172
string(oci_core.DhcpDnsOptionServerTypeCustomdnsserver),
7273
string(oci_core.DhcpDnsOptionServerTypeVcnlocal),
@@ -367,9 +368,6 @@ func (s *CoreDhcpOptionsResourceCrud) mapToDhcpOption(fieldKeyFormat string) (oc
367368
}
368369
switch strings.ToLower(type_) {
369370
case strings.ToLower("DomainNameServer"):
370-
if searchDomainNames, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "search_domain_names")); ok && len(searchDomainNames.([]interface{})) > 0 {
371-
return nil, fmt.Errorf("'search_domain_names' should not be specified for type DomainNameServer")
372-
}
373371
details := oci_core.DhcpDnsOption{}
374372
details.CustomDnsServers = []string{}
375373
if customDnsServers, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "custom_dns_servers")); ok {
@@ -387,14 +385,6 @@ func (s *CoreDhcpOptionsResourceCrud) mapToDhcpOption(fieldKeyFormat string) (oc
387385
}
388386
baseObject = details
389387
case strings.ToLower("SearchDomain"):
390-
if customDnsServers, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "custom_dns_servers")); ok && len(customDnsServers.([]interface{})) > 0 {
391-
return nil, fmt.Errorf("'custom_dns_servers' should not be specified for type SearchDomain")
392-
}
393-
394-
if serverType, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "server_type")); ok && len(serverType.(string)) > 0 {
395-
return nil, fmt.Errorf("'server_type' should not be specified for type SearchDomain")
396-
}
397-
398388
details := oci_core.DhcpSearchDomainOption{}
399389
details.SearchDomainNames = []string{}
400390
if searchDomainNames, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "search_domain_names")); ok {
@@ -411,7 +401,6 @@ func (s *CoreDhcpOptionsResourceCrud) mapToDhcpOption(fieldKeyFormat string) (oc
411401
default:
412402
return nil, fmt.Errorf("unknown type '%v' was specified", type_)
413403
}
414-
415404
return baseObject, nil
416405
}
417406

oci/core_instance_configuration_resource.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/hashicorp/terraform/helper/schema"
1313
"github.com/hashicorp/terraform/helper/validation"
14+
1415
oci_core "github.com/oracle/oci-go-sdk/core"
1516
)
1617

@@ -784,7 +785,6 @@ func (s *CoreInstanceConfigurationResourceCrud) mapToInstanceConfigurationAttach
784785

785786
func InstanceConfigurationAttachVolumeDetailsToMap(obj *oci_core.InstanceConfigurationAttachVolumeDetails) map[string]interface{} {
786787
result := map[string]interface{}{}
787-
788788
switch v := (*obj).(type) {
789789
case oci_core.InstanceConfigurationIscsiAttachVolumeDetails:
790790
result["type"] = "iscsi"
@@ -1050,41 +1050,41 @@ func (s *CoreInstanceConfigurationResourceCrud) mapToInstanceConfigurationInstan
10501050
switch strings.ToLower(instanceType) {
10511051
case strings.ToLower("compute"):
10521052
details := oci_core.ComputeInstanceDetails{}
1053+
details.BlockVolumes = []oci_core.InstanceConfigurationBlockVolumeDetails{}
10531054
if blockVolumes, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "block_volumes")); ok {
1054-
details.BlockVolumes = []oci_core.InstanceConfigurationBlockVolumeDetails{}
10551055
interfaces := blockVolumes.([]interface{})
10561056
tmp := make([]oci_core.InstanceConfigurationBlockVolumeDetails, len(interfaces))
10571057
for i := range interfaces {
10581058
stateDataIndex := i
1059-
fieldKeyFormatNextLevel := fmt.Sprintf(fieldKeyFormat, fmt.Sprintf("%s.%d.%%s", "block_volumes", stateDataIndex))
1059+
fieldKeyFormatNextLevel := fmt.Sprintf("%s.%d.%%s", fmt.Sprintf(fieldKeyFormat, "block_volumes"), stateDataIndex)
10601060
converted, err := s.mapToInstanceConfigurationBlockVolumeDetails(fieldKeyFormatNextLevel)
10611061
if err != nil {
1062-
return nil, err
1062+
return details, err
10631063
}
10641064
tmp[i] = converted
10651065
}
10661066
details.BlockVolumes = tmp
10671067
}
10681068
if launchDetails, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "launch_details")); ok {
10691069
if tmpList := launchDetails.([]interface{}); len(tmpList) > 0 {
1070-
fieldKeyFormatNextLevel := fmt.Sprintf(fieldKeyFormat, fmt.Sprintf("%s.%d.%%s", "launch_details", 0))
1070+
fieldKeyFormatNextLevel := fmt.Sprintf("%s.%d.%%s", fmt.Sprintf(fieldKeyFormat, "launch_details"), 0)
10711071
tmp, err := s.mapToInstanceConfigurationLaunchInstanceDetails(fieldKeyFormatNextLevel)
10721072
if err != nil {
1073-
return nil, err
1073+
return details, fmt.Errorf("unable to convert launch_details, encountered error: %v", err)
10741074
}
10751075
details.LaunchDetails = &tmp
10761076
}
10771077
}
1078+
details.SecondaryVnics = []oci_core.InstanceConfigurationAttachVnicDetails{}
10781079
if secondaryVnics, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "secondary_vnics")); ok {
1079-
details.SecondaryVnics = []oci_core.InstanceConfigurationAttachVnicDetails{}
10801080
interfaces := secondaryVnics.([]interface{})
10811081
tmp := make([]oci_core.InstanceConfigurationAttachVnicDetails, len(interfaces))
10821082
for i := range interfaces {
10831083
stateDataIndex := i
1084-
fieldKeyFormatNextLevel := fmt.Sprintf(fieldKeyFormat, fmt.Sprintf("%s.%d.%%s", "secondary_vnics", stateDataIndex))
1084+
fieldKeyFormatNextLevel := fmt.Sprintf("%s.%d.%%s", fmt.Sprintf(fieldKeyFormat, "secondary_vnics"), stateDataIndex)
10851085
converted, err := s.mapToInstanceConfigurationAttachVnicDetails(fieldKeyFormatNextLevel)
10861086
if err != nil {
1087-
return nil, err
1087+
return details, err
10881088
}
10891089
tmp[i] = converted
10901090
}

oci/core_instance_data_source.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ func (s *CoreInstanceDataSourceCrud) SetData() error {
101101
s.D.Set("freeform_tags", s.Res.FreeformTags)
102102

103103
if s.Res.ImageId != nil {
104-
// @CODEGEN 1/2018: support legacy name "image"
105104
s.D.Set("image", *s.Res.ImageId)
106105
}
107106

oci/core_instance_pool_resource.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ func (s *CoreInstancePoolResourceCrud) CreatedPending() []string {
235235

236236
func (s *CoreInstancePoolResourceCrud) CreatedTarget() []string {
237237
return []string{
238-
string(oci_core.InstancePoolLifecycleStateRunning),
239238
string(oci_core.InstancePoolLifecycleStateStopped),
239+
string(oci_core.InstancePoolLifecycleStateRunning),
240240
}
241241
}
242242

@@ -393,6 +393,7 @@ func (s *CoreInstancePoolResourceCrud) Get() error {
393393
if err != nil {
394394
return err
395395
}
396+
396397
s.Res = &response.InstancePool
397398
return nil
398399
}

oci/core_instance_resource.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,6 @@ func (s *CoreInstanceResourceCrud) SetData() error {
803803
s.D.Set("freeform_tags", s.Res.FreeformTags)
804804

805805
if s.Res.ImageId != nil {
806-
// @CODEGEN 1/2018: support legacy name "image"
807806
s.D.Set("image", *s.Res.ImageId)
808807
}
809808

oci/core_internet_gateway_resource.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ func (s *CoreInternetGatewayResourceCrud) Create() error {
167167
request.DisplayName = &tmp
168168
}
169169

170-
// TODO: GetOk malfunction with this bool: 'ok' is always the value of the bool
171-
// newer versions of terraform support GetOkExists which should resolve this problem
172-
enabledTmp := s.D.Get("enabled").(bool)
173-
request.IsEnabled = &enabledTmp
170+
if enabled, ok := s.D.GetOkExists("enabled"); ok {
171+
tmp := enabled.(bool)
172+
request.IsEnabled = &tmp
173+
}
174174

175175
if freeformTags, ok := s.D.GetOkExists("freeform_tags"); ok {
176176
request.FreeformTags = objectMapToStringMap(freeformTags.(map[string]interface{}))
@@ -225,10 +225,10 @@ func (s *CoreInternetGatewayResourceCrud) Update() error {
225225
request.DisplayName = &tmp
226226
}
227227

228-
// TODO: GetOk malfunction with this bool: 'ok' is always the value of the bool
229-
// newer versions of terraform support GetOkExists which should resolve this problem
230-
enabledTmp := s.D.Get("enabled").(bool)
231-
request.IsEnabled = &enabledTmp
228+
if enabled, ok := s.D.GetOkExists("enabled"); ok {
229+
tmp := enabled.(bool)
230+
request.IsEnabled = &tmp
231+
}
232232

233233
if freeformTags, ok := s.D.GetOkExists("freeform_tags"); ok {
234234
request.FreeformTags = objectMapToStringMap(freeformTags.(map[string]interface{}))

0 commit comments

Comments
 (0)