Skip to content

Commit 8fe9ed0

Browse files
authored
Merge pull request #1027 from terraform-providers/release_gh
Release gh
2 parents 3874ed1 + fcf3cc8 commit 8fe9ed0

File tree

52 files changed

+913
-146
lines changed

Some content is hidden

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

52 files changed

+913
-146
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
## 3.71.0 (Unreleased)
2+
3+
### Added
4+
- Support for private customer onboarding and delayed upgrade in `oci_oce_oce_instance`
5+
- Support private stream pools and custom KMS key integration in streaming service
6+
27
## 3.70.0 (April 08, 2020)
38

49
### Added

examples/oce/main.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ resource "oci_oce_oce_instance" "test_oce_instance" {
3232
tenancy_name = "${var.tenancy_name}"
3333

3434
#optional
35-
freeform_tags = "${map("freeformkey", "freeformvalue")}"
36-
description = "description"
37-
instance_usage_type = "NONPRIMARY"
38-
waf_primary_domain = "oracle.com"
35+
freeform_tags = "${map("freeformkey", "freeformvalue")}"
36+
description = "description"
37+
instance_access_type = "PUBLIC"
38+
instance_usage_type = "NONPRIMARY"
39+
upgrade_schedule = "UPGRADE_IMMEDIATELY"
40+
waf_primary_domain = "oracle.com"
3941
}
4042

4143
data "oci_oce_oce_instances" "test_oce_instances" {

examples/streaming/main.tf

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ provider "oci" {
1515
region = "${var.region}"
1616
}
1717

18+
/*
1819
resource "oci_streaming_stream" "stream" {
1920
compartment_id = "${var.compartment_ocid}"
2021
name = "stream1"
@@ -63,13 +64,34 @@ resource "oci_streaming_connect_harness" "test_connect_harness" {
6364
data "oci_streaming_connect_harness" "test_connect_harness" {
6465
connect_harness_id = "${oci_streaming_connect_harness.test_connect_harness.id}"
6566
}
67+
*/
6668

6769
resource "oci_streaming_stream_pool" "test_stream_pool" {
6870
#Required
6971
compartment_id = "${var.compartment_ocid}"
7072
name = "TFStreamPool"
73+
74+
private_endpoint_settings {
75+
nsg_ids = ["${oci_core_network_security_group.test_nsg.id}"]
76+
private_endpoint_ip = "10.0.0.5"
77+
subnet_id = "${oci_core_subnet.test_subnet.id}"
78+
}
79+
}
80+
81+
resource "oci_core_vcn" "test_vcn" {
82+
cidr_block = "10.0.0.0/16"
83+
compartment_id = "${var.compartment_ocid}"
84+
display_name = "testvcn"
85+
dns_label = "dnslabel"
7186
}
7287

73-
data "oci_streaming_stream_pool" "test_stream_pool" {
74-
stream_pool_id = "${oci_streaming_stream_pool.test_stream_pool.id}"
88+
resource "oci_core_subnet" "test_subnet" {
89+
cidr_block = "10.0.0.0/24"
90+
compartment_id = "${var.compartment_ocid}"
91+
vcn_id = "${oci_core_vcn.test_vcn.id}"
92+
}
93+
94+
resource "oci_core_network_security_group" "test_nsg" {
95+
compartment_id = "${var.compartment_ocid}"
96+
vcn_id = "${oci_core_vcn.test_vcn.id}"
7597
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce
77
github.com/hashicorp/terraform v0.12.4-0.20190628193153-a74738cd35fc
88
github.com/mitchellh/cli v1.0.0
9-
github.com/oracle/oci-go-sdk v17.3.0+incompatible
9+
github.com/oracle/oci-go-sdk v17.4.0+incompatible
1010
github.com/stretchr/objx v0.1.1 // indirect
1111
github.com/stretchr/testify v1.3.0
1212
gopkg.in/yaml.v2 v2.2.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ github.com/oracle/oci-go-sdk v17.2.0+incompatible h1:e/oLH8Cf+uvJsRozNocwNJ5zNok
436436
github.com/oracle/oci-go-sdk v17.2.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
437437
github.com/oracle/oci-go-sdk v17.3.0+incompatible h1:a9PyjUO0hU/FvwUqOcFMfWS3iz35ojJcqwxWZPewGdg=
438438
github.com/oracle/oci-go-sdk v17.3.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
439+
github.com/oracle/oci-go-sdk v17.4.0+incompatible h1:W9yFhlwQ9+p0mE2oPrS++v821eIT17gTUpJXkmGZb9o=
440+
github.com/oracle/oci-go-sdk v17.4.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
439441
github.com/packer-community/winrmcp v0.0.0-20180102160824-81144009af58 h1:m3CEgv3ah1Rhy82L+c0QG/U3VyY1UsvsIdkh0/rU97Y=
440442
github.com/packer-community/winrmcp v0.0.0-20180102160824-81144009af58/go.mod h1:f6Izs6JvFTdnRbziASagjZ2vmf55NSIkC/weStxCHqk=
441443
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c h1:Lgl0gzECD8GnQ5QCWA8o6BtfL6mDH5rQgM4/fX3avOs=

oci/audit_events_data_source.go

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

55
import (
66
"context"
7+
"fmt"
78
"time"
89

910
"github.com/hashicorp/terraform/helper/schema"
@@ -416,6 +417,10 @@ func (s *AuditAuditEventsDataSourceCrud) SetData() error {
416417
func dataToMap(obj *oci_audit.Data) map[string]interface{} {
417418
result := map[string]interface{}{}
418419

420+
for keys := range obj.AdditionalDetails {
421+
obj.AdditionalDetails[keys] = fmt.Sprintf("%v", obj.AdditionalDetails[keys])
422+
}
423+
419424
result["additional_details"] = obj.AdditionalDetails
420425

421426
if obj.AvailabilityDomain != nil {

oci/bds_bds_instance_resource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func BdsBdsInstanceResource() *schema.Resource {
102102
"number_of_nodes": {
103103
Type: schema.TypeInt,
104104
Required: true,
105-
ValidateFunc: validation.IntBetween(1, 1),
105+
ValidateFunc: validation.IntBetween(1, 2),
106106
},
107107
},
108108
},
@@ -138,7 +138,7 @@ func BdsBdsInstanceResource() *schema.Resource {
138138
"number_of_nodes": {
139139
Type: schema.TypeInt,
140140
Required: true,
141-
ValidateFunc: validation.IntBetween(1, 1),
141+
ValidateFunc: validation.IntBetween(1, 2),
142142
},
143143
},
144144
},

oci/export_compartment_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,9 @@ func deleteTestChild(d *schema.ResourceData, m interface{}) error {
332332
func initResourceDiscoveryTests() {
333333
resourceNameCount = map[string]int{}
334334

335+
resourcesMap = ResourcesMap()
336+
datasourcesMap = DataSourcesMap()
337+
335338
resourcesMap["oci_test_parent"] = testParentResource()
336339
resourcesMap["oci_test_child"] = testChildResource()
337340
datasourcesMap["oci_test_parents"] = testParentsDatasource()
@@ -343,6 +346,13 @@ func initResourceDiscoveryTests() {
343346
initTestResources()
344347
}
345348

349+
func cleanupResourceDiscoveryTests() {
350+
delete(resourcesMap, "oci_test_parent")
351+
delete(resourcesMap, "oci_test_child")
352+
delete(datasourcesMap, "oci_test_parents")
353+
delete(datasourcesMap, "oci_test_children")
354+
}
355+
346356
func initTestResources() {
347357
numParentResources := 4
348358
if parentResources == nil || len(parentResources) != numParentResources {
@@ -445,6 +455,7 @@ func generateTestResourceFromSchema(id int, resourceSchemaMap map[string]*schema
445455
// Basic test to ensure that RunExportCommand generates TF artifacts
446456
func TestUnitRunExportCommand_basic(t *testing.T) {
447457
initResourceDiscoveryTests()
458+
defer cleanupResourceDiscoveryTests()
448459
compartmentId := resourceDiscoveryTestCompartmentOcid
449460
outputDir, err := os.Getwd()
450461
outputDir = fmt.Sprintf("%s%sdiscoveryTest-%d", outputDir, string(os.PathSeparator), time.Now().Nanosecond())
@@ -484,6 +495,7 @@ func TestUnitRunExportCommand_basic(t *testing.T) {
484495

485496
func TestUnitRunExportCommand_error(t *testing.T) {
486497
initResourceDiscoveryTests()
498+
defer cleanupResourceDiscoveryTests()
487499
compartmentId := resourceDiscoveryTestCompartmentOcid
488500
outputDir, err := os.Getwd()
489501
outputDir = fmt.Sprintf("%s%sdiscoveryTest-%d", outputDir, string(os.PathSeparator), time.Now().Nanosecond())
@@ -510,6 +522,7 @@ func TestUnitRunExportCommand_error(t *testing.T) {
510522
// Test that resources can be found using a resource dependency graph
511523
func TestUnitFindResources_basic(t *testing.T) {
512524
initResourceDiscoveryTests()
525+
defer cleanupResourceDiscoveryTests()
513526
rootResource := getRootCompartmentResource()
514527

515528
results, err := findResources(nil, rootResource, compartmentTestingResourceGraph, nil)
@@ -542,6 +555,7 @@ func TestUnitFindResources_basic(t *testing.T) {
542555
// Test that only targeted ocid resources are exportable
543556
func TestUnitFindResources_restrictedOcids(t *testing.T) {
544557
initResourceDiscoveryTests()
558+
defer cleanupResourceDiscoveryTests()
545559
rootResource := getRootCompartmentResource()
546560

547561
// Parent resources are defined as alwaysExportable. So even if it's not specified in the ocids, it should be exported.
@@ -593,6 +607,7 @@ func TestUnitFindResources_restrictedOcids(t *testing.T) {
593607
// Test that overriden find function is invoked if a resource has one
594608
func TestUnitFindResources_overrideFn(t *testing.T) {
595609
initResourceDiscoveryTests()
610+
defer cleanupResourceDiscoveryTests()
596611
rootResource := getRootCompartmentResource()
597612

598613
// Create an override function that returns nothing when discovering child test resources
@@ -624,6 +639,7 @@ func TestUnitFindResources_overrideFn(t *testing.T) {
624639
// Test that process resource function is invoked if a resource has one
625640
func TestUnitFindResources_processResourceFn(t *testing.T) {
626641
initResourceDiscoveryTests()
642+
defer cleanupResourceDiscoveryTests()
627643
rootResource := getRootCompartmentResource()
628644

629645
// Create a processing function that adds a new attribute to every discovered child resource
@@ -717,6 +733,7 @@ func TestUnitGenerateTerraformNameFromResource_basic(t *testing.T) {
717733
// Test that correct HCL is generated from a discovered test resource
718734
func TestUnitGetHCLString_basic(t *testing.T) {
719735
initResourceDiscoveryTests()
736+
defer cleanupResourceDiscoveryTests()
720737
rootResource := getRootCompartmentResource()
721738

722739
results, err := findResources(nil, rootResource, compartmentTestingResourceGraph, nil)
@@ -792,6 +809,7 @@ parent_id = "ocid1.parent.abcdefghiklmnop.3"
792809
// Test that HCL can be generated when optional or required fields are missing
793810
func TestUnitGetHCLString_missingFields(t *testing.T) {
794811
initResourceDiscoveryTests()
812+
defer cleanupResourceDiscoveryTests()
795813
rootResource := getRootCompartmentResource()
796814

797815
results, err := findResources(nil, rootResource, compartmentTestingResourceGraph, nil)
@@ -833,6 +851,7 @@ func TestUnitGetHCLString_missingFields(t *testing.T) {
833851
// Test that HCL can be generated with values replaced by interpolation syntax
834852
func TestUnitGetHCLString_interpolationMap(t *testing.T) {
835853
initResourceDiscoveryTests()
854+
defer cleanupResourceDiscoveryTests()
836855
rootResource := getRootCompartmentResource()
837856

838857
results, err := findResources(nil, rootResource, compartmentTestingResourceGraph, nil)

oci/export_resource_helpers.go

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88

99
oci_core "github.com/oracle/oci-go-sdk/core"
10+
oci_identity "github.com/oracle/oci-go-sdk/identity"
1011
oci_load_balancer "github.com/oracle/oci-go-sdk/loadbalancer"
1112
)
1213

@@ -90,7 +91,7 @@ func init() {
9091
exportIdentityAvailabilityDomainHints.processDiscoveredResourcesFn = processAvailabilityDomains
9192
exportIdentityAvailabilityDomainHints.getHCLStringOverrideFn = getAvailabilityDomainHCLDatasource
9293
exportIdentityAuthenticationPolicyHints.processDiscoveredResourcesFn = processIdentityAuthenticationPolicies
93-
exportIdentityTagHints.processDiscoveredResourcesFn = processTagDefinitions
94+
exportIdentityTagHints.findResourcesOverrideFn = findIdentityTags
9495

9596
exportObjectStorageBucketHints.getIdFn = getObjectStorageBucketId
9697
exportObjectStorageBucketHints.requireResourceRefresh = true
@@ -635,6 +636,66 @@ func getObjectStorageBucketId(resource *OCIResource) (string, error) {
635636
return getBucketCompositeId(name, namespace), nil
636637
}
637638

639+
func findIdentityTags(clients *OracleClients, tfMeta *TerraformResourceAssociation, parent *OCIResource) ([]*OCIResource, error) {
640+
// List on Tags does not return validator, and resource Read requires tagNamespaceId
641+
// which is also not returned in Summary response. Tags also do not have composite id in state.
642+
// Getting tags using ListTagsRequest and the calling tagResource.Read
643+
tagNamespaceId := parent.id
644+
request := oci_identity.ListTagsRequest{}
645+
646+
request.TagNamespaceId = &tagNamespaceId
647+
648+
request.RequestMetadata.RetryPolicy = getRetryPolicy(true, "identity")
649+
results := []*OCIResource{}
650+
651+
response, err := clients.identityClient.ListTags(context.Background(), request)
652+
if err != nil {
653+
return results, err
654+
}
655+
656+
request.Page = response.OpcNextPage
657+
658+
for request.Page != nil {
659+
listResponse, err := clients.identityClient.ListTags(context.Background(), request)
660+
if err != nil {
661+
return results, err
662+
}
663+
664+
response.Items = append(response.Items, listResponse.Items...)
665+
request.Page = listResponse.OpcNextPage
666+
}
667+
668+
for _, tag := range response.Items {
669+
tagResource := resourcesMap[tfMeta.resourceClass]
670+
671+
d := tagResource.TestResourceData()
672+
d.Set("tag_namespace_id", parent.id)
673+
d.Set("name", tag.Name)
674+
675+
if err := tagResource.Read(d, clients); err != nil {
676+
return results, err
677+
}
678+
679+
resource := &OCIResource{
680+
compartmentId: parent.compartmentId,
681+
sourceAttributes: convertResourceDataToMap(tagResource.Schema, d),
682+
rawResource: tag,
683+
TerraformResource: TerraformResource{
684+
id: d.Id(),
685+
terraformClass: tfMeta.resourceClass,
686+
terraformName: fmt.Sprintf("%s_%s", parent.parent.terraformName, *tag.Name),
687+
},
688+
getHclStringFn: getHclStringFromGenericMap,
689+
parent: parent,
690+
}
691+
692+
results = append(results, resource)
693+
}
694+
695+
return results, nil
696+
697+
}
698+
638699
func findLoadBalancerListeners(clients *OracleClients, tfMeta *TerraformResourceAssociation, parent *OCIResource) ([]*OCIResource, error) {
639700
loadBalancerId := parent.sourceAttributes["load_balancer_id"].(string)
640701
backendSetName := parent.sourceAttributes["name"].(string)
@@ -690,14 +751,6 @@ func findLoadBalancerListeners(clients *OracleClients, tfMeta *TerraformResource
690751
return results, nil
691752
}
692753

693-
func processTagDefinitions(clients *OracleClients, resources []*OCIResource) ([]*OCIResource, error) {
694-
for _, resource := range resources {
695-
resource.sourceAttributes["tag_namespace_id"] = resource.parent.id
696-
resource.importId = fmt.Sprintf("tagNamespaces/%s/tags/%s", resource.parent.id, resource.sourceAttributes["name"].(string))
697-
}
698-
return resources, nil
699-
}
700-
701754
func processNetworkSecurityGroupRules(clients *OracleClients, resources []*OCIResource) ([]*OCIResource, error) {
702755
for _, resource := range resources {
703756
resource.sourceAttributes["network_security_group_id"] = resource.parent.id

0 commit comments

Comments
 (0)