-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy pathresource_schema.go
121 lines (116 loc) · 3.18 KB
/
resource_schema.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package streamconnection
import (
"context"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
)
func ResourceSchema(ctx context.Context) schema.Schema {
return schema.Schema{
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"project_id": schema.StringAttribute{
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"instance_name": schema.StringAttribute{
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"connection_name": schema.StringAttribute{
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"type": schema.StringAttribute{
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
// cluster type specific
"cluster_name": schema.StringAttribute{
Optional: true,
},
"db_role_to_execute": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"role": schema.StringAttribute{
Required: true,
},
"type": schema.StringAttribute{
Required: true,
Validators: []validator.String{
stringvalidator.OneOf("BUILT_IN", "CUSTOM"),
},
},
},
},
// kafka type specific
"authentication": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"mechanism": schema.StringAttribute{
Optional: true,
},
"password": schema.StringAttribute{
Optional: true,
Sensitive: true,
},
"username": schema.StringAttribute{
Optional: true,
},
},
},
"bootstrap_servers": schema.StringAttribute{
Optional: true,
},
"config": schema.MapAttribute{
ElementType: types.StringType,
Optional: true,
},
"security": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"broker_public_certificate": schema.StringAttribute{
Optional: true,
},
"protocol": schema.StringAttribute{
Optional: true,
},
},
},
"networking": schema.SingleNestedAttribute{
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.Object{
objectplanmodifier.UseStateForUnknown(),
},
Attributes: map[string]schema.Attribute{
"access": schema.SingleNestedAttribute{
Required: true,
Attributes: map[string]schema.Attribute{
"type": schema.StringAttribute{
Required: true,
},
},
},
},
},
},
}
}