Skip to content

Commit f048d91

Browse files
committed
Add support for Retention Rules that control object immutability
1 parent b8093aa commit f048d91

19 files changed

+1373
-67
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Support for application definition parameters update in dataflow application
77
- Support for Cross Region Replication
88
- Support for Secrets Management Service's `oci_vault_secret` and `oci_vault_secret_version` datasources
9+
- Support for Retention Rules that control object immutability
910

1011
## 3.68.0 (March 25, 2020)
1112

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) 2017, 2019, 2020, Oracle and/or its affiliates. All rights reserved.
2+
3+
/*
4+
* This example shows how to manage a retention rule within a bucket
5+
*/
6+
7+
resource "oci_objectstorage_bucket" "retention_rule_bucket" {
8+
compartment_id = "${var.compartment_ocid}"
9+
namespace = "${data.oci_objectstorage_namespace.ns.namespace}"
10+
name = "tf-example-bucket"
11+
access_type = "NoPublicAccess"
12+
13+
retention_rules {
14+
display_name = "tf-example-retention-rule"
15+
16+
duration {
17+
time_amount = "10"
18+
time_unit = "DAYS"
19+
}
20+
21+
time_rule_locked = "2120-05-04T17:23:46Z"
22+
}
23+
}
24+
25+
data "oci_objectstorage_bucket" "retention_rule_bucket" {
26+
namespace = "${data.oci_objectstorage_namespace.ns.namespace}"
27+
name = "tf-example-bucket"
28+
}
29+
30+
output lifecyclePolicies1 {
31+
value = "${data.oci_objectstorage_bucket.retention_rule_bucket.retention_rules}"
32+
}

go.sum

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -328,36 +328,6 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
328328
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
329329
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
330330
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
331-
github.com/oracle/oci-go-sdk v12.3.0+incompatible h1:hkX0CRD+OmK3+wCbKItck+zgqD+AiPcfxBXnmdgZPlA=
332-
github.com/oracle/oci-go-sdk v12.3.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
333-
github.com/oracle/oci-go-sdk v12.4.0+incompatible h1:W/MTcMs9HOnqQA8+v4xfLxMWN1VN3Q/UtrhQiJK6WHU=
334-
github.com/oracle/oci-go-sdk v12.4.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
335-
github.com/oracle/oci-go-sdk v12.5.0+incompatible h1:pr08ECoaDKHWO9tnzJB1YqClEs7ZK1CFOez2DQocH14=
336-
github.com/oracle/oci-go-sdk v12.5.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
337-
github.com/oracle/oci-go-sdk v13.0.0+incompatible h1:ueAty9OrRXfWi+4gyPLKcOpzhf1OSK70mwt36sD/hf8=
338-
github.com/oracle/oci-go-sdk v13.0.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
339-
github.com/oracle/oci-go-sdk v13.1.0+incompatible h1:inwbT0b/mMbnTfzYoW2xcU1cCMIlU6Fz973at5phRXM=
340-
github.com/oracle/oci-go-sdk v13.1.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
341-
github.com/oracle/oci-go-sdk v14.0.0+incompatible h1:DqmXj/YCn1RLTBO4wKNdZ5lTT6DbhU0ymFYDm6lHZSY=
342-
github.com/oracle/oci-go-sdk v14.0.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
343-
github.com/oracle/oci-go-sdk v15.0.0+incompatible h1:DN9mJZUJMm2IKY9z+lDg7Hz6e+ns1PtWSSbQ8PrmOmw=
344-
github.com/oracle/oci-go-sdk v15.0.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
345-
github.com/oracle/oci-go-sdk v15.1.0+incompatible h1:J+ZPaUim4XZqjdZK13GDsdtu/arw8NzFZGVdQzlrFZo=
346-
github.com/oracle/oci-go-sdk v15.1.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
347-
github.com/oracle/oci-go-sdk v15.2.0+incompatible h1:I//vgQYMUJ3M1tHJP7JaxhKD+wVuxwEX7ilENS7EFsQ=
348-
github.com/oracle/oci-go-sdk v15.2.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
349-
github.com/oracle/oci-go-sdk v15.3.0+incompatible h1:b3/jwxjLAvx1992VxahQhtjjhREiF5SiBmRGb2fs3rM=
350-
github.com/oracle/oci-go-sdk v15.3.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
351-
github.com/oracle/oci-go-sdk v15.4.0+incompatible h1:340zNuNGctKSrh/hX9dgfstETssSysphXSHXcht+bZo=
352-
github.com/oracle/oci-go-sdk v15.4.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
353-
github.com/oracle/oci-go-sdk v15.5.0+incompatible h1:GdG5NWt+lhv0+WslpaF1dbz8KkScYba+zLdr3Nf0ElU=
354-
github.com/oracle/oci-go-sdk v15.5.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
355-
github.com/oracle/oci-go-sdk v15.6.0+incompatible h1:6kX7J6cJnFeWwCPUfiywDD5joxx6qQbJ0SyqnaaKlqU=
356-
github.com/oracle/oci-go-sdk v15.6.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
357-
github.com/oracle/oci-go-sdk v15.7.0+incompatible h1:CkhSZ7dL9yB/rNbVX+MVFHojuMTo+4dFOSorz/iNxmY=
358-
github.com/oracle/oci-go-sdk v15.7.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
359-
github.com/oracle/oci-go-sdk v15.8.0+incompatible h1:SEJ4DBi6DUtCZH26hGtDhQiU3IfjuBFc7R4XjQ8w9DA=
360-
github.com/oracle/oci-go-sdk v15.8.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
361331
github.com/oracle/oci-go-sdk v16.0.0+incompatible h1:4BbhAM6wz7u9vtYrBMCPeQ2oRV9oaaqsHenErPvpQs4=
362332
github.com/oracle/oci-go-sdk v16.0.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
363333
github.com/oracle/oci-go-sdk v17.0.0+incompatible h1:VueI9WISwu2+GwYd2WzuFO+M7ufSnpA707MooU+8xNs=

oci/objectstorage_bucket_data_source.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ func readSingularObjectStorageBucket(d *schema.ResourceData, m interface{}) erro
3636
}
3737

3838
type ObjectStorageBucketDataSourceCrud struct {
39-
D *schema.ResourceData
40-
Client *oci_object_storage.ObjectStorageClient
41-
Res *oci_object_storage.GetBucketResponse
39+
D *schema.ResourceData
40+
Client *oci_object_storage.ObjectStorageClient
41+
Res *oci_object_storage.GetBucketResponse
42+
RetentionRuleRes []*oci_object_storage.RetentionRule
43+
DisableNotFoundRetries bool
4244
}
4345

4446
func (s *ObjectStorageBucketDataSourceCrud) VoidState() {
@@ -47,15 +49,18 @@ func (s *ObjectStorageBucketDataSourceCrud) VoidState() {
4749

4850
func (s *ObjectStorageBucketDataSourceCrud) Get() error {
4951
request := oci_object_storage.GetBucketRequest{}
52+
listRetentionRulesRequest := oci_object_storage.ListRetentionRulesRequest{}
5053

5154
if name, ok := s.D.GetOkExists("name"); ok {
5255
tmp := name.(string)
5356
request.BucketName = &tmp
57+
listRetentionRulesRequest.BucketName = &tmp
5458
}
5559

5660
if namespace, ok := s.D.GetOkExists("namespace"); ok {
5761
tmp := namespace.(string)
5862
request.NamespaceName = &tmp
63+
listRetentionRulesRequest.NamespaceName = &tmp
5964
}
6065

6166
request.Fields = oci_object_storage.GetGetBucketFieldsEnumValues()
@@ -67,6 +72,16 @@ func (s *ObjectStorageBucketDataSourceCrud) Get() error {
6772
}
6873

6974
s.Res = &response
75+
76+
// using list call as summary and get response is same for a retention rule
77+
listRetentionRulesRequest.RequestMetadata.RetryPolicy = getRetryPolicy(s.DisableNotFoundRetries, "object_storage")
78+
listRetentionRulesResponse, e := s.Client.ListRetentionRules(context.Background(), listRetentionRulesRequest)
79+
if e != nil {
80+
return e
81+
}
82+
83+
s.RetentionRuleRes = listResponseToRetentionRuleRes(listRetentionRulesResponse)
84+
7085
return nil
7186
}
7287

@@ -137,5 +152,7 @@ func (s *ObjectStorageBucketDataSourceCrud) SetData() error {
137152
s.D.Set("time_created", s.Res.TimeCreated.String())
138153
}
139154

155+
s.D.Set("retention_rules", retentionRulesResToSet(s.RetentionRuleRes, true))
156+
140157
return nil
141158
}

0 commit comments

Comments
 (0)