Skip to content

Commit 93d66a2

Browse files
jpbetzTim Bannister
andcommitted
Update API docs that are shared between VAP and MAP
Co-authored-by: Tim Bannister <[email protected]>
1 parent c9024e7 commit 93d66a2

File tree

2 files changed

+26
-20
lines changed
  • pkg/apis/admissionregistration
  • staging/src/k8s.io/api/admissionregistration/v1alpha1

2 files changed

+26
-20
lines changed

pkg/apis/admissionregistration/types.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,20 @@ const (
9292
type FailurePolicyType string
9393

9494
const (
95-
// Ignore means that an error calling the webhook is ignored.
95+
// Ignore means that an error calling the admission webhook or admission policy is ignored.
9696
Ignore FailurePolicyType = "Ignore"
97-
// Fail means that an error calling the webhook causes the admission to fail.
97+
// Fail means that an error calling the admission webhook or admission policy causes resource admission to fail.
9898
Fail FailurePolicyType = "Fail"
9999
)
100100

101101
// MatchPolicyType specifies the type of match policy
102102
type MatchPolicyType string
103103

104104
const (
105-
// Exact means requests should only be sent to the webhook if they exactly match a given rule
105+
// Exact means requests should only be sent to the admission webhook or admission policy if they exactly match a given rule.
106106
Exact MatchPolicyType = "Exact"
107-
// Equivalent means requests should be sent to the webhook if they modify a resource listed in rules via another API group or version.
107+
// Equivalent means requests should be sent to the admission webhook or admission policy if they modify a resource listed
108+
// in rules via another API group or version.
108109
Equivalent MatchPolicyType = "Equivalent"
109110
)
110111

@@ -617,9 +618,9 @@ type MatchResources struct {
617618
// Default to the empty LabelSelector, which matches everything.
618619
// +optional
619620
NamespaceSelector *metav1.LabelSelector
620-
// ObjectSelector decides whether to run the validation based on if the
621+
// ObjectSelector decides whether to run the policy based on if the
621622
// object has matching labels. objectSelector is evaluated against both
622-
// the oldObject and newObject that would be sent to the cel validation, and
623+
// the oldObject and newObject that would be sent to the cel policy, and
623624
// is considered to match if either object matches the selector. A null
624625
// object (oldObject in the case of create, or newObject in the case of
625626
// delete) or an object that cannot have labels (like a
@@ -630,12 +631,14 @@ type MatchResources struct {
630631
// Default to the empty LabelSelector, which matches everything.
631632
// +optional
632633
ObjectSelector *metav1.LabelSelector
633-
// ResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy matches.
634+
// ResourceRules describes what operations on what resources/subresources the policy matches.
634635
// The policy cares about an operation if it matches _any_ Rule.
636+
// +listType=atomic
635637
// +optional
636638
ResourceRules []NamedRuleWithOperations
637-
// ExcludeResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy should not care about.
639+
// ExcludeResourceRules describes what operations on what resources/subresources the policy should not care about.
638640
// The exclude rules take precedence over include rules (if a resource matches both, it is excluded)
641+
// +listType=atomic
639642
// +optional
640643
ExcludeResourceRules []NamedRuleWithOperations
641644
// matchPolicy defines how the "MatchResources" list is used to match incoming requests.
@@ -644,12 +647,12 @@ type MatchResources struct {
644647
// - Exact: match a request only if it exactly matches a specified rule.
645648
// For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
646649
// but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
647-
// a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the ValidatingAdmissionPolicy.
650+
// a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the policy.
648651
//
649652
// - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version.
650653
// For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
651654
// and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
652-
// a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the ValidatingAdmissionPolicy.
655+
// a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the policy.
653656
//
654657
// Defaults to "Equivalent"
655658
// +optional

staging/src/k8s.io/api/admissionregistration/v1alpha1/types.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ const (
5656
type FailurePolicyType string
5757

5858
const (
59-
// Ignore means that an error calling the webhook is ignored.
59+
// Ignore means that an error calling the admission webhook or admission policy is ignored.
6060
Ignore FailurePolicyType = "Ignore"
61-
// Fail means that an error calling the webhook causes the admission to fail.
61+
// Fail means that an error calling the admission webhook or admission policy causes resource admission to fail.
6262
Fail FailurePolicyType = "Fail"
6363
)
6464

@@ -67,9 +67,11 @@ const (
6767
type MatchPolicyType string
6868

6969
const (
70-
// Exact means requests should only be sent to the webhook if they exactly match a given rule.
70+
// Exact means requests should only be sent to the admission webhook or admission policy if they exactly match a given rule.
7171
Exact MatchPolicyType = "Exact"
72-
// Equivalent means requests should be sent to the webhook if they modify a resource listed in rules via another API group or version.
72+
// Equivalent means requests should be sent to the admission webhook or admission policy if they modify a resource listed
73+
// in rules via an equivalent API group or version. For example, `autoscaling/v1` and `autoscaling/v2`
74+
// HorizontalPodAutoscalers are equivalent: the same set of resources appear via both APIs.
7375
Equivalent MatchPolicyType = "Equivalent"
7476
)
7577

@@ -577,9 +579,9 @@ type MatchResources struct {
577579
// Default to the empty LabelSelector, which matches everything.
578580
// +optional
579581
NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty" protobuf:"bytes,1,opt,name=namespaceSelector"`
580-
// ObjectSelector decides whether to run the validation based on if the
582+
// ObjectSelector decides whether to run the policy based on if the
581583
// object has matching labels. objectSelector is evaluated against both
582-
// the oldObject and newObject that would be sent to the cel validation, and
584+
// the oldObject and newObject that would be sent to the policy's expression (CEL), and
583585
// is considered to match if either object matches the selector. A null
584586
// object (oldObject in the case of create, or newObject in the case of
585587
// delete) or an object that cannot have labels (like a
@@ -590,12 +592,12 @@ type MatchResources struct {
590592
// Default to the empty LabelSelector, which matches everything.
591593
// +optional
592594
ObjectSelector *metav1.LabelSelector `json:"objectSelector,omitempty" protobuf:"bytes,2,opt,name=objectSelector"`
593-
// ResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy matches.
595+
// ResourceRules describes what operations on what resources/subresources the admission policy matches.
594596
// The policy cares about an operation if it matches _any_ Rule.
595597
// +listType=atomic
596598
// +optional
597599
ResourceRules []NamedRuleWithOperations `json:"resourceRules,omitempty" protobuf:"bytes,3,rep,name=resourceRules"`
598-
// ExcludeResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy should not care about.
600+
// ExcludeResourceRules describes what operations on what resources/subresources the policy should not care about.
599601
// The exclude rules take precedence over include rules (if a resource matches both, it is excluded)
600602
// +listType=atomic
601603
// +optional
@@ -606,12 +608,13 @@ type MatchResources struct {
606608
// - Exact: match a request only if it exactly matches a specified rule.
607609
// For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
608610
// but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
609-
// a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the ValidatingAdmissionPolicy.
611+
// the admission policy does not consider requests to apps/v1beta1 or extensions/v1beta1 API groups.
610612
//
611613
// - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version.
612614
// For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
613615
// and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
614-
// a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the ValidatingAdmissionPolicy.
616+
// the admission policy **does** consider requests made to apps/v1beta1 or extensions/v1beta1
617+
// API groups. The API server translates the request to a matched resource API if necessary.
615618
//
616619
// Defaults to "Equivalent"
617620
// +optional

0 commit comments

Comments
 (0)