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
e4c219df
Commit
e4c219df
authored
Aug 07, 2018
by
jennybuckley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
block dry run if a webhook would be called
parent
972e1549
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
0 deletions
+16
-0
statuserror.go
...server/pkg/admission/plugin/webhook/errors/statuserror.go
+6
-0
dispatcher.go
...erver/pkg/admission/plugin/webhook/mutating/dispatcher.go
+5
-0
dispatcher.go
...ver/pkg/admission/plugin/webhook/validating/dispatcher.go
+5
-0
No files found.
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/errors/statuserror.go
View file @
e4c219df
...
@@ -45,3 +45,9 @@ func ToStatusErr(webhookName string, result *metav1.Status) *apierrors.StatusErr
...
@@ -45,3 +45,9 @@ func ToStatusErr(webhookName string, result *metav1.Status) *apierrors.StatusErr
ErrStatus
:
*
result
,
ErrStatus
:
*
result
,
}
}
}
}
// NewDryRunUnsupportedErr returns a StatusError with information about the webhook plugin
func
NewDryRunUnsupportedErr
(
webhookName
string
)
*
apierrors
.
StatusError
{
reason
:=
fmt
.
Sprintf
(
"admission webhook %q does not support dry run"
,
webhookName
)
return
apierrors
.
NewBadRequest
(
reason
)
}
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/mutating/dispatcher.go
View file @
e4c219df
...
@@ -82,6 +82,11 @@ func (a *mutatingDispatcher) Dispatch(ctx context.Context, attr *generic.Version
...
@@ -82,6 +82,11 @@ func (a *mutatingDispatcher) Dispatch(ctx context.Context, attr *generic.Version
// note that callAttrMutatingHook updates attr
// note that callAttrMutatingHook updates attr
func
(
a
*
mutatingDispatcher
)
callAttrMutatingHook
(
ctx
context
.
Context
,
h
*
v1beta1
.
Webhook
,
attr
*
generic
.
VersionedAttributes
)
error
{
func
(
a
*
mutatingDispatcher
)
callAttrMutatingHook
(
ctx
context
.
Context
,
h
*
v1beta1
.
Webhook
,
attr
*
generic
.
VersionedAttributes
)
error
{
if
attr
.
IsDryRun
()
{
// TODO: support this
webhookerrors
.
NewDryRunUnsupportedErr
(
h
.
Name
)
}
// Make the webhook request
// Make the webhook request
request
:=
request
.
CreateAdmissionReview
(
attr
)
request
:=
request
.
CreateAdmissionReview
(
attr
)
client
,
err
:=
a
.
cm
.
HookClient
(
h
)
client
,
err
:=
a
.
cm
.
HookClient
(
h
)
...
...
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating/dispatcher.go
View file @
e4c219df
...
@@ -97,6 +97,11 @@ func (d *validatingDispatcher) Dispatch(ctx context.Context, attr *generic.Versi
...
@@ -97,6 +97,11 @@ func (d *validatingDispatcher) Dispatch(ctx context.Context, attr *generic.Versi
}
}
func
(
d
*
validatingDispatcher
)
callHook
(
ctx
context
.
Context
,
h
*
v1beta1
.
Webhook
,
attr
*
generic
.
VersionedAttributes
)
error
{
func
(
d
*
validatingDispatcher
)
callHook
(
ctx
context
.
Context
,
h
*
v1beta1
.
Webhook
,
attr
*
generic
.
VersionedAttributes
)
error
{
if
attr
.
IsDryRun
()
{
// TODO: support this
webhookerrors
.
NewDryRunUnsupportedErr
(
h
.
Name
)
}
// Make the webhook request
// Make the webhook request
request
:=
request
.
CreateAdmissionReview
(
attr
)
request
:=
request
.
CreateAdmissionReview
(
attr
)
client
,
err
:=
d
.
cm
.
HookClient
(
h
)
client
,
err
:=
d
.
cm
.
HookClient
(
h
)
...
...
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