mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
api
This commit is contained in:
parent
95fa928ecb
commit
70f1b052e3
@ -249,6 +249,20 @@ type ValidatingWebhook struct {
|
|||||||
// +optional
|
// +optional
|
||||||
NamespaceSelector *metav1.LabelSelector
|
NamespaceSelector *metav1.LabelSelector
|
||||||
|
|
||||||
|
// ObjectSelector decides whether to run the webhook based on if the
|
||||||
|
// object has matching labels. objectSelector is evaluated against both
|
||||||
|
// the oldObject and newObject that would be sent to the webhook, and
|
||||||
|
// is considered to match if either object matches the selector. A null
|
||||||
|
// object (oldObject in the case of create, or newObject in the case of
|
||||||
|
// delete) or an object that cannot have labels (like a
|
||||||
|
// DeploymentRollback or a PodProxyOptions object) is not considered to
|
||||||
|
// match.
|
||||||
|
// Use the object selector only if the webhook is opt-in, because end
|
||||||
|
// users may skip the admission webhook by setting the labels.
|
||||||
|
// Default to the empty LabelSelector, which matches everything.
|
||||||
|
// +optional
|
||||||
|
ObjectSelector *metav1.LabelSelector
|
||||||
|
|
||||||
// SideEffects states whether this webhookk has side effects.
|
// SideEffects states whether this webhookk has side effects.
|
||||||
// Acceptable values are: Unknown, None, Some, NoneOnDryRun
|
// Acceptable values are: Unknown, None, Some, NoneOnDryRun
|
||||||
// Webhooks with side effects MUST implement a reconciliation system, since a request may be
|
// Webhooks with side effects MUST implement a reconciliation system, since a request may be
|
||||||
@ -359,6 +373,20 @@ type MutatingWebhook struct {
|
|||||||
// +optional
|
// +optional
|
||||||
NamespaceSelector *metav1.LabelSelector
|
NamespaceSelector *metav1.LabelSelector
|
||||||
|
|
||||||
|
// ObjectSelector decides whether to run the webhook based on if the
|
||||||
|
// object has matching labels. objectSelector is evaluated against both
|
||||||
|
// the oldObject and newObject that would be sent to the webhook, and
|
||||||
|
// is considered to match if either object matches the selector. A null
|
||||||
|
// object (oldObject in the case of create, or newObject in the case of
|
||||||
|
// delete) or an object that cannot have labels (like a
|
||||||
|
// DeploymentRollback or a PodProxyOptions object) is not considered to
|
||||||
|
// match.
|
||||||
|
// Use the object selector only if the webhook is opt-in, because end
|
||||||
|
// users may skip the admission webhook by setting the labels.
|
||||||
|
// Default to the empty LabelSelector, which matches everything.
|
||||||
|
// +optional
|
||||||
|
ObjectSelector *metav1.LabelSelector
|
||||||
|
|
||||||
// SideEffects states whether this webhookk has side effects.
|
// SideEffects states whether this webhookk has side effects.
|
||||||
// Acceptable values are: Unknown, None, Some, NoneOnDryRun
|
// Acceptable values are: Unknown, None, Some, NoneOnDryRun
|
||||||
// Webhooks with side effects MUST implement a reconciliation system, since a request may be
|
// Webhooks with side effects MUST implement a reconciliation system, since a request may be
|
||||||
|
@ -40,6 +40,10 @@ func SetDefaults_ValidatingWebhook(obj *admissionregistrationv1beta1.ValidatingW
|
|||||||
selector := metav1.LabelSelector{}
|
selector := metav1.LabelSelector{}
|
||||||
obj.NamespaceSelector = &selector
|
obj.NamespaceSelector = &selector
|
||||||
}
|
}
|
||||||
|
if obj.ObjectSelector == nil {
|
||||||
|
selector := metav1.LabelSelector{}
|
||||||
|
obj.ObjectSelector = &selector
|
||||||
|
}
|
||||||
if obj.SideEffects == nil {
|
if obj.SideEffects == nil {
|
||||||
// TODO: revisit/remove this default and possibly make the field required when promoting to v1
|
// TODO: revisit/remove this default and possibly make the field required when promoting to v1
|
||||||
unknown := admissionregistrationv1beta1.SideEffectClassUnknown
|
unknown := admissionregistrationv1beta1.SideEffectClassUnknown
|
||||||
@ -68,6 +72,10 @@ func SetDefaults_MutatingWebhook(obj *admissionregistrationv1beta1.MutatingWebho
|
|||||||
selector := metav1.LabelSelector{}
|
selector := metav1.LabelSelector{}
|
||||||
obj.NamespaceSelector = &selector
|
obj.NamespaceSelector = &selector
|
||||||
}
|
}
|
||||||
|
if obj.ObjectSelector == nil {
|
||||||
|
selector := metav1.LabelSelector{}
|
||||||
|
obj.ObjectSelector = &selector
|
||||||
|
}
|
||||||
if obj.SideEffects == nil {
|
if obj.SideEffects == nil {
|
||||||
// TODO: revisit/remove this default and possibly make the field required when promoting to v1
|
// TODO: revisit/remove this default and possibly make the field required when promoting to v1
|
||||||
unknown := admissionregistrationv1beta1.SideEffectClassUnknown
|
unknown := admissionregistrationv1beta1.SideEffectClassUnknown
|
||||||
|
@ -245,6 +245,10 @@ func validateValidatingWebhook(hook *admissionregistration.ValidatingWebhook, fl
|
|||||||
allErrors = append(allErrors, metav1validation.ValidateLabelSelector(hook.NamespaceSelector, fldPath.Child("namespaceSelector"))...)
|
allErrors = append(allErrors, metav1validation.ValidateLabelSelector(hook.NamespaceSelector, fldPath.Child("namespaceSelector"))...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if hook.ObjectSelector != nil {
|
||||||
|
allErrors = append(allErrors, metav1validation.ValidateLabelSelector(hook.ObjectSelector, fldPath.Child("objectSelector"))...)
|
||||||
|
}
|
||||||
|
|
||||||
cc := hook.ClientConfig
|
cc := hook.ClientConfig
|
||||||
switch {
|
switch {
|
||||||
case (cc.URL == nil) == (cc.Service == nil):
|
case (cc.URL == nil) == (cc.Service == nil):
|
||||||
@ -281,6 +285,9 @@ func validateMutatingWebhook(hook *admissionregistration.MutatingWebhook, fldPat
|
|||||||
if hook.NamespaceSelector != nil {
|
if hook.NamespaceSelector != nil {
|
||||||
allErrors = append(allErrors, metav1validation.ValidateLabelSelector(hook.NamespaceSelector, fldPath.Child("namespaceSelector"))...)
|
allErrors = append(allErrors, metav1validation.ValidateLabelSelector(hook.NamespaceSelector, fldPath.Child("namespaceSelector"))...)
|
||||||
}
|
}
|
||||||
|
if hook.ObjectSelector != nil {
|
||||||
|
allErrors = append(allErrors, metav1validation.ValidateLabelSelector(hook.ObjectSelector, fldPath.Child("objectSelector"))...)
|
||||||
|
}
|
||||||
if hook.ReinvocationPolicy != nil && !supportedReinvocationPolicies.Has(string(*hook.ReinvocationPolicy)) {
|
if hook.ReinvocationPolicy != nil && !supportedReinvocationPolicies.Has(string(*hook.ReinvocationPolicy)) {
|
||||||
allErrors = append(allErrors, field.NotSupported(fldPath.Child("reinvocationPolicy"), *hook.ReinvocationPolicy, supportedReinvocationPolicies.List()))
|
allErrors = append(allErrors, field.NotSupported(fldPath.Child("reinvocationPolicy"), *hook.ReinvocationPolicy, supportedReinvocationPolicies.List()))
|
||||||
}
|
}
|
||||||
|
@ -252,13 +252,27 @@ type ValidatingWebhook struct {
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// See
|
// See
|
||||||
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
|
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
|
||||||
// for more examples of label selectors.
|
// for more examples of label selectors.
|
||||||
//
|
//
|
||||||
// Default to the empty LabelSelector, which matches everything.
|
// Default to the empty LabelSelector, which matches everything.
|
||||||
// +optional
|
// +optional
|
||||||
NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty" protobuf:"bytes,5,opt,name=namespaceSelector"`
|
NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty" protobuf:"bytes,5,opt,name=namespaceSelector"`
|
||||||
|
|
||||||
|
// ObjectSelector decides whether to run the webhook based on if the
|
||||||
|
// object has matching labels. objectSelector is evaluated against both
|
||||||
|
// the oldObject and newObject that would be sent to the webhook, and
|
||||||
|
// is considered to match if either object matches the selector. A null
|
||||||
|
// object (oldObject in the case of create, or newObject in the case of
|
||||||
|
// delete) or an object that cannot have labels (like a
|
||||||
|
// DeploymentRollback or a PodProxyOptions object) is not considered to
|
||||||
|
// match.
|
||||||
|
// Use the object selector only if the webhook is opt-in, because end
|
||||||
|
// users may skip the admission webhook by setting the labels.
|
||||||
|
// Default to the empty LabelSelector, which matches everything.
|
||||||
|
// +optional
|
||||||
|
ObjectSelector *metav1.LabelSelector `json:"objectSelector,omitempty"`
|
||||||
|
|
||||||
// SideEffects states whether this webhookk has side effects.
|
// SideEffects states whether this webhookk has side effects.
|
||||||
// Acceptable values are: Unknown, None, Some, NoneOnDryRun
|
// Acceptable values are: Unknown, None, Some, NoneOnDryRun
|
||||||
// Webhooks with side effects MUST implement a reconciliation system, since a request may be
|
// Webhooks with side effects MUST implement a reconciliation system, since a request may be
|
||||||
@ -377,6 +391,20 @@ type MutatingWebhook struct {
|
|||||||
// +optional
|
// +optional
|
||||||
NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty" protobuf:"bytes,5,opt,name=namespaceSelector"`
|
NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty" protobuf:"bytes,5,opt,name=namespaceSelector"`
|
||||||
|
|
||||||
|
// ObjectSelector decides whether to run the webhook based on if the
|
||||||
|
// object has matching labels. objectSelector is evaluated against both
|
||||||
|
// the oldObject and newObject that would be sent to the webhook, and
|
||||||
|
// is considered to match if either object matches the selector. A null
|
||||||
|
// object (oldObject in the case of create, or newObject in the case of
|
||||||
|
// delete) or an object that cannot have labels (like a
|
||||||
|
// DeploymentRollback or a PodProxyOptions object) is not considered to
|
||||||
|
// match.
|
||||||
|
// Use the object selector only if the webhook is opt-in, because end
|
||||||
|
// users may skip the admission webhook by setting the labels.
|
||||||
|
// Default to the empty LabelSelector, which matches everything.
|
||||||
|
// +optional
|
||||||
|
ObjectSelector *metav1.LabelSelector `json:"objectSelector,omitempty" protobuf:"bytes,11,opt,name=objectSelector"`
|
||||||
|
|
||||||
// SideEffects states whether this webhookk has side effects.
|
// SideEffects states whether this webhookk has side effects.
|
||||||
// Acceptable values are: Unknown, None, Some, NoneOnDryRun
|
// Acceptable values are: Unknown, None, Some, NoneOnDryRun
|
||||||
// Webhooks with side effects MUST implement a reconciliation system, since a request may be
|
// Webhooks with side effects MUST implement a reconciliation system, since a request may be
|
||||||
|
Loading…
Reference in New Issue
Block a user