Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b6fa0f5b
Commit
b6fa0f5b
authored
May 20, 2019
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AdmissionRegistration API changes: MatchPolicy
parent
fc495f45
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
0 deletions
+67
-0
fuzzer.go
pkg/apis/admissionregistration/fuzzer/fuzzer.go
+2
-0
types.go
pkg/apis/admissionregistration/types.go
+26
-0
defaults.go
pkg/apis/admissionregistration/v1beta1/defaults.go
+4
-0
validation.go
pkg/apis/admissionregistration/validation/validation.go
+8
-0
types.go
...ing/src/k8s.io/api/admissionregistration/v1beta1/types.go
+27
-0
No files found.
pkg/apis/admissionregistration/fuzzer/fuzzer.go
View file @
b6fa0f5b
...
...
@@ -37,6 +37,8 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
c
.
FuzzNoCustom
(
obj
)
// fuzz self without calling this function again
p
:=
admissionregistration
.
FailurePolicyType
(
"Fail"
)
obj
.
FailurePolicy
=
&
p
m
:=
admissionregistration
.
MatchPolicyType
(
"Exact"
)
obj
.
MatchPolicy
=
&
m
s
:=
admissionregistration
.
SideEffectClassUnknown
obj
.
SideEffects
=
&
s
if
obj
.
TimeoutSeconds
==
nil
{
...
...
pkg/apis/admissionregistration/types.go
View file @
b6fa0f5b
...
...
@@ -86,6 +86,16 @@ const (
Fail
FailurePolicyType
=
"Fail"
)
// MatchPolicyType specifies the type of match policy
type
MatchPolicyType
string
const
(
// Exact means requests should only be sent to the webhook if they exactly match a given rule
Exact
MatchPolicyType
=
"Exact"
// Equivalent means requests should be sent to the webhook if they modify a resource listed in rules via another API group or version.
Equivalent
MatchPolicyType
=
"Equivalent"
)
// SideEffectClass denotes the type of side effects resulting from calling the webhook
type
SideEffectClass
string
...
...
@@ -177,6 +187,22 @@ type Webhook struct {
// +optional
FailurePolicy
*
FailurePolicyType
// matchPolicy defines how the "rules" list is used to match incoming requests.
// Allowed values are "Exact" or "Equivalent".
//
// - Exact: match a request only if it exactly matches a specified rule.
// For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
// but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
// a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.
//
// - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version.
// For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
// and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
// a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.
//
// +optional
MatchPolicy
*
MatchPolicyType
// NamespaceSelector decides whether to run the webhook on an object based
// on whether the namespace for that object matches the selector. If the
// object itself is a namespace, the matching is performed on
...
...
pkg/apis/admissionregistration/v1beta1/defaults.go
View file @
b6fa0f5b
...
...
@@ -32,6 +32,10 @@ func SetDefaults_Webhook(obj *admissionregistrationv1beta1.Webhook) {
policy
:=
admissionregistrationv1beta1
.
Ignore
obj
.
FailurePolicy
=
&
policy
}
if
obj
.
MatchPolicy
==
nil
{
policy
:=
admissionregistrationv1beta1
.
Exact
obj
.
MatchPolicy
=
&
policy
}
if
obj
.
NamespaceSelector
==
nil
{
selector
:=
metav1
.
LabelSelector
{}
obj
.
NamespaceSelector
=
&
selector
...
...
pkg/apis/admissionregistration/validation/validation.go
View file @
b6fa0f5b
...
...
@@ -231,6 +231,9 @@ func validateWebhook(hook *admissionregistration.Webhook, fldPath *field.Path) f
if
hook
.
FailurePolicy
!=
nil
&&
!
supportedFailurePolicies
.
Has
(
string
(
*
hook
.
FailurePolicy
))
{
allErrors
=
append
(
allErrors
,
field
.
NotSupported
(
fldPath
.
Child
(
"failurePolicy"
),
*
hook
.
FailurePolicy
,
supportedFailurePolicies
.
List
()))
}
if
hook
.
MatchPolicy
!=
nil
&&
!
supportedMatchPolicies
.
Has
(
string
(
*
hook
.
MatchPolicy
))
{
allErrors
=
append
(
allErrors
,
field
.
NotSupported
(
fldPath
.
Child
(
"matchPolicy"
),
*
hook
.
MatchPolicy
,
supportedMatchPolicies
.
List
()))
}
if
hook
.
SideEffects
!=
nil
&&
!
supportedSideEffectClasses
.
Has
(
string
(
*
hook
.
SideEffects
))
{
allErrors
=
append
(
allErrors
,
field
.
NotSupported
(
fldPath
.
Child
(
"sideEffects"
),
*
hook
.
SideEffects
,
supportedSideEffectClasses
.
List
()))
}
...
...
@@ -259,6 +262,11 @@ var supportedFailurePolicies = sets.NewString(
string
(
admissionregistration
.
Fail
),
)
var
supportedMatchPolicies
=
sets
.
NewString
(
string
(
admissionregistration
.
Exact
),
string
(
admissionregistration
.
Equivalent
),
)
var
supportedSideEffectClasses
=
sets
.
NewString
(
string
(
admissionregistration
.
SideEffectClassUnknown
),
string
(
admissionregistration
.
SideEffectClassNone
),
...
...
staging/src/k8s.io/api/admissionregistration/v1beta1/types.go
View file @
b6fa0f5b
...
...
@@ -84,6 +84,16 @@ const (
Fail
FailurePolicyType
=
"Fail"
)
// MatchPolicyType specifies the type of match policy
type
MatchPolicyType
string
const
(
// Exact means requests should only be sent to the webhook if they exactly match a given rule
Exact
MatchPolicyType
=
"Exact"
// Equivalent means requests should be sent to the webhook if they modify a resource listed in rules via another API group or version.
Equivalent
MatchPolicyType
=
"Equivalent"
)
type
SideEffectClass
string
const
(
...
...
@@ -186,6 +196,23 @@ type Webhook struct {
// +optional
FailurePolicy
*
FailurePolicyType
`json:"failurePolicy,omitempty" protobuf:"bytes,4,opt,name=failurePolicy,casttype=FailurePolicyType"`
// matchPolicy defines how the "rules" list is used to match incoming requests.
// Allowed values are "Exact" or "Equivalent".
//
// - Exact: match a request only if it exactly matches a specified rule.
// For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
// but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
// a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.
//
// - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version.
// For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
// and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
// a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.
//
// Defaults to "Exact"
// +optional
MatchPolicy
*
MatchPolicyType
`json:"matchPolicy,omitempty" protobuf:"bytes,9,opt,name=matchPolicy,casttype=MatchPolicyType"`
// NamespaceSelector decides whether to run the webhook on an object based
// on whether the namespace for that object matches the selector. If the
// object itself is a namespace, the matching is performed on
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment