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
d4f48c93
Commit
d4f48c93
authored
Oct 24, 2017
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
admission: split MutationInterface out of Interface
parent
970d2553
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
10 deletions
+28
-10
chain.go
staging/src/k8s.io/apiserver/pkg/admission/chain.go
+21
-3
interfaces.go
staging/src/k8s.io/apiserver/pkg/admission/interfaces.go
+7
-7
No files found.
staging/src/k8s.io/apiserver/pkg/admission/chain.go
View file @
d4f48c93
...
...
@@ -30,9 +30,27 @@ func (admissionHandler chainAdmissionHandler) Admit(a Attributes) error {
if
!
handler
.
Handles
(
a
.
GetOperation
())
{
continue
}
err
:=
handler
.
Admit
(
a
)
if
err
!=
nil
{
return
err
if
mutator
,
ok
:=
handler
.
(
MutationInterface
);
ok
{
err
:=
mutator
.
Admit
(
a
)
if
err
!=
nil
{
return
err
}
}
}
return
nil
}
// ValidatingAdmit performs an admission control check using a chain of handlers, and returns immediately on first error
func
(
admissionHandler
chainAdmissionHandler
)
ValidatingAdmit
(
a
Attributes
)
error
{
for
_
,
handler
:=
range
admissionHandler
{
if
!
handler
.
Handles
(
a
.
GetOperation
())
{
continue
}
if
validator
,
ok
:=
handler
.
(
ValidationInterface
);
ok
{
err
:=
validator
.
ValidatingAdmit
(
a
)
if
err
!=
nil
{
return
err
}
}
}
return
nil
...
...
staging/src/k8s.io/apiserver/pkg/admission/interfaces.go
View file @
d4f48c93
...
...
@@ -53,22 +53,22 @@ type Attributes interface {
// Interface is an abstract, pluggable interface for Admission Control decisions.
type
Interface
interface
{
// Admit makes an admission decision based on the request attributes
Admit
(
a
Attributes
)
(
err
error
)
// Handles returns true if this admission controller can handle the given operation
// where operation can be one of CREATE, UPDATE, DELETE, or CONNECT
Handles
(
operation
Operation
)
bool
}
type
MutationInterface
interface
{
Interface
// Admit makes an admission decision based on the request attributes
Admit
(
a
Attributes
)
(
err
error
)
}
// ValidationInterface is an abstract, pluggable interface for Admission Control decisions.
type
ValidationInterface
interface
{
// ValidatingAdmit makes an admission decision based on the request attributes. It is NOT allowed to mutate
ValidatingAdmit
(
a
Attributes
)
(
err
error
)
// Handles returns true if this admission controller can handle the given operation
// where operation can be one of CREATE, UPDATE, DELETE, or CONNECT
Handles
(
operation
Operation
)
bool
}
// Operation is the type of resource operation being checked for admission control
...
...
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