From 8feede8b08ec661f996f0d00a36e0143cec43878 Mon Sep 17 00:00:00 2001 From: Arthur GURBANOV Date: Tue, 19 Mar 2024 18:10:12 +0100 Subject: [PATCH 1/5] add restart policy for init containers --- kubernetes/schema_container.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/kubernetes/schema_container.go b/kubernetes/schema_container.go index 9d1cdedeb1..42c7495edb 100644 --- a/kubernetes/schema_container.go +++ b/kubernetes/schema_container.go @@ -582,11 +582,24 @@ func containerFields(isUpdatable bool) map[string]*schema.Schema { MaxItems: 1, ForceNew: !isUpdatable, Computed: true, - Description: "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources", + Description: "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/", Elem: &schema.Resource{ Schema: resourcesFieldV1(isUpdatable), }, }, + "restart_policy": { + Type: schema.TypeString, + Optional: true, + Computed: isComputed, + ForceNew: !isUpdatable, + Default: conditionalDefault(!isComputed, string(corev1.RestartPolicyAlways)), + Description: "Restart policy for init container. One of Always, OnFailure, Never. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy.", + ValidateFunc: validation.StringInSlice([]string{ + string(corev1.RestartPolicyAlways), + string(corev1.RestartPolicyOnFailure), + string(corev1.RestartPolicyNever), + }, false), + }, "security_context": { Type: schema.TypeList, Optional: true, From 172fc9fa11509e310957ffcf7aad2d08fa26919b Mon Sep 17 00:00:00 2001 From: Arthur GURBANOV Date: Tue, 19 Mar 2024 18:12:03 +0100 Subject: [PATCH 2/5] rebase --- kubernetes/schema_container.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kubernetes/schema_container.go b/kubernetes/schema_container.go index 42c7495edb..21c15c96a3 100644 --- a/kubernetes/schema_container.go +++ b/kubernetes/schema_container.go @@ -582,8 +582,7 @@ func containerFields(isUpdatable bool) map[string]*schema.Schema { MaxItems: 1, ForceNew: !isUpdatable, Computed: true, - Description: "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/", - Elem: &schema.Resource{ + Description: "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources", Elem: &schema.Resource{ Schema: resourcesFieldV1(isUpdatable), }, }, From 350a4fba0be835c00a7c613aac590e28c4a8e67d Mon Sep 17 00:00:00 2001 From: Arthur GURBANOV Date: Tue, 19 Mar 2024 18:12:44 +0100 Subject: [PATCH 3/5] fix --- kubernetes/schema_container.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kubernetes/schema_container.go b/kubernetes/schema_container.go index 21c15c96a3..b84afa5662 100644 --- a/kubernetes/schema_container.go +++ b/kubernetes/schema_container.go @@ -582,7 +582,8 @@ func containerFields(isUpdatable bool) map[string]*schema.Schema { MaxItems: 1, ForceNew: !isUpdatable, Computed: true, - Description: "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources", Elem: &schema.Resource{ + Description: "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources", + Elem: &schema.Resource{ Schema: resourcesFieldV1(isUpdatable), }, }, From ba4feda7baaa53d0b939353e4653171ca345295c Mon Sep 17 00:00:00 2001 From: Arthur GURBANOV Date: Tue, 19 Mar 2024 18:13:24 +0100 Subject: [PATCH 4/5] fix whitespace --- kubernetes/schema_container.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes/schema_container.go b/kubernetes/schema_container.go index b84afa5662..d8ae120329 100644 --- a/kubernetes/schema_container.go +++ b/kubernetes/schema_container.go @@ -582,7 +582,7 @@ func containerFields(isUpdatable bool) map[string]*schema.Schema { MaxItems: 1, ForceNew: !isUpdatable, Computed: true, - Description: "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources", + Description: "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources", Elem: &schema.Resource{ Schema: resourcesFieldV1(isUpdatable), }, From 1e53b58adeca768de22ffc4c27930b92168afd75 Mon Sep 17 00:00:00 2001 From: Arthur GURBANOV Date: Wed, 20 Mar 2024 11:00:34 +0100 Subject: [PATCH 5/5] add change log --- .changelog/2449.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/2449.txt diff --git a/.changelog/2449.txt b/.changelog/2449.txt new file mode 100644 index 0000000000..5da09138a0 --- /dev/null +++ b/.changelog/2449.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +`kubernetes/schema_container.go`: add support of `restart_policy` option for sidecar init containers +``` \ No newline at end of file