Skip to content

Commit a295c8b

Browse files
authored
Merge pull request #177 from /issues/175
adding missing access_uri to schema #175
2 parents 3199fc7 + 86c5db4 commit a295c8b

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

docs/examples/storage/preauthrequests/preauthreq.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ variable "bucket_name" {}
2020
variable "object_name" {}
2121

2222
provider "baremetal" {
23-
region = "us-phoenix-1"
24-
alias = "phx"
2523
tenancy_ocid = "${var.tenancy_ocid}"
2624
user_ocid = "${var.user_ocid}"
2725
fingerprint = "${var.fingerprint}"
@@ -45,3 +43,11 @@ resource "baremetal_objectstorage_preauthrequest" "parOnObject" {
4543
access_type = "ObjectRead" //Other configurations accepted are ObjectWrite, ObjectReadWrite
4644
time_expires = "2019-11-10T23:00:00Z"
4745
}
46+
47+
output "par_request_url" {
48+
value = "${baremetal_objectstorage_preauthrequest.parOnObject.access_uri}"
49+
}
50+
51+
output "par_request_name" {
52+
value = "${baremetal_objectstorage_preauthrequest.parOnObject.name}"
53+
}

helpers_objectstorage.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,18 @@ var preauthenticatedRequestSchema = map[string]*schema.Schema{
102102
"access_type": {
103103
Type: schema.TypeString,
104104
Computed: false,
105-
Default: baremetal.ObjectRead,
106-
Optional: true,
105+
Required: true,
107106
ValidateFunc: validation.StringInSlice([]string{
108107
string(baremetal.PARAnyObjectWrite),
109108
string(baremetal.PARObjectRead),
110109
string(baremetal.PARObjectReadWrite),
111110
string(baremetal.ObjectRead)}, true),
112111
},
112+
"access_uri": {
113+
Type: schema.TypeString,
114+
Computed: true,
115+
Optional: true,
116+
},
113117
"time_expires": {
114118
Type: schema.TypeString,
115119
Computed: false,

resource_obmcs_objectstorage_preauthenticatedrequest.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
type PreauthenticatedRequestResourceCrud struct {
1616
crud.BaseCrud
1717
Id string
18+
Name string
1819
Namespace string
1920
BucketName string
2021
ObjectName string
@@ -76,7 +77,9 @@ func (s *PreauthenticatedRequestResourceCrud) SetData() {
7677
s.D.Set("object", s.ObjectName)
7778
s.D.Set("time_expires", s.TimeExpires.Format(time.RFC3339))
7879
s.D.Set("access_type", s.AccessType)
80+
s.D.Set("access_uri", s.AccessURI)
7981
s.D.Set("id", s.ID)
82+
s.D.Set("name", s.Name)
8083
}
8184

8285
func (s *PreauthenticatedRequestResourceCrud) Create() (e error) {
@@ -111,6 +114,7 @@ func (s *PreauthenticatedRequestResourceCrud) Create() (e error) {
111114
s.Namespace = namespace
112115
s.BucketName = bucket
113116
s.ObjectName = object
117+
s.Name = res.Name
114118
return
115119
}
116120

@@ -128,13 +132,15 @@ func (s *PreauthenticatedRequestResourceCrud) Get() (e error) {
128132
}
129133

130134
s.Id = res.ID
135+
//Access URI is only accessible on create
131136
s.AccessURI = ""
132137
s.TimeCreated = res.TimeCreated
133138
s.TimeExpires = res.TimeExpires
134139
s.AccessType = res.AccessType
135140
s.Namespace = namespace
136141
s.BucketName = bucket
137142
s.ObjectName = res.ObjectName
143+
s.Name = res.Name
138144

139145
return
140146
}

0 commit comments

Comments
 (0)