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
970d2553
Commit
970d2553
authored
Oct 23, 2017
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
admission: { -> Mutating}Admit(admission.Attributes)
parent
02e16cb2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
8 deletions
+8
-8
admission_test.go
plugin/pkg/admission/initialresources/admission_test.go
+3
-3
admission_test.go
...n/pkg/admission/namespace/autoprovision/admission_test.go
+1
-1
interfaces.go
staging/src/k8s.io/apiserver/pkg/admission/interfaces.go
+2
-2
delete.go
...ing/src/k8s.io/apiserver/pkg/endpoints/handlers/delete.go
+2
-2
No files found.
plugin/pkg/admission/initialresources/admission_test.go
View file @
970d2553
...
@@ -110,7 +110,7 @@ func expectNoAnnotation(t *testing.T, pod *api.Pod) {
...
@@ -110,7 +110,7 @@ func expectNoAnnotation(t *testing.T, pod *api.Pod) {
}
}
}
}
func
admit
(
t
*
testing
.
T
,
ir
admission
.
Interface
,
pods
[]
*
api
.
Pod
)
{
func
admit
(
t
*
testing
.
T
,
ir
admission
.
Mutation
Interface
,
pods
[]
*
api
.
Pod
)
{
for
i
:=
range
pods
{
for
i
:=
range
pods
{
p
:=
pods
[
i
]
p
:=
pods
[
i
]
...
@@ -123,7 +123,7 @@ func admit(t *testing.T, ir admission.Interface, pods []*api.Pod) {
...
@@ -123,7 +123,7 @@ func admit(t *testing.T, ir admission.Interface, pods []*api.Pod) {
}
}
}
}
func
testAdminScenarios
(
t
*
testing
.
T
,
ir
admission
.
Interface
,
p
*
api
.
Pod
)
{
func
testAdminScenarios
(
t
*
testing
.
T
,
ir
admission
.
Mutation
Interface
,
p
*
api
.
Pod
)
{
podKind
:=
api
.
Kind
(
"Pod"
)
.
WithVersion
(
"version"
)
podKind
:=
api
.
Kind
(
"Pod"
)
.
WithVersion
(
"version"
)
podRes
:=
api
.
Resource
(
"pods"
)
.
WithVersion
(
"version"
)
podRes
:=
api
.
Resource
(
"pods"
)
.
WithVersion
(
"version"
)
...
@@ -151,7 +151,7 @@ func testAdminScenarios(t *testing.T, ir admission.Interface, p *api.Pod) {
...
@@ -151,7 +151,7 @@ func testAdminScenarios(t *testing.T, ir admission.Interface, p *api.Pod) {
}
}
}
}
func
performTest
(
t
*
testing
.
T
,
ir
admission
.
Interface
)
{
func
performTest
(
t
*
testing
.
T
,
ir
admission
.
Mutation
Interface
)
{
pods
:=
getPods
()
pods
:=
getPods
()
admit
(
t
,
ir
,
pods
)
admit
(
t
,
ir
,
pods
)
testAdminScenarios
(
t
,
ir
,
pods
[
0
])
testAdminScenarios
(
t
,
ir
,
pods
[
0
])
...
...
plugin/pkg/admission/namespace/autoprovision/admission_test.go
View file @
970d2553
...
@@ -35,7 +35,7 @@ import (
...
@@ -35,7 +35,7 @@ import (
)
)
// newHandlerForTest returns the admission controller configured for testing.
// newHandlerForTest returns the admission controller configured for testing.
func
newHandlerForTest
(
c
clientset
.
Interface
)
(
admission
.
Interface
,
informers
.
SharedInformerFactory
,
error
)
{
func
newHandlerForTest
(
c
clientset
.
Interface
)
(
admission
.
Mutation
Interface
,
informers
.
SharedInformerFactory
,
error
)
{
f
:=
informers
.
NewSharedInformerFactory
(
c
,
5
*
time
.
Minute
)
f
:=
informers
.
NewSharedInformerFactory
(
c
,
5
*
time
.
Minute
)
handler
:=
NewProvision
()
handler
:=
NewProvision
()
pluginInitializer
:=
kubeadmission
.
NewPluginInitializer
(
c
,
f
,
nil
,
nil
,
nil
,
nil
,
nil
)
pluginInitializer
:=
kubeadmission
.
NewPluginInitializer
(
c
,
f
,
nil
,
nil
,
nil
,
nil
,
nil
)
...
...
staging/src/k8s.io/apiserver/pkg/admission/interfaces.go
View file @
970d2553
...
@@ -63,8 +63,8 @@ type Interface interface {
...
@@ -63,8 +63,8 @@ type Interface interface {
// ValidationInterface is an abstract, pluggable interface for Admission Control decisions.
// ValidationInterface is an abstract, pluggable interface for Admission Control decisions.
type
ValidationInterface
interface
{
type
ValidationInterface
interface
{
// Validat
e
makes an admission decision based on the request attributes. It is NOT allowed to mutate
// Validat
ingAdmit
makes an admission decision based on the request attributes. It is NOT allowed to mutate
Validat
e
(
a
Attributes
)
(
err
error
)
Validat
ingAdmit
(
a
Attributes
)
(
err
error
)
// Handles returns true if this admission controller can handle the given operation
// Handles returns true if this admission controller can handle the given operation
// where operation can be one of CREATE, UPDATE, DELETE, or CONNECT
// where operation can be one of CREATE, UPDATE, DELETE, or CONNECT
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/delete.go
View file @
970d2553
...
@@ -106,7 +106,7 @@ func DeleteResource(r rest.GracefulDeleter, allowsOptions bool, scope RequestSco
...
@@ -106,7 +106,7 @@ func DeleteResource(r rest.GracefulDeleter, allowsOptions bool, scope RequestSco
if
validatingAdmission
!=
nil
&&
validatingAdmission
.
Handles
(
admission
.
Delete
)
{
if
validatingAdmission
!=
nil
&&
validatingAdmission
.
Handles
(
admission
.
Delete
)
{
userInfo
,
_
:=
request
.
UserFrom
(
ctx
)
userInfo
,
_
:=
request
.
UserFrom
(
ctx
)
err
=
validatingAdmission
.
Validat
e
(
admission
.
NewAttributesRecord
(
nil
,
nil
,
scope
.
Kind
,
namespace
,
name
,
scope
.
Resource
,
scope
.
Subresource
,
admission
.
Delete
,
userInfo
))
err
=
validatingAdmission
.
Validat
ingAdmit
(
admission
.
NewAttributesRecord
(
nil
,
nil
,
scope
.
Kind
,
namespace
,
name
,
scope
.
Resource
,
scope
.
Subresource
,
admission
.
Delete
,
userInfo
))
if
err
!=
nil
{
if
err
!=
nil
{
scope
.
err
(
err
,
w
,
req
)
scope
.
err
(
err
,
w
,
req
)
return
return
...
@@ -193,7 +193,7 @@ func DeleteCollection(r rest.CollectionDeleter, checkBody bool, scope RequestSco
...
@@ -193,7 +193,7 @@ func DeleteCollection(r rest.CollectionDeleter, checkBody bool, scope RequestSco
if
validatingAdmission
!=
nil
&&
validatingAdmission
.
Handles
(
admission
.
Delete
)
{
if
validatingAdmission
!=
nil
&&
validatingAdmission
.
Handles
(
admission
.
Delete
)
{
userInfo
,
_
:=
request
.
UserFrom
(
ctx
)
userInfo
,
_
:=
request
.
UserFrom
(
ctx
)
err
=
validatingAdmission
.
Validat
e
(
admission
.
NewAttributesRecord
(
nil
,
nil
,
scope
.
Kind
,
namespace
,
""
,
scope
.
Resource
,
scope
.
Subresource
,
admission
.
Delete
,
userInfo
))
err
=
validatingAdmission
.
Validat
ingAdmit
(
admission
.
NewAttributesRecord
(
nil
,
nil
,
scope
.
Kind
,
namespace
,
""
,
scope
.
Resource
,
scope
.
Subresource
,
admission
.
Delete
,
userInfo
))
if
err
!=
nil
{
if
err
!=
nil
{
scope
.
err
(
err
,
w
,
req
)
scope
.
err
(
err
,
w
,
req
)
return
return
...
...
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