Add container restart rules to API

Kubernetes-commit: af595a44aefcbf01dfad82c40af2e97346c938d9
This commit is contained in:
Yuan Wang 2025-07-01 02:33:00 +00:00 committed by Kubernetes Publisher
parent 6314d905de
commit 3d6860cb41
7 changed files with 184 additions and 0 deletions

View File

@ -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.

View File

@ -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
}

View File

@ -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
}

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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"):