From 240ae6d9218b69733c130481be3558d91238a4d6 Mon Sep 17 00:00:00 2001 From: Vladislav Rassokhin Date: Thu, 28 Mar 2019 15:32:12 +0300 Subject: [PATCH] Simplify DefaultFunc to just Default --- kubernetes/schema_pod_spec.go | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/kubernetes/schema_pod_spec.go b/kubernetes/schema_pod_spec.go index 2f22e509b6..133cd6e598 100644 --- a/kubernetes/schema_pod_spec.go +++ b/kubernetes/schema_pod_spec.go @@ -43,7 +43,7 @@ func podSpecFields(isUpdatable, isDeprecated, isComputed bool) map[string]*schem Type: schema.TypeString, Optional: true, Computed: isComputed, - DefaultFunc: defaultIfNotComputed(isComputed, "ClusterFirst"), + Default: defaultIfNotComputed(isComputed, "ClusterFirst"), Description: "Set DNS policy for containers within the pod. One of 'ClusterFirst' or 'Default'. Defaults to 'ClusterFirst'.", Deprecated: deprecatedMessage, }, @@ -51,7 +51,7 @@ func podSpecFields(isUpdatable, isDeprecated, isComputed bool) map[string]*schem Type: schema.TypeBool, Optional: true, Computed: isComputed, - DefaultFunc: defaultIfNotComputed(isComputed, false), + Default: defaultIfNotComputed(isComputed, false), Description: "Use the host's ipc namespace. Optional: Default to false.", Deprecated: deprecatedMessage, }, @@ -59,7 +59,7 @@ func podSpecFields(isUpdatable, isDeprecated, isComputed bool) map[string]*schem Type: schema.TypeBool, Optional: true, Computed: isComputed, - DefaultFunc: defaultIfNotComputed(isComputed, false), + Default: defaultIfNotComputed(isComputed, false), Description: "Host networking requested for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified.", Deprecated: deprecatedMessage, }, @@ -68,7 +68,7 @@ func podSpecFields(isUpdatable, isDeprecated, isComputed bool) map[string]*schem Type: schema.TypeBool, Optional: true, Computed: isComputed, - DefaultFunc: defaultIfNotComputed(isComputed, false), + Default: defaultIfNotComputed(isComputed, false), Description: "Use the host's pid namespace.", Deprecated: deprecatedMessage, }, @@ -114,7 +114,7 @@ func podSpecFields(isUpdatable, isDeprecated, isComputed bool) map[string]*schem Type: schema.TypeString, Optional: true, Computed: isComputed, - DefaultFunc: defaultIfNotComputed(isComputed, "Always"), + Default: defaultIfNotComputed(isComputed, "Always"), Description: "Restart policy for all containers within the pod. One of Always, OnFailure, Never. More info: http://kubernetes.io/docs/user-guide/pod-states#restartpolicy.", Deprecated: deprecatedMessage, }, @@ -180,7 +180,7 @@ func podSpecFields(isUpdatable, isDeprecated, isComputed bool) map[string]*schem Type: schema.TypeInt, Optional: true, Computed: isComputed, - DefaultFunc: defaultIfNotComputed(isComputed, 30), + Default: defaultIfNotComputed(isComputed, 30), ValidateFunc: validateTerminationGracePeriodSeconds, Description: "Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period will be used instead. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process.", Deprecated: deprecatedMessage, @@ -213,14 +213,11 @@ func podSpecFields(isUpdatable, isDeprecated, isComputed bool) map[string]*schem return s } -func defaultIfNotComputed(isComputed bool, defaultValue interface{}) schema.SchemaDefaultFunc { - return func() (interface{}, error) { - if isComputed { - return nil, nil - } - - return defaultValue, nil +func defaultIfNotComputed(isComputed bool, defaultValue interface{}) interface{} { + if isComputed { + return nil } + return defaultValue } func volumeSchema() *schema.Resource {