/
schema.go
94 lines (91 loc) · 2.82 KB
/
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
package zfs
import (
"github.com/awlsring/terraform-provider-proxmox/proxmox/storage-class"
ds "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
rs "github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
)
var dataSourceSchema = ds.Schema{
Attributes: map[string]ds.Attribute{
"filters": filter.Schema(),
"zfs_storage_classes": ds.ListNestedAttribute{
Computed: true,
NestedObject: ds.NestedAttributeObject{
Attributes: map[string]ds.Attribute{
"id": ds.StringAttribute{
Computed: true,
Description: "The identifier of the storage class.",
},
"nodes": ds.ListAttribute{
Computed: true,
ElementType: types.StringType,
Description: "Nodes that implement this storage class.",
},
"content_types": ds.ListAttribute{
Computed: true,
ElementType: types.StringType,
Description: "The content types that can be stored on this storage class.",
},
"pool": ds.StringAttribute{
Computed: true,
Description: "The ZFS pool of the storage.",
},
"mount": ds.StringAttribute{
Computed: true,
Description: "The path the ZFS pool should be mounted at on each node.",
},
},
},
},
},
}
var resourceSchema = rs.Schema{
Attributes: map[string]rs.Attribute{
"id": rs.StringAttribute{
Required: true,
Description: "The id of the ZFS storage class.",
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"pool": rs.StringAttribute{
Required: true,
Description: "The ZFS pool of the storage.",
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"mount": rs.StringAttribute{
Computed: true,
Description: "The path the ZFS pool should be mounted at on each node.",
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"nodes": rs.ListAttribute{
Optional: true,
Computed: true,
ElementType: types.StringType,
Description: "Nodes that implement this storage class.",
PlanModifiers: []planmodifier.List{
listplanmodifier.UseStateForUnknown(),
},
},
"content_types": rs.ListAttribute{
Optional: true,
Computed: true,
ElementType: types.StringType,
Description: "The content types that can be stored on this storage class.",
PlanModifiers: []planmodifier.List{
listplanmodifier.UseStateForUnknown(),
},
Validators: storage.ContentTypeValidator(
"images",
"rootdir",
),
},
},
}