Skip to content

Commit bca63bb

Browse files
authored
Release 3.31.0
Release 3.31.0
2 parents 5813f8b + 3c94afd commit bca63bb

File tree

346 files changed

+84517
-6571
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

346 files changed

+84517
-6571
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
## 3.31.0 (Unreleased)
2+
3+
### Added
4+
- Support for moving `email sender` resource between compartments.
5+
- Support for moving NAT Gateway resource across Compartments.
6+
7+
### Fixed
8+
- Fix for `defined_tags` property deletion bug
9+
10+
## Notes
11+
- This release upgrades the Terraform plugin SDK to v0.12.3-0.20190619193004-2ab2796c932c, which fixes
12+
how null/empty values are stored in state during import and fixes unnecessary diffs caused by omission of
13+
Optional/Computed fields.
14+
215
## 3.30.0 (June 19, 2019)
316

417
### Added

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
module github.com/terraform-providers/terraform-provider-oci
22

33
require (
4-
github.com/go-ini/ini v0.0.0-20170209042415-ee900ca56593 // indirect
54
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce // indirect
6-
github.com/hashicorp/terraform v0.12.0-rc1
7-
github.com/oracle/oci-go-sdk v5.11.0+incompatible
8-
github.com/smartystreets/goconvey v0.0.0-20190222223459-a17d461953aa // indirect
5+
github.com/hashicorp/terraform v0.12.3-0.20190619193004-2ab2796c932c
6+
github.com/oracle/oci-go-sdk v5.12.0+incompatible
97
github.com/stretchr/objx v0.1.1 // indirect
108
github.com/stretchr/testify v1.3.0
119
gopkg.in/yaml.v2 v2.2.2

go.sum

Lines changed: 46 additions & 141 deletions
Large diffs are not rendered by default.

oci/audit_audit_events_data_source.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ package provider
1111

1212
import (
1313
"context"
14+
"time"
1415

1516
"github.com/hashicorp/terraform/helper/schema"
1617
oci_audit "github.com/oracle/oci-go-sdk/audit"
1718
oci_common "github.com/oracle/oci-go-sdk/common"
18-
19-
"time"
2019
)
2120

2221
func AuditAuditEventsDataSource() *schema.Resource {

oci/core_app_catalog_subscription_resource.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import (
1212
"time"
1313

1414
"github.com/hashicorp/terraform/helper/schema"
15-
"github.com/oracle/oci-go-sdk/common"
15+
16+
oci_common "github.com/oracle/oci-go-sdk/common"
1617
oci_core "github.com/oracle/oci-go-sdk/core"
1718
)
1819

@@ -159,7 +160,7 @@ func (s *CoreAppCatalogSubscriptionResourceCrud) Create() error {
159160

160161
if timeRetrieved, ok := s.D.GetOkExists("time_retrieved"); ok {
161162
tmp, _ := time.Parse(time.RFC3339Nano, timeRetrieved.(string))
162-
request.TimeRetrieved = &common.SDKTime{Time: tmp}
163+
request.TimeRetrieved = &oci_common.SDKTime{Time: tmp}
163164
}
164165

165166
request.RequestMetadata.RetryPolicy = getRetryPolicy(s.DisableNotFoundRetries, "core")

oci/core_dhcp_options_resource.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,18 @@ func (s *CoreDhcpOptionsResourceCrud) Create() error {
240240
}
241241

242242
s.Res = &response.DhcpOptions
243+
244+
// this is needed to make the infrastructure match what is on the config as in some cases during the Create the service adds an option for SearchDomain by default if the user doesn't provide it.
245+
updateRequest := oci_core.UpdateDhcpOptionsRequest{}
246+
updateRequest.DhcpId = s.Res.Id
247+
updateRequest.Options = request.Options
248+
updateRequest.RequestMetadata.RetryPolicy = getRetryPolicy(s.DisableNotFoundRetries, "core")
249+
updateResponse, err := s.Client.UpdateDhcpOptions(context.Background(), updateRequest)
250+
if err != nil {
251+
log.Printf("[ERROR] Could not perform an update right after the create of the dhcpOptions: %v", err)
252+
}
253+
s.Res = &updateResponse.DhcpOptions
254+
243255
return nil
244256
}
245257

oci/core_dhcp_options_resource_test.go

Lines changed: 67 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,9 @@ import (
1212
"github.com/hashicorp/terraform/helper/resource"
1313
"github.com/hashicorp/terraform/terraform"
1414

15-
core "github.com/oracle/oci-go-sdk/core"
16-
"github.com/stretchr/testify/suite"
15+
"github.com/oracle/oci-go-sdk/core"
1716
)
1817

19-
type ResourceCoreDHCPOptionsTestSuite struct {
20-
suite.Suite
21-
Providers map[string]terraform.ResourceProvider
22-
Config string
23-
ResourceName string
24-
}
25-
2618
var defaultDhcpOpts = `
2719
resource "oci_core_default_dhcp_options" "default" {
2820
manage_default_resource_id = "${oci_core_virtual_network.t.default_dhcp_options_id}"
@@ -54,10 +46,61 @@ var additionalDhcpOption4 = `
5446
}
5547
}`
5648

57-
func (s *ResourceCoreDHCPOptionsTestSuite) SetupTest() {
58-
s.Providers = testAccProviders
59-
testAccPreCheck(s.T())
60-
s.Config = legacyTestProviderConfig() + `
49+
//If you set DhcpDnsOption to `VcnLocalPlusInternet`, and you assign a DNS label to the VCN during creation, the search domain name in the VCN's default set of DHCP options is automatically set to the VCN domain
50+
//To avoid multiple applies we perform an apply after the create in order have the options match what the user has in the config
51+
//This test makes sure we handle that case correctly and that there is a non empty plan after the apply
52+
func TestResourceCoreDHCPOptions_avoidServiceDefault(t *testing.T) {
53+
httpreplay.SetScenario("TestAccResourceCoreDHCPOptions_avoidServiceDefault")
54+
defer httpreplay.SaveScenario()
55+
56+
provider := testAccProvider
57+
58+
resource.Test(t, resource.TestCase{
59+
PreCheck: func() { testAccPreCheck(t) },
60+
Providers: map[string]terraform.ResourceProvider{
61+
"oci": provider,
62+
},
63+
Steps: []resource.TestStep{
64+
{
65+
Config: legacyTestProviderConfig() + defaultDhcpOpts + `
66+
resource "oci_core_virtual_network" "t" {
67+
cidr_block = "10.1.0.0/16"
68+
compartment_id = "${var.compartment_id}"
69+
display_name = "testVcn"
70+
dns_label = "tftestvcn"
71+
}
72+
73+
resource "oci_core_dhcp_options" "opt" {
74+
compartment_id = "${var.compartment_id}"
75+
vcn_id = "${oci_core_virtual_network.t.id}"
76+
display_name = "testDhcpOptions"
77+
78+
// required
79+
options {
80+
type = "DomainNameServer"
81+
server_type = "VcnLocalPlusInternet"
82+
}
83+
}`,
84+
Check: resource.ComposeAggregateTestCheckFunc(
85+
resource.TestCheckResourceAttr("oci_core_dhcp_options.opt", "display_name", "testDhcpOptions"),
86+
resource.TestCheckResourceAttr("oci_core_dhcp_options.opt", "options.#", "1"),
87+
resource.TestCheckResourceAttr("oci_core_dhcp_options.opt", "options.0.type", "DomainNameServer"),
88+
resource.TestCheckResourceAttr("oci_core_dhcp_options.opt", "options.0.server_type", "VcnLocalPlusInternet"),
89+
),
90+
},
91+
},
92+
})
93+
}
94+
95+
func TestResourceCoreDHCPOptions_basic(t *testing.T) {
96+
httpreplay.SetScenario("TestAccResourceCoreDHCPOptions_basic")
97+
defer httpreplay.SaveScenario()
98+
99+
var resDefaultId, resOpt4Id, resId2 string
100+
101+
provider := testAccProvider
102+
103+
config := legacyTestProviderConfig() + `
61104
resource "oci_core_virtual_network" "t" {
62105
cidr_block = "10.0.0.0/16"
63106
compartment_id = "${var.compartment_id}"
@@ -104,13 +147,12 @@ func (s *ResourceCoreDHCPOptionsTestSuite) SetupTest() {
104147
custom_dns_servers = [ "8.8.4.4", "8.8.8.8" ]
105148
}
106149
}`
107-
}
108-
109-
func (s *ResourceCoreDHCPOptionsTestSuite) TestAccResourceCoreDHCPOptions_basic() {
110-
var resDefaultId, resOpt4Id, resId2 string
111150

112-
resource.Test(s.T(), resource.TestCase{
113-
Providers: s.Providers,
151+
resource.Test(t, resource.TestCase{
152+
PreCheck: func() { testAccPreCheck(t) },
153+
Providers: map[string]terraform.ResourceProvider{
154+
"oci": provider,
155+
},
114156
Steps: []resource.TestStep{
115157
// Test invalid options type
116158
{
@@ -156,7 +198,7 @@ func (s *ResourceCoreDHCPOptionsTestSuite) TestAccResourceCoreDHCPOptions_basic(
156198
},
157199
// Verify result of strange polymorphic options
158200
{
159-
Config: s.Config,
201+
Config: config,
160202
Check: nil,
161203
},
162204
{
@@ -181,7 +223,7 @@ func (s *ResourceCoreDHCPOptionsTestSuite) TestAccResourceCoreDHCPOptions_basic(
181223
ExpectError: regexp.MustCompile("InvalidParameter.*JSON input"),
182224
},
183225
{
184-
Config: s.Config + additionalDhcpOption4 + defaultDhcpOpts,
226+
Config: config + additionalDhcpOption4 + defaultDhcpOpts,
185227
Check: resource.ComposeAggregateTestCheckFunc(
186228

187229
resource.TestCheckResourceAttr("oci_core_dhcp_options.opt1", "display_name", "display_name1"),
@@ -259,12 +301,12 @@ func (s *ResourceCoreDHCPOptionsTestSuite) TestAccResourceCoreDHCPOptions_basic(
259301
},
260302
// Verify removing default DHCP options
261303
{
262-
Config: s.Config + additionalDhcpOption4,
304+
Config: config + additionalDhcpOption4,
263305
Check: nil,
264306
},
265307
// Verify adding default DHCP options again
266308
{
267-
Config: s.Config + additionalDhcpOption4 + defaultDhcpOpts,
309+
Config: config + additionalDhcpOption4 + defaultDhcpOpts,
268310
Check: resource.ComposeAggregateTestCheckFunc(
269311
resource.TestCheckResourceAttr("oci_core_default_dhcp_options.default", "options.0.type", "DomainNameServer"),
270312
resource.TestCheckResourceAttr("oci_core_default_dhcp_options.default", "options.0.server_type", "CustomDnsServer"),
@@ -290,7 +332,7 @@ func (s *ResourceCoreDHCPOptionsTestSuite) TestAccResourceCoreDHCPOptions_basic(
290332
},
291333
// ensure that changing the case for options.?.type (polymorphic discriminator) is a no-op.
292334
{
293-
Config: s.Config + `
335+
Config: config + `
294336
resource "oci_core_dhcp_options" "opt4" { # Same as additionalDhcpOption4 but with diff casing for 'type'.
295337
compartment_id = "${var.compartment_id}"
296338
vcn_id = "${oci_core_virtual_network.t.id}"
@@ -309,7 +351,7 @@ func (s *ResourceCoreDHCPOptionsTestSuite) TestAccResourceCoreDHCPOptions_basic(
309351
},
310352
// Changing to a different vcn should be a ForceNew
311353
{
312-
Config: s.Config + `
354+
Config: config + `
313355
resource "oci_core_dhcp_options" "opt4" { # Same as alternate additionalDhcpOption4 above, but with diff vcn.
314356
compartment_id = "${var.compartment_id}"
315357
vcn_id = "${oci_core_virtual_network.t2.id}"
@@ -337,9 +379,3 @@ func (s *ResourceCoreDHCPOptionsTestSuite) TestAccResourceCoreDHCPOptions_basic(
337379
},
338380
})
339381
}
340-
341-
func TestResourceCoreDHCPOptionsTestSuite(t *testing.T) {
342-
httpreplay.SetScenario("TestResourceCoreDHCPOptionsTestSuite")
343-
defer httpreplay.SaveScenario()
344-
suite.Run(t, new(ResourceCoreDHCPOptionsTestSuite))
345-
}

oci/core_nat_gateway_resource.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ func CoreNatGatewayResource() *schema.Resource {
2525
"compartment_id": {
2626
Type: schema.TypeString,
2727
Required: true,
28-
ForceNew: true,
2928
},
3029
"vcn_id": {
3130
Type: schema.TypeString,
@@ -207,6 +206,15 @@ func (s *CoreNatGatewayResourceCrud) Get() error {
207206
}
208207

209208
func (s *CoreNatGatewayResourceCrud) Update() error {
209+
if compartment, ok := s.D.GetOkExists("compartment_id"); ok && s.D.HasChange("compartment_id") {
210+
oldRaw, newRaw := s.D.GetChange("compartment_id")
211+
if newRaw != "" && oldRaw != "" {
212+
err := s.updateCompartment(compartment)
213+
if err != nil {
214+
return err
215+
}
216+
}
217+
}
210218
request := oci_core.UpdateNatGatewayRequest{}
211219

212220
if blockTraffic, ok := s.D.GetOkExists("block_traffic"); ok {
@@ -292,3 +300,21 @@ func (s *CoreNatGatewayResourceCrud) SetData() error {
292300

293301
return nil
294302
}
303+
304+
func (s *CoreNatGatewayResourceCrud) updateCompartment(compartment interface{}) error {
305+
changeCompartmentRequest := oci_core.ChangeNatGatewayCompartmentRequest{}
306+
307+
compartmentTmp := compartment.(string)
308+
changeCompartmentRequest.CompartmentId = &compartmentTmp
309+
310+
idTmp := s.D.Id()
311+
changeCompartmentRequest.NatGatewayId = &idTmp
312+
313+
changeCompartmentRequest.RequestMetadata.RetryPolicy = getRetryPolicy(s.DisableNotFoundRetries, "core")
314+
315+
_, err := s.Client.ChangeNatGatewayCompartment(context.Background(), changeCompartmentRequest)
316+
if err != nil {
317+
return err
318+
}
319+
return nil
320+
}

oci/core_nat_gateway_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ func TestCoreNatGatewayResource_basic(t *testing.T) {
6161
compartmentId := getEnvSettingWithBlankDefault("compartment_ocid")
6262
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
6363

64+
compartmentIdU := getEnvSettingWithDefault("compartment_id_for_update", compartmentId)
65+
compartmentIdUVariableStr := fmt.Sprintf("variable \"compartment_id_for_update\" { default = \"%s\" }\n", compartmentIdU)
66+
6467
resourceName := "oci_core_nat_gateway.test_nat_gateway"
6568
datasourceName := "data.oci_core_nat_gateways.test_nat_gateways"
6669
singularDatasourceName := "data.oci_core_nat_gateway.test_nat_gateway"
@@ -116,6 +119,35 @@ func TestCoreNatGatewayResource_basic(t *testing.T) {
116119
),
117120
},
118121

122+
// verify update to the compartment (the compartment will be switched back in the next step)
123+
{
124+
Config: config + compartmentIdVariableStr + compartmentIdUVariableStr + NatGatewayResourceDependencies +
125+
generateResourceFromRepresentationMap("oci_core_nat_gateway", "test_nat_gateway", Optional, Create,
126+
representationCopyWithNewProperties(natGatewayRepresentation, map[string]interface{}{
127+
"compartment_id": Representation{repType: Required, create: `${var.compartment_id_for_update}`},
128+
})),
129+
Check: resource.ComposeAggregateTestCheckFunc(
130+
resource.TestCheckResourceAttr(resourceName, "block_traffic", "false"),
131+
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentIdU),
132+
resource.TestCheckResourceAttr(resourceName, "defined_tags.%", "1"),
133+
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
134+
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
135+
resource.TestCheckResourceAttrSet(resourceName, "id"),
136+
resource.TestCheckResourceAttrSet(resourceName, "nat_ip"),
137+
resource.TestCheckResourceAttrSet(resourceName, "state"),
138+
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
139+
resource.TestCheckResourceAttrSet(resourceName, "vcn_id"),
140+
141+
func(s *terraform.State) (err error) {
142+
resId2, err = fromInstanceState(s, resourceName, "id")
143+
if resId != resId2 {
144+
return fmt.Errorf("resource recreated when it was supposed to be updated")
145+
}
146+
return err
147+
},
148+
),
149+
},
150+
119151
// verify updates to updatable parameters
120152
{
121153
Config: config + compartmentIdVariableStr + NatGatewayResourceDependencies +

oci/core_public_ip_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func TestCorePublicIpResource_basic(t *testing.T) {
296296
resource.TestCheckResourceAttr(resourceName, "display_name", displayName),
297297
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
298298
resource.TestCheckResourceAttr(resourceName, "lifetime", string(oci_core.PublicIpLifetimeReserved)),
299-
resource.TestCheckResourceAttr(resourceName, "private_ip_id", ""), // Still defined, but now empty.
299+
resource.TestCheckNoResourceAttr(resourceName, "private_ip_id"), // Should not be defined in state
300300
resource.TestCheckNoResourceAttr(resourceName, "availability_domain"),
301301
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
302302
resource.TestCheckResourceAttr(resourceName, "scope", string(oci_core.PublicIpScopeRegion)),

0 commit comments

Comments
 (0)