Skip to content

Commit 5e700fe

Browse files
No change in functionality. Code organization changed to make schema definition standardized (#397)
1 parent bb9d434 commit 5e700fe

9 files changed

+305
-293
lines changed

provider/helpers_identity.go

Lines changed: 0 additions & 43 deletions
This file was deleted.

provider/helpers_objectstorage.go

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -2,95 +2,10 @@
22

33
package provider
44

5-
import (
6-
"github.com/hashicorp/terraform/helper/schema"
7-
"github.com/hashicorp/terraform/helper/validation"
8-
"github.com/oracle/bmcs-go-sdk"
9-
)
10-
115
func resourceObjectStorageMapToMetadata(rm map[string]interface{}) map[string]string {
126
result := map[string]string{}
137
for k, v := range rm {
148
result[k] = v.(string)
159
}
1610
return result
1711
}
18-
19-
var bucketSchema = map[string]*schema.Schema{
20-
"compartment_id": {
21-
Type: schema.TypeString,
22-
Required: true,
23-
Computed: false,
24-
},
25-
"name": {
26-
Type: schema.TypeString,
27-
Required: true,
28-
Computed: false,
29-
},
30-
"namespace": {
31-
Type: schema.TypeString,
32-
Required: true,
33-
Computed: false,
34-
},
35-
"access_type": {
36-
Type: schema.TypeString,
37-
Computed: false,
38-
Default: baremetal.NoPublicAccess,
39-
Optional: true,
40-
ValidateFunc: validation.StringInSlice([]string{
41-
string(baremetal.NoPublicAccess),
42-
string(baremetal.ObjectRead)}, true),
43-
},
44-
"metadata": {
45-
Type: schema.TypeMap,
46-
Optional: true,
47-
},
48-
}
49-
50-
var preauthenticatedRequestSchema = map[string]*schema.Schema{
51-
"id": {
52-
Type: schema.TypeString,
53-
Optional: true,
54-
Computed: true,
55-
},
56-
"namespace": {
57-
Type: schema.TypeString,
58-
Required: true,
59-
Computed: false,
60-
},
61-
"name": {
62-
Type: schema.TypeString,
63-
Required: true,
64-
Computed: false,
65-
},
66-
"bucket": {
67-
Type: schema.TypeString,
68-
Required: true,
69-
Computed: false,
70-
},
71-
"object": {
72-
Type: schema.TypeString,
73-
Optional: true,
74-
Computed: false,
75-
},
76-
"access_type": {
77-
Type: schema.TypeString,
78-
Computed: false,
79-
Required: true,
80-
ValidateFunc: validation.StringInSlice([]string{
81-
string(baremetal.PARAnyObjectWrite),
82-
string(baremetal.PARObjectRead),
83-
string(baremetal.PARObjectReadWrite),
84-
string(baremetal.ObjectRead)}, true),
85-
},
86-
"access_uri": {
87-
Type: schema.TypeString,
88-
Computed: true,
89-
Optional: true,
90-
},
91-
"time_expires": {
92-
Type: schema.TypeString,
93-
Computed: false,
94-
Required: true,
95-
},
96-
}

provider/identity_compartment_resource.go

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,6 @@ import (
1515

1616
// ResourceIdentityCompartment exposes an IdentityCompartment Resource
1717
func CompartmentResource() *schema.Resource {
18-
compartmentSchema := map[string]*schema.Schema{
19-
"id": {
20-
Type: schema.TypeString,
21-
Computed: true,
22-
},
23-
"name": {
24-
Type: schema.TypeString,
25-
Required: true,
26-
},
27-
"description": {
28-
Type: schema.TypeString,
29-
Required: true,
30-
},
31-
"compartment_id": {
32-
Type: schema.TypeString,
33-
Computed: true,
34-
},
35-
"state": {
36-
Type: schema.TypeString,
37-
Computed: true,
38-
},
39-
"inactive_state": {
40-
Type: schema.TypeInt,
41-
Computed: true,
42-
},
43-
"time_created": {
44-
Type: schema.TypeString,
45-
Computed: true,
46-
},
47-
"time_modified": {
48-
Type: schema.TypeString,
49-
Computed: true,
50-
},
51-
}
52-
5318
return &schema.Resource{
5419
Importer: &schema.ResourceImporter{
5520
State: schema.ImportStatePassthrough,
@@ -59,7 +24,40 @@ func CompartmentResource() *schema.Resource {
5924
Read: readCompartment,
6025
Update: updateCompartment,
6126
Delete: deleteCompartment,
62-
Schema: compartmentSchema,
27+
Schema: map[string]*schema.Schema{
28+
"id": {
29+
Type: schema.TypeString,
30+
Computed: true,
31+
},
32+
"name": {
33+
Type: schema.TypeString,
34+
Required: true,
35+
},
36+
"description": {
37+
Type: schema.TypeString,
38+
Required: true,
39+
},
40+
"compartment_id": {
41+
Type: schema.TypeString,
42+
Computed: true,
43+
},
44+
"state": {
45+
Type: schema.TypeString,
46+
Computed: true,
47+
},
48+
"inactive_state": {
49+
Type: schema.TypeInt,
50+
Computed: true,
51+
},
52+
"time_created": {
53+
Type: schema.TypeString,
54+
Computed: true,
55+
},
56+
"time_modified": {
57+
Type: schema.TypeString,
58+
Computed: true,
59+
},
60+
},
6361
}
6462
}
6563

provider/identity_group_resource.go

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,42 @@ func GroupResource() *schema.Resource {
2222
Read: readGroup,
2323
Update: updateGroup,
2424
Delete: deleteGroup,
25-
Schema: baseIdentitySchema,
25+
Schema: map[string]*schema.Schema{
26+
"id": {
27+
Type: schema.TypeString,
28+
Computed: true,
29+
ForceNew: true,
30+
},
31+
"name": {
32+
Type: schema.TypeString,
33+
Required: true,
34+
ForceNew: true,
35+
},
36+
"description": {
37+
Type: schema.TypeString,
38+
Required: true,
39+
},
40+
"compartment_id": {
41+
Type: schema.TypeString,
42+
Computed: true,
43+
},
44+
"state": {
45+
Type: schema.TypeString,
46+
Computed: true,
47+
},
48+
"inactive_state": {
49+
Type: schema.TypeInt,
50+
Computed: true,
51+
},
52+
"time_created": {
53+
Type: schema.TypeString,
54+
Computed: true,
55+
},
56+
"time_modified": {
57+
Type: schema.TypeString,
58+
Computed: true,
59+
},
60+
},
2661
}
2762
}
2863

0 commit comments

Comments
 (0)