-
Notifications
You must be signed in to change notification settings - Fork 89
/
schema_metadata.go
68 lines (65 loc) · 2.86 KB
/
schema_metadata.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
package argocd
import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func metadataSchema(name string) *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Description: fmt.Sprintf("Standard %s's metadata. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata", name),
Required: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: metadataFields(name),
},
}
}
func metadataFields(objectName string) map[string]*schema.Schema {
return map[string]*schema.Schema{
"annotations": {
Type: schema.TypeMap,
Description: fmt.Sprintf("An unstructured key value map stored with the %s that may be used to store arbitrary metadata. More info: http://kubernetes.io/docs/user-guide/annotations", objectName),
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
ValidateFunc: validateMetadataAnnotations,
},
"generation": {
Type: schema.TypeInt,
Description: "A sequence number representing a specific generation of the desired state.",
Computed: true,
},
"labels": {
Type: schema.TypeMap,
Description: fmt.Sprintf("Map of string keys and values that can be used to organize and categorize (scope and select) the %s. May match selectors of replication controllers and services. More info: http://kubernetes.io/docs/user-guide/labels", objectName),
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
ValidateFunc: validateMetadataLabels,
},
"name": {
Type: schema.TypeString,
Description: fmt.Sprintf("Name of the %s, must be unique. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names", objectName),
Optional: true,
ForceNew: true,
Computed: true,
ValidateFunc: validateMetadataName,
},
"namespace": {
Type: schema.TypeString,
Description: fmt.Sprintf("Namespace of the %s, must be unique. Cannot be updated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/", objectName),
Optional: true,
ForceNew: true,
Computed: true,
ValidateFunc: validateMetadataName,
},
"resource_version": {
Type: schema.TypeString,
Description: fmt.Sprintf("An opaque value that represents the internal version of this %s that can be used by clients to determine when %s has changed. Read more: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency", objectName, objectName),
Computed: true,
},
"uid": {
Type: schema.TypeString,
Description: fmt.Sprintf("The unique in time and space value for this %s. More info: http://kubernetes.io/docs/user-guide/identifiers#uids", objectName),
Computed: true,
},
}
}