From 3d6860cb41c91f98d40e9464e3315e4ac9ceb922 Mon Sep 17 00:00:00 2001 From: Yuan Wang Date: Tue, 1 Jul 2025 02:33:00 +0000 Subject: [PATCH] Add container restart rules to API Kubernetes-commit: af595a44aefcbf01dfad82c40af2e97346c938d9 --- applyconfigurations/core/v1/container.go | 14 +++++ .../core/v1/containerrestartrule.go | 52 ++++++++++++++++++ .../v1/containerrestartruleonexitcodes.go | 54 +++++++++++++++++++ .../core/v1/ephemeralcontainer.go | 13 +++++ .../core/v1/ephemeralcontainercommon.go | 14 +++++ applyconfigurations/internal/internal.go | 33 ++++++++++++ applyconfigurations/utils.go | 4 ++ 7 files changed, 184 insertions(+) create mode 100644 applyconfigurations/core/v1/containerrestartrule.go create mode 100644 applyconfigurations/core/v1/containerrestartruleonexitcodes.go diff --git a/applyconfigurations/core/v1/container.go b/applyconfigurations/core/v1/container.go index eed5f7d0..4694b12f 100644 --- a/applyconfigurations/core/v1/container.go +++ b/applyconfigurations/core/v1/container.go @@ -36,6 +36,7 @@ type ContainerApplyConfiguration struct { Resources *ResourceRequirementsApplyConfiguration `json:"resources,omitempty"` ResizePolicy []ContainerResizePolicyApplyConfiguration `json:"resizePolicy,omitempty"` RestartPolicy *corev1.ContainerRestartPolicy `json:"restartPolicy,omitempty"` + RestartPolicyRules []ContainerRestartRuleApplyConfiguration `json:"restartPolicyRules,omitempty"` VolumeMounts []VolumeMountApplyConfiguration `json:"volumeMounts,omitempty"` VolumeDevices []VolumeDeviceApplyConfiguration `json:"volumeDevices,omitempty"` LivenessProbe *ProbeApplyConfiguration `json:"livenessProbe,omitempty"` @@ -169,6 +170,19 @@ func (b *ContainerApplyConfiguration) WithRestartPolicy(value corev1.ContainerRe return b } +// WithRestartPolicyRules adds the given value to the RestartPolicyRules field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the RestartPolicyRules field. +func (b *ContainerApplyConfiguration) WithRestartPolicyRules(values ...*ContainerRestartRuleApplyConfiguration) *ContainerApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithRestartPolicyRules") + } + b.RestartPolicyRules = append(b.RestartPolicyRules, *values[i]) + } + return b +} + // WithVolumeMounts adds the given value to the VolumeMounts field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the VolumeMounts field. diff --git a/applyconfigurations/core/v1/containerrestartrule.go b/applyconfigurations/core/v1/containerrestartrule.go new file mode 100644 index 00000000..6ec09000 --- /dev/null +++ b/applyconfigurations/core/v1/containerrestartrule.go @@ -0,0 +1,52 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1 + +import ( + corev1 "k8s.io/api/core/v1" +) + +// ContainerRestartRuleApplyConfiguration represents a declarative configuration of the ContainerRestartRule type for use +// with apply. +type ContainerRestartRuleApplyConfiguration struct { + Action *corev1.ContainerRestartRuleAction `json:"action,omitempty"` + ExitCodes *ContainerRestartRuleOnExitCodesApplyConfiguration `json:"exitCodes,omitempty"` +} + +// ContainerRestartRuleApplyConfiguration constructs a declarative configuration of the ContainerRestartRule type for use with +// apply. +func ContainerRestartRule() *ContainerRestartRuleApplyConfiguration { + return &ContainerRestartRuleApplyConfiguration{} +} + +// WithAction sets the Action field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Action field is set to the value of the last call. +func (b *ContainerRestartRuleApplyConfiguration) WithAction(value corev1.ContainerRestartRuleAction) *ContainerRestartRuleApplyConfiguration { + b.Action = &value + return b +} + +// WithExitCodes sets the ExitCodes field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ExitCodes field is set to the value of the last call. +func (b *ContainerRestartRuleApplyConfiguration) WithExitCodes(value *ContainerRestartRuleOnExitCodesApplyConfiguration) *ContainerRestartRuleApplyConfiguration { + b.ExitCodes = value + return b +} diff --git a/applyconfigurations/core/v1/containerrestartruleonexitcodes.go b/applyconfigurations/core/v1/containerrestartruleonexitcodes.go new file mode 100644 index 00000000..6bfd9619 --- /dev/null +++ b/applyconfigurations/core/v1/containerrestartruleonexitcodes.go @@ -0,0 +1,54 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1 + +import ( + corev1 "k8s.io/api/core/v1" +) + +// ContainerRestartRuleOnExitCodesApplyConfiguration represents a declarative configuration of the ContainerRestartRuleOnExitCodes type for use +// with apply. +type ContainerRestartRuleOnExitCodesApplyConfiguration struct { + Operator *corev1.ContainerRestartRuleOnExitCodesOperator `json:"operator,omitempty"` + Values []int32 `json:"values,omitempty"` +} + +// ContainerRestartRuleOnExitCodesApplyConfiguration constructs a declarative configuration of the ContainerRestartRuleOnExitCodes type for use with +// apply. +func ContainerRestartRuleOnExitCodes() *ContainerRestartRuleOnExitCodesApplyConfiguration { + return &ContainerRestartRuleOnExitCodesApplyConfiguration{} +} + +// WithOperator sets the Operator field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Operator field is set to the value of the last call. +func (b *ContainerRestartRuleOnExitCodesApplyConfiguration) WithOperator(value corev1.ContainerRestartRuleOnExitCodesOperator) *ContainerRestartRuleOnExitCodesApplyConfiguration { + b.Operator = &value + return b +} + +// WithValues adds the given value to the Values field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Values field. +func (b *ContainerRestartRuleOnExitCodesApplyConfiguration) WithValues(values ...int32) *ContainerRestartRuleOnExitCodesApplyConfiguration { + for i := range values { + b.Values = append(b.Values, values[i]) + } + return b +} diff --git a/applyconfigurations/core/v1/ephemeralcontainer.go b/applyconfigurations/core/v1/ephemeralcontainer.go index 4b74439f..d41c9853 100644 --- a/applyconfigurations/core/v1/ephemeralcontainer.go +++ b/applyconfigurations/core/v1/ephemeralcontainer.go @@ -147,6 +147,19 @@ func (b *EphemeralContainerApplyConfiguration) WithRestartPolicy(value corev1.Co return b } +// WithRestartPolicyRules adds the given value to the RestartPolicyRules field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the RestartPolicyRules field. +func (b *EphemeralContainerApplyConfiguration) WithRestartPolicyRules(values ...*ContainerRestartRuleApplyConfiguration) *EphemeralContainerApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithRestartPolicyRules") + } + b.EphemeralContainerCommonApplyConfiguration.RestartPolicyRules = append(b.EphemeralContainerCommonApplyConfiguration.RestartPolicyRules, *values[i]) + } + return b +} + // WithVolumeMounts adds the given value to the VolumeMounts field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the VolumeMounts field. diff --git a/applyconfigurations/core/v1/ephemeralcontainercommon.go b/applyconfigurations/core/v1/ephemeralcontainercommon.go index d5d13d27..cd9bf08f 100644 --- a/applyconfigurations/core/v1/ephemeralcontainercommon.go +++ b/applyconfigurations/core/v1/ephemeralcontainercommon.go @@ -36,6 +36,7 @@ type EphemeralContainerCommonApplyConfiguration struct { Resources *ResourceRequirementsApplyConfiguration `json:"resources,omitempty"` ResizePolicy []ContainerResizePolicyApplyConfiguration `json:"resizePolicy,omitempty"` RestartPolicy *corev1.ContainerRestartPolicy `json:"restartPolicy,omitempty"` + RestartPolicyRules []ContainerRestartRuleApplyConfiguration `json:"restartPolicyRules,omitempty"` VolumeMounts []VolumeMountApplyConfiguration `json:"volumeMounts,omitempty"` VolumeDevices []VolumeDeviceApplyConfiguration `json:"volumeDevices,omitempty"` LivenessProbe *ProbeApplyConfiguration `json:"livenessProbe,omitempty"` @@ -169,6 +170,19 @@ func (b *EphemeralContainerCommonApplyConfiguration) WithRestartPolicy(value cor return b } +// WithRestartPolicyRules adds the given value to the RestartPolicyRules field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the RestartPolicyRules field. +func (b *EphemeralContainerCommonApplyConfiguration) WithRestartPolicyRules(values ...*ContainerRestartRuleApplyConfiguration) *EphemeralContainerCommonApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithRestartPolicyRules") + } + b.RestartPolicyRules = append(b.RestartPolicyRules, *values[i]) + } + return b +} + // WithVolumeMounts adds the given value to the VolumeMounts field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, values provided by each call will be appended to the VolumeMounts field. diff --git a/applyconfigurations/internal/internal.go b/applyconfigurations/internal/internal.go index cd102bab..20d28dad 100644 --- a/applyconfigurations/internal/internal.go +++ b/applyconfigurations/internal/internal.go @@ -5333,6 +5333,12 @@ var schemaYAML = typed.YAMLObject(`types: - name: restartPolicy type: scalar: string + - name: restartPolicyRules + type: + list: + elementType: + namedType: io.k8s.api.core.v1.ContainerRestartRule + elementRelationship: atomic - name: securityContext type: namedType: io.k8s.api.core.v1.SecurityContext @@ -5416,6 +5422,27 @@ var schemaYAML = typed.YAMLObject(`types: type: scalar: string default: "" +- name: io.k8s.api.core.v1.ContainerRestartRule + map: + fields: + - name: action + type: + scalar: string + - name: exitCodes + type: + namedType: io.k8s.api.core.v1.ContainerRestartRuleOnExitCodes +- name: io.k8s.api.core.v1.ContainerRestartRuleOnExitCodes + map: + fields: + - name: operator + type: + scalar: string + - name: values + type: + list: + elementType: + scalar: numeric + elementRelationship: associative - name: io.k8s.api.core.v1.ContainerState map: fields: @@ -5781,6 +5808,12 @@ var schemaYAML = typed.YAMLObject(`types: - name: restartPolicy type: scalar: string + - name: restartPolicyRules + type: + list: + elementType: + namedType: io.k8s.api.core.v1.ContainerRestartRule + elementRelationship: atomic - name: securityContext type: namedType: io.k8s.api.core.v1.SecurityContext diff --git a/applyconfigurations/utils.go b/applyconfigurations/utils.go index 0087977a..6c5959d9 100644 --- a/applyconfigurations/utils.go +++ b/applyconfigurations/utils.go @@ -726,6 +726,10 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &applyconfigurationscorev1.ContainerPortApplyConfiguration{} case corev1.SchemeGroupVersion.WithKind("ContainerResizePolicy"): return &applyconfigurationscorev1.ContainerResizePolicyApplyConfiguration{} + case corev1.SchemeGroupVersion.WithKind("ContainerRestartRule"): + return &applyconfigurationscorev1.ContainerRestartRuleApplyConfiguration{} + case corev1.SchemeGroupVersion.WithKind("ContainerRestartRuleOnExitCodes"): + return &applyconfigurationscorev1.ContainerRestartRuleOnExitCodesApplyConfiguration{} case corev1.SchemeGroupVersion.WithKind("ContainerState"): return &applyconfigurationscorev1.ContainerStateApplyConfiguration{} case corev1.SchemeGroupVersion.WithKind("ContainerStateRunning"):