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
1ae85648
Commit
1ae85648
authored
Feb 14, 2018
by
David Eads
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add an admission decorator chain
parent
ada94009
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
4 deletions
+42
-4
BUILD
staging/src/k8s.io/apiserver/pkg/admission/BUILD
+1
-0
decorator.go
staging/src/k8s.io/apiserver/pkg/admission/decorator.go
+39
-0
plugins.go
staging/src/k8s.io/apiserver/pkg/admission/plugins.go
+1
-3
admission.go
staging/src/k8s.io/apiserver/pkg/server/options/admission.go
+1
-1
No files found.
staging/src/k8s.io/apiserver/pkg/admission/BUILD
View file @
1ae85648
...
@@ -32,6 +32,7 @@ go_library(
...
@@ -32,6 +32,7 @@ go_library(
"attributes.go",
"attributes.go",
"chain.go",
"chain.go",
"config.go",
"config.go",
"decorator.go",
"errors.go",
"errors.go",
"handler.go",
"handler.go",
"interfaces.go",
"interfaces.go",
...
...
staging/src/k8s.io/apiserver/pkg/admission/decorator.go
0 → 100644
View file @
1ae85648
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
admission
type
Decorator
interface
{
Decorate
(
handler
Interface
,
name
string
)
Interface
}
type
DecoratorFunc
func
(
handler
Interface
,
name
string
)
Interface
func
(
d
DecoratorFunc
)
Decorate
(
handler
Interface
,
name
string
)
Interface
{
return
d
(
handler
,
name
)
}
type
Decorators
[]
Decorator
// Decorate applies the decorator in inside-out order, i.e. the first decorator in the slice is first applied to the given handler.
func
(
d
Decorators
)
Decorate
(
handler
Interface
,
name
string
)
Interface
{
result
:=
handler
for
_
,
d
:=
range
d
{
result
=
d
.
Decorate
(
result
,
name
)
}
return
result
}
staging/src/k8s.io/apiserver/pkg/admission/plugins.go
View file @
1ae85648
...
@@ -122,8 +122,6 @@ func splitStream(config io.Reader) (io.Reader, io.Reader, error) {
...
@@ -122,8 +122,6 @@ func splitStream(config io.Reader) (io.Reader, io.Reader, error) {
return
bytes
.
NewBuffer
(
configBytes
),
bytes
.
NewBuffer
(
configBytes
),
nil
return
bytes
.
NewBuffer
(
configBytes
),
bytes
.
NewBuffer
(
configBytes
),
nil
}
}
type
Decorator
func
(
handler
Interface
,
name
string
)
Interface
// NewFromPlugins returns an admission.Interface that will enforce admission control decisions of all
// NewFromPlugins returns an admission.Interface that will enforce admission control decisions of all
// the given plugins.
// the given plugins.
func
(
ps
*
Plugins
)
NewFromPlugins
(
pluginNames
[]
string
,
configProvider
ConfigProvider
,
pluginInitializer
PluginInitializer
,
decorator
Decorator
)
(
Interface
,
error
)
{
func
(
ps
*
Plugins
)
NewFromPlugins
(
pluginNames
[]
string
,
configProvider
ConfigProvider
,
pluginInitializer
PluginInitializer
,
decorator
Decorator
)
(
Interface
,
error
)
{
...
@@ -140,7 +138,7 @@ func (ps *Plugins) NewFromPlugins(pluginNames []string, configProvider ConfigPro
...
@@ -140,7 +138,7 @@ func (ps *Plugins) NewFromPlugins(pluginNames []string, configProvider ConfigPro
}
}
if
plugin
!=
nil
{
if
plugin
!=
nil
{
if
decorator
!=
nil
{
if
decorator
!=
nil
{
handlers
=
append
(
handlers
,
decorator
(
plugin
,
pluginName
))
handlers
=
append
(
handlers
,
decorator
.
Decorate
(
plugin
,
pluginName
))
}
else
{
}
else
{
handlers
=
append
(
handlers
,
plugin
)
handlers
=
append
(
handlers
,
plugin
)
}
}
...
...
staging/src/k8s.io/apiserver/pkg/server/options/admission.go
View file @
1ae85648
...
@@ -141,7 +141,7 @@ func (a *AdmissionOptions) ApplyTo(
...
@@ -141,7 +141,7 @@ func (a *AdmissionOptions) ApplyTo(
pluginInitializers
=
append
(
pluginInitializers
,
genericInitializer
)
pluginInitializers
=
append
(
pluginInitializers
,
genericInitializer
)
initializersChain
=
append
(
initializersChain
,
pluginInitializers
...
)
initializersChain
=
append
(
initializersChain
,
pluginInitializers
...
)
admissionChain
,
err
:=
a
.
Plugins
.
NewFromPlugins
(
pluginNames
,
pluginsConfigProvider
,
initializersChain
,
admission
metrics
.
WithControllerMetrics
)
admissionChain
,
err
:=
a
.
Plugins
.
NewFromPlugins
(
pluginNames
,
pluginsConfigProvider
,
initializersChain
,
admission
.
DecoratorFunc
(
admissionmetrics
.
WithControllerMetrics
)
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
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