mirror of
https://github.com/kubernetes/client-go.git
synced 2025-08-08 18:57:24 +00:00
Merge pull request #132642 from yuanwang04/restart-rules
Implement container restart policy rules Kubernetes-commit: 26045b2fab22857c5b8a836ad709df717637491a
This commit is contained in:
commit
bce2be2f20
@ -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.
|
||||
|
52
applyconfigurations/core/v1/containerrestartrule.go
Normal file
52
applyconfigurations/core/v1/containerrestartrule.go
Normal 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
|
||||
}
|
@ -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
|
||||
}
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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"):
|
||||
|
2
go.mod
2
go.mod
@ -25,7 +25,7 @@ require (
|
||||
golang.org/x/time v0.9.0
|
||||
google.golang.org/protobuf v1.36.5
|
||||
gopkg.in/evanphx/json-patch.v4 v4.12.0
|
||||
k8s.io/api v0.0.0-20250725024533-ed2eb37e36f7
|
||||
k8s.io/api v0.0.0-20250725024534-53dd5462e729
|
||||
k8s.io/apimachinery v0.0.0-20250724224258-50e39b11cd32
|
||||
k8s.io/klog/v2 v2.130.1
|
||||
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b
|
||||
|
4
go.sum
4
go.sum
@ -150,8 +150,8 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
k8s.io/api v0.0.0-20250725024533-ed2eb37e36f7 h1:pignGgNAV6vmwxzdSNqBSbV5Z/ZGZSmQ9rdKwM9tgvU=
|
||||
k8s.io/api v0.0.0-20250725024533-ed2eb37e36f7/go.mod h1:h7pQu2oCQ3ccFA95Gaxuu7JO+0gHm6uxdKA4dLNL3Y8=
|
||||
k8s.io/api v0.0.0-20250725024534-53dd5462e729 h1:raeWWJ+/+yxrpn2KAvZgxic537l2Ejpa8nnLaCO7+7Y=
|
||||
k8s.io/api v0.0.0-20250725024534-53dd5462e729/go.mod h1:h7pQu2oCQ3ccFA95Gaxuu7JO+0gHm6uxdKA4dLNL3Y8=
|
||||
k8s.io/apimachinery v0.0.0-20250724224258-50e39b11cd32 h1:XbDM37tJSNp0ga7QZkizY+qxKJEA0DFe+nqssKruths=
|
||||
k8s.io/apimachinery v0.0.0-20250724224258-50e39b11cd32/go.mod h1:mjSAX6740hY31nMwwbFVIcjVaXzV46iZzqDA+UfugZ8=
|
||||
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
|
||||
|
Loading…
Reference in New Issue
Block a user