-
Notifications
You must be signed in to change notification settings - Fork 98
/
base_attr_schema.go
58 lines (51 loc) · 1.46 KB
/
base_attr_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
package aci
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
func GetBaseAttrSchema() map[string]*schema.Schema {
return AppendAttrSchemas(map[string]*schema.Schema{}, GetDescriptionAttrSchema(), GetAnnotationAttrSchema())
}
func GetAllowEmptyAttrSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"allow_empty_result": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
},
}
}
// AppendBaseAttrSchema adds the BaseAttr to any schema
func AppendBaseAttrSchema(attrs map[string]*schema.Schema) map[string]*schema.Schema {
for key, value := range GetBaseAttrSchema() {
attrs[key] = value
}
return attrs
}
// AppendAttrSchemas adds a range of schemas to any schema
func AppendAttrSchemas(attrs map[string]*schema.Schema, mapsToAppend ...map[string]*schema.Schema) map[string]*schema.Schema {
for _, m := range mapsToAppend {
for key, value := range m {
attrs[key] = value
}
}
return attrs
}
func GetAnnotationAttrSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"annotation": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
DefaultFunc: func() (interface{}, error) {
return "orchestrator:terraform", nil
},
},
}
}
func GetDescriptionAttrSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"description": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},
}
}