kubernetes: Make generatable name optional in metadataSchema
This commit is contained in:
parent
735dfc416d
commit
793ce368fc
|
@ -25,7 +25,7 @@ func resourceKubernetesNamespace() *schema.Resource {
|
|||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"metadata": metadataSchema("namespace"),
|
||||
"metadata": metadataSchema("namespace", true),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ func metadataFields(objectName string) map[string]*schema.Schema {
|
|||
ForceNew: true,
|
||||
Computed: true,
|
||||
ValidateFunc: validateName,
|
||||
ConflictsWith: []string{"metadata.generate_name"},
|
||||
},
|
||||
"resource_version": {
|
||||
Type: schema.TypeString,
|
||||
|
@ -52,8 +51,10 @@ func metadataFields(objectName string) map[string]*schema.Schema {
|
|||
}
|
||||
}
|
||||
|
||||
func metadataSchema(objectName string) *schema.Schema {
|
||||
func metadataSchema(objectName string, generatableName bool) *schema.Schema {
|
||||
fields := metadataFields(objectName)
|
||||
|
||||
if generatableName {
|
||||
fields["generate_name"] = &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Description: "Prefix, used by the server, to generate a unique name ONLY IF the `name` field has not been provided. This value will also be combined with a unique suffix. Read more: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#idempotency",
|
||||
|
@ -62,6 +63,8 @@ func metadataSchema(objectName string) *schema.Schema {
|
|||
ValidateFunc: validateGenerateName,
|
||||
ConflictsWith: []string{"metadata.name"},
|
||||
}
|
||||
fields["name"].ConflictsWith = []string{"metadata.generate_name"}
|
||||
}
|
||||
|
||||
return &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
|
@ -92,6 +95,7 @@ func namespacedMetadataSchema(objectName string, generatableName bool) *schema.S
|
|||
ValidateFunc: validateGenerateName,
|
||||
ConflictsWith: []string{"metadata.name"},
|
||||
}
|
||||
fields["name"].ConflictsWith = []string{"metadata.generate_name"}
|
||||
}
|
||||
|
||||
return &schema.Schema{
|
||||
|
|
|
@ -68,7 +68,9 @@ func expandStringMap(m map[string]interface{}) map[string]string {
|
|||
func flattenMetadata(meta api.ObjectMeta) []map[string]interface{} {
|
||||
m := make(map[string]interface{})
|
||||
m["annotations"] = filterAnnotations(meta.Annotations)
|
||||
if meta.GenerateName != "" {
|
||||
m["generate_name"] = meta.GenerateName
|
||||
}
|
||||
m["labels"] = meta.Labels
|
||||
m["name"] = meta.Name
|
||||
m["resource_version"] = meta.ResourceVersion
|
||||
|
|
Loading…
Reference in New Issue