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
aedcf681
Commit
aedcf681
authored
Oct 27, 2017
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
admission: rename Validate{ -> Initialization}, Validat{ingAdmit -> e}
parent
2452afff
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
76 additions
and
77 deletions
+76
-77
initializer.go
pkg/kubeapiserver/admission/initializer.go
+4
-4
admission.go
plugin/pkg/admission/admit/admission.go
+2
-2
admission.go
plugin/pkg/admission/exec/admission.go
+2
-2
admission_test.go
plugin/pkg/admission/exec/admission_test.go
+1
-1
gc_admission.go
plugin/pkg/admission/gc/gc_admission.go
+1
-1
admission.go
plugin/pkg/admission/limitranger/admission.go
+1
-1
admission_test.go
plugin/pkg/admission/limitranger/admission_test.go
+1
-1
admission.go
plugin/pkg/admission/namespace/autoprovision/admission.go
+2
-2
admission_test.go
...n/pkg/admission/namespace/autoprovision/admission_test.go
+1
-1
admission.go
plugin/pkg/admission/namespace/exists/admission.go
+2
-2
admission_test.go
plugin/pkg/admission/namespace/exists/admission_test.go
+1
-1
admission.go
plugin/pkg/admission/noderestriction/admission.go
+1
-1
admission.go
plugin/pkg/admission/persistentvolume/resize/admission.go
+2
-2
admission.go
plugin/pkg/admission/podnodeselector/admission.go
+1
-1
admission_test.go
plugin/pkg/admission/podnodeselector/admission_test.go
+1
-1
admission.go
plugin/pkg/admission/podpreset/admission.go
+1
-1
admission.go
plugin/pkg/admission/podtolerationrestriction/admission.go
+1
-1
admission_test.go
.../pkg/admission/podtolerationrestriction/admission_test.go
+1
-1
admission.go
plugin/pkg/admission/priority/admission.go
+2
-2
admission.go
plugin/pkg/admission/resourcequota/admission.go
+2
-2
admission.go
plugin/pkg/admission/security/podsecuritypolicy/admission.go
+2
-2
admission.go
plugin/pkg/admission/serviceaccount/admission.go
+2
-2
admission.go
plugin/pkg/admission/storageclass/setdefault/admission.go
+2
-2
chain.go
staging/src/k8s.io/apiserver/pkg/admission/chain.go
+3
-3
initializer_test.go
...o/apiserver/pkg/admission/initializer/initializer_test.go
+5
-5
interfaces.go
.../k8s.io/apiserver/pkg/admission/initializer/interfaces.go
+4
-4
interfaces.go
staging/src/k8s.io/apiserver/pkg/admission/interfaces.go
+6
-6
initialization.go
...ver/pkg/admission/plugin/initialization/initialization.go
+2
-2
admission.go
...ver/pkg/admission/plugin/namespace/lifecycle/admission.go
+2
-2
admission_test.go
...kg/admission/plugin/namespace/lifecycle/admission_test.go
+1
-1
admission.go
...8s.io/apiserver/pkg/admission/plugin/webhook/admission.go
+2
-3
plugins.go
staging/src/k8s.io/apiserver/pkg/admission/plugins.go
+6
-6
delete.go
...ing/src/k8s.io/apiserver/pkg/endpoints/handlers/delete.go
+2
-2
create.go
staging/src/k8s.io/apiserver/pkg/registry/rest/create.go
+1
-1
update.go
staging/src/k8s.io/apiserver/pkg/registry/rest/update.go
+1
-1
admission.go
...le-apiserver/pkg/admission/plugin/banflunder/admission.go
+2
-2
admission_test.go
...iserver/pkg/admission/plugin/banflunder/admission_test.go
+1
-1
interfaces.go
...e-apiserver/pkg/admission/wardleinitializer/interfaces.go
+1
-1
wardleinitializer_test.go
...pkg/admission/wardleinitializer/wardleinitializer_test.go
+1
-1
No files found.
pkg/kubeapiserver/admission/initializer.go
View file @
aedcf681
...
...
@@ -34,13 +34,13 @@ import (
// WantsInternalKubeClientSet defines a function which sets ClientSet for admission plugins that need it
type
WantsInternalKubeClientSet
interface
{
SetInternalKubeClientSet
(
internalclientset
.
Interface
)
admission
.
Validator
admission
.
Initialization
Validator
}
// WantsInternalKubeInformerFactory defines a function which sets InformerFactory for admission plugins that need it
type
WantsInternalKubeInformerFactory
interface
{
SetInternalKubeInformerFactory
(
informers
.
SharedInformerFactory
)
admission
.
Validator
admission
.
Initialization
Validator
}
// WantsCloudConfig defines a function which sets CloudConfig for admission plugins that need it.
...
...
@@ -56,7 +56,7 @@ type WantsRESTMapper interface {
// WantsQuotaConfiguration defines a function which sets quota configuration for admission plugins that need it.
type
WantsQuotaConfiguration
interface
{
SetQuotaConfiguration
(
quota
.
Configuration
)
admission
.
Validator
admission
.
Initialization
Validator
}
// WantsServiceResolver defines a fuction that accepts a ServiceResolver for
...
...
@@ -75,7 +75,7 @@ type ServiceResolver interface {
// to allow the apiserver to control what is returned as auth info
type
WantsAuthenticationInfoResolverWrapper
interface
{
SetAuthenticationInfoResolverWrapper
(
webhook
.
AuthenticationInfoResolverWrapper
)
admission
.
Validator
admission
.
Initialization
Validator
}
type
PluginInitializer
struct
{
...
...
plugin/pkg/admission/admit/admission.go
View file @
aedcf681
...
...
@@ -38,8 +38,8 @@ func (AlwaysAdmit) Admit(a admission.Attributes) (err error) {
return
nil
}
// Validat
ingAdmit makes an admission decision based on the request attributes. It is NOT allowed to mutate
func
(
AlwaysAdmit
)
Validat
ingAdmit
(
a
admission
.
Attributes
)
(
err
error
)
{
// Validat
e makes an admission decision based on the request attributes. It is NOT allowed to mutate.
func
(
AlwaysAdmit
)
Validat
e
(
a
admission
.
Attributes
)
(
err
error
)
{
return
nil
}
...
...
plugin/pkg/admission/exec/admission.go
View file @
aedcf681
...
...
@@ -135,8 +135,8 @@ func (d *DenyExec) SetInternalKubeClientSet(client internalclientset.Interface)
d
.
client
=
client
}
// Validate
implements the
Validator interface.
func
(
d
*
DenyExec
)
Validate
()
error
{
// Validate
Initialization implements the Initialization
Validator interface.
func
(
d
*
DenyExec
)
Validate
Initialization
()
error
{
if
d
.
client
==
nil
{
return
fmt
.
Errorf
(
"missing client"
)
}
...
...
plugin/pkg/admission/exec/admission_test.go
View file @
aedcf681
...
...
@@ -118,7 +118,7 @@ func testAdmission(t *testing.T, pod *api.Pod, handler *DenyExec, shouldAccept b
})
handler
.
SetInternalKubeClientSet
(
mockClient
)
admission
.
Validate
(
handler
)
admission
.
Validate
Initialization
(
handler
)
// pods/exec
{
...
...
plugin/pkg/admission/gc/gc_admission.go
View file @
aedcf681
...
...
@@ -260,7 +260,7 @@ func (a *gcPermissionsEnforcement) SetRESTMapper(restMapper meta.RESTMapper) {
a
.
restMapper
=
restMapper
}
func
(
a
*
gcPermissionsEnforcement
)
Validate
()
error
{
func
(
a
*
gcPermissionsEnforcement
)
Validate
Initialization
()
error
{
if
a
.
authorizer
==
nil
{
return
fmt
.
Errorf
(
"missing authorizer"
)
}
...
...
plugin/pkg/admission/limitranger/admission.go
View file @
aedcf681
...
...
@@ -75,7 +75,7 @@ func (l *LimitRanger) SetInternalKubeInformerFactory(f informers.SharedInformerF
l
.
lister
=
limitRangeInformer
.
Lister
()
}
func
(
l
*
LimitRanger
)
Validate
()
error
{
func
(
l
*
LimitRanger
)
Validate
Initialization
()
error
{
if
l
.
lister
==
nil
{
return
fmt
.
Errorf
(
"missing limitRange lister"
)
}
...
...
plugin/pkg/admission/limitranger/admission_test.go
View file @
aedcf681
...
...
@@ -746,7 +746,7 @@ func newHandlerForTest(c clientset.Interface) (*LimitRanger, informers.SharedInf
}
pluginInitializer
:=
kubeadmission
.
NewPluginInitializer
(
c
,
f
,
nil
,
nil
,
nil
,
nil
,
nil
)
pluginInitializer
.
Initialize
(
handler
)
err
=
admission
.
Validate
(
handler
)
err
=
admission
.
Validate
Initialization
(
handler
)
return
handler
,
f
,
err
}
...
...
plugin/pkg/admission/namespace/autoprovision/admission.go
View file @
aedcf681
...
...
@@ -106,8 +106,8 @@ func (p *Provision) SetInternalKubeInformerFactory(f informers.SharedInformerFac
p
.
SetReadyFunc
(
namespaceInformer
.
Informer
()
.
HasSynced
)
}
// Validate
implements the
Validator interface.
func
(
p
*
Provision
)
Validate
()
error
{
// Validate
Initialization implements the Initialization
Validator interface.
func
(
p
*
Provision
)
Validate
Initialization
()
error
{
if
p
.
namespaceLister
==
nil
{
return
fmt
.
Errorf
(
"missing namespaceLister"
)
}
...
...
plugin/pkg/admission/namespace/autoprovision/admission_test.go
View file @
aedcf681
...
...
@@ -40,7 +40,7 @@ func newHandlerForTest(c clientset.Interface) (admission.MutationInterface, info
handler
:=
NewProvision
()
pluginInitializer
:=
kubeadmission
.
NewPluginInitializer
(
c
,
f
,
nil
,
nil
,
nil
,
nil
,
nil
)
pluginInitializer
.
Initialize
(
handler
)
err
:=
admission
.
Validate
(
handler
)
err
:=
admission
.
Validate
Initialization
(
handler
)
return
handler
,
f
,
err
}
...
...
plugin/pkg/admission/namespace/exists/admission.go
View file @
aedcf681
...
...
@@ -101,8 +101,8 @@ func (e *Exists) SetInternalKubeInformerFactory(f informers.SharedInformerFactor
e
.
SetReadyFunc
(
namespaceInformer
.
Informer
()
.
HasSynced
)
}
// Validate
implements the
Validator interface.
func
(
e
*
Exists
)
Validate
()
error
{
// Validate
Initialization implements the Initialization
Validator interface.
func
(
e
*
Exists
)
Validate
Initialization
()
error
{
if
e
.
namespaceLister
==
nil
{
return
fmt
.
Errorf
(
"missing namespaceLister"
)
}
...
...
plugin/pkg/admission/namespace/exists/admission_test.go
View file @
aedcf681
...
...
@@ -39,7 +39,7 @@ func newHandlerForTest(c clientset.Interface) (admission.MutationInterface, info
handler
:=
NewExists
()
pluginInitializer
:=
kubeadmission
.
NewPluginInitializer
(
c
,
f
,
nil
,
nil
,
nil
,
nil
,
nil
)
pluginInitializer
.
Initialize
(
handler
)
err
:=
admission
.
Validate
(
handler
)
err
:=
admission
.
Validate
Initialization
(
handler
)
return
handler
,
f
,
err
}
...
...
plugin/pkg/admission/noderestriction/admission.go
View file @
aedcf681
...
...
@@ -69,7 +69,7 @@ func (p *nodePlugin) SetInternalKubeClientSet(f internalclientset.Interface) {
p
.
podsGetter
=
f
.
Core
()
}
func
(
p
*
nodePlugin
)
Validate
()
error
{
func
(
p
*
nodePlugin
)
Validate
Initialization
()
error
{
if
p
.
nodeIdentifier
==
nil
{
return
fmt
.
Errorf
(
"%s requires a node identifier"
,
PluginName
)
}
...
...
plugin/pkg/admission/persistentvolume/resize/admission.go
View file @
aedcf681
...
...
@@ -68,8 +68,8 @@ func (pvcr *persistentVolumeClaimResize) SetInternalKubeInformerFactory(f inform
})
}
// Validate ensures lister is set.
func
(
pvcr
*
persistentVolumeClaimResize
)
Validate
()
error
{
// Validate
Initialization
ensures lister is set.
func
(
pvcr
*
persistentVolumeClaimResize
)
Validate
Initialization
()
error
{
if
pvcr
.
pvLister
==
nil
{
return
fmt
.
Errorf
(
"missing persistent volume lister"
)
}
...
...
plugin/pkg/admission/podnodeselector/admission.go
View file @
aedcf681
...
...
@@ -183,7 +183,7 @@ func (p *podNodeSelector) SetInternalKubeInformerFactory(f informers.SharedInfor
p
.
SetReadyFunc
(
namespaceInformer
.
Informer
()
.
HasSynced
)
}
func
(
p
*
podNodeSelector
)
Validate
()
error
{
func
(
p
*
podNodeSelector
)
Validate
Initialization
()
error
{
if
p
.
namespaceLister
==
nil
{
return
fmt
.
Errorf
(
"missing namespaceLister"
)
}
...
...
plugin/pkg/admission/podnodeselector/admission_test.go
View file @
aedcf681
...
...
@@ -243,6 +243,6 @@ func newHandlerForTest(c clientset.Interface) (*podNodeSelector, informers.Share
handler
:=
NewPodNodeSelector
(
nil
)
pluginInitializer
:=
kubeadmission
.
NewPluginInitializer
(
c
,
f
,
nil
,
nil
,
nil
,
nil
,
nil
)
pluginInitializer
.
Initialize
(
handler
)
err
:=
admission
.
Validate
(
handler
)
err
:=
admission
.
Validate
Initialization
(
handler
)
return
handler
,
f
,
err
}
plugin/pkg/admission/podpreset/admission.go
View file @
aedcf681
...
...
@@ -69,7 +69,7 @@ func NewPlugin() *podPresetPlugin {
}
}
func
(
plugin
*
podPresetPlugin
)
Validate
()
error
{
func
(
plugin
*
podPresetPlugin
)
Validate
Initialization
()
error
{
if
plugin
.
client
==
nil
{
return
fmt
.
Errorf
(
"%s requires a client"
,
pluginName
)
}
...
...
plugin/pkg/admission/podtolerationrestriction/admission.go
View file @
aedcf681
...
...
@@ -202,7 +202,7 @@ func (p *podTolerationsPlugin) SetInternalKubeInformerFactory(f informers.Shared
}
func
(
p
*
podTolerationsPlugin
)
Validate
()
error
{
func
(
p
*
podTolerationsPlugin
)
Validate
Initialization
()
error
{
if
p
.
namespaceLister
==
nil
{
return
fmt
.
Errorf
(
"missing namespaceLister"
)
}
...
...
plugin/pkg/admission/podtolerationrestriction/admission_test.go
View file @
aedcf681
...
...
@@ -344,6 +344,6 @@ func newHandlerForTest(c clientset.Interface) (*podTolerationsPlugin, informers.
handler
:=
NewPodTolerationsPlugin
(
pluginConfig
)
pluginInitializer
:=
kubeadmission
.
NewPluginInitializer
(
c
,
f
,
nil
,
nil
,
nil
,
nil
,
nil
)
pluginInitializer
.
Initialize
(
handler
)
err
=
admission
.
Validate
(
handler
)
err
=
admission
.
Validate
Initialization
(
handler
)
return
handler
,
f
,
err
}
plugin/pkg/admission/priority/admission.go
View file @
aedcf681
...
...
@@ -74,8 +74,8 @@ func NewPlugin() *PriorityPlugin {
}
}
// Validate
implements the
Validator interface.
func
(
p
*
PriorityPlugin
)
Validate
()
error
{
// Validate
Initialization implements the Initialization
Validator interface.
func
(
p
*
PriorityPlugin
)
Validate
Initialization
()
error
{
if
p
.
client
==
nil
{
return
fmt
.
Errorf
(
"%s requires a client"
,
pluginName
)
}
...
...
plugin/pkg/admission/resourcequota/admission.go
View file @
aedcf681
...
...
@@ -100,8 +100,8 @@ func (a *QuotaAdmission) SetQuotaConfiguration(c quota.Configuration) {
a
.
evaluator
=
NewQuotaEvaluator
(
a
.
quotaAccessor
,
a
.
quotaConfiguration
,
nil
,
a
.
config
,
a
.
numEvaluators
,
a
.
stopCh
)
}
// Validate ensures an authorizer is set.
func
(
a
*
QuotaAdmission
)
Validate
()
error
{
// Validate
Initialization
ensures an authorizer is set.
func
(
a
*
QuotaAdmission
)
Validate
Initialization
()
error
{
if
a
.
quotaAccessor
==
nil
{
return
fmt
.
Errorf
(
"missing quotaAccessor"
)
}
...
...
plugin/pkg/admission/security/podsecuritypolicy/admission.go
View file @
aedcf681
...
...
@@ -72,8 +72,8 @@ func (plugin *podSecurityPolicyPlugin) SetAuthorizer(authz authorizer.Authorizer
plugin
.
authz
=
authz
}
// Validate ensures an authorizer is set.
func
(
plugin
*
podSecurityPolicyPlugin
)
Validate
()
error
{
// Validate
Initialization
ensures an authorizer is set.
func
(
plugin
*
podSecurityPolicyPlugin
)
Validate
Initialization
()
error
{
if
plugin
.
authz
==
nil
{
return
fmt
.
Errorf
(
"%s requires an authorizer"
,
PluginName
)
}
...
...
plugin/pkg/admission/serviceaccount/admission.go
View file @
aedcf681
...
...
@@ -117,8 +117,8 @@ func (a *serviceAccount) SetInternalKubeInformerFactory(f informers.SharedInform
})
}
// Validate ensures an authorizer is set.
func
(
a
*
serviceAccount
)
Validate
()
error
{
// Validate
Initialization
ensures an authorizer is set.
func
(
a
*
serviceAccount
)
Validate
Initialization
()
error
{
if
a
.
client
==
nil
{
return
fmt
.
Errorf
(
"missing client"
)
}
...
...
plugin/pkg/admission/storageclass/setdefault/admission.go
View file @
aedcf681
...
...
@@ -69,8 +69,8 @@ func (a *claimDefaulterPlugin) SetInternalKubeInformerFactory(f informers.Shared
a
.
SetReadyFunc
(
informer
.
Informer
()
.
HasSynced
)
}
// Validate ensures lister is set.
func
(
a
*
claimDefaulterPlugin
)
Validate
()
error
{
// Validate
Initialization
ensures lister is set.
func
(
a
*
claimDefaulterPlugin
)
Validate
Initialization
()
error
{
if
a
.
lister
==
nil
{
return
fmt
.
Errorf
(
"missing lister"
)
}
...
...
staging/src/k8s.io/apiserver/pkg/admission/chain.go
View file @
aedcf681
...
...
@@ -40,14 +40,14 @@ func (admissionHandler chainAdmissionHandler) Admit(a Attributes) error {
return
nil
}
// Validat
ingAdmit
performs an admission control check using a chain of handlers, and returns immediately on first error
func
(
admissionHandler
chainAdmissionHandler
)
Validat
ingAdmit
(
a
Attributes
)
error
{
// Validat
e
performs an admission control check using a chain of handlers, and returns immediately on first error
func
(
admissionHandler
chainAdmissionHandler
)
Validat
e
(
a
Attributes
)
error
{
for
_
,
handler
:=
range
admissionHandler
{
if
!
handler
.
Handles
(
a
.
GetOperation
())
{
continue
}
if
validator
,
ok
:=
handler
.
(
ValidationInterface
);
ok
{
err
:=
validator
.
Validat
ingAdmit
(
a
)
err
:=
validator
.
Validat
e
(
a
)
if
err
!=
nil
{
return
err
}
...
...
staging/src/k8s.io/apiserver/pkg/admission/initializer/initializer_test.go
View file @
aedcf681
...
...
@@ -99,7 +99,7 @@ func (self *WantExternalKubeInformerFactory) SetExternalKubeInformerFactory(sf i
}
func
(
self
*
WantExternalKubeInformerFactory
)
Admit
(
a
admission
.
Attributes
)
error
{
return
nil
}
func
(
self
*
WantExternalKubeInformerFactory
)
Handles
(
o
admission
.
Operation
)
bool
{
return
false
}
func
(
self
*
WantExternalKubeInformerFactory
)
Validate
()
error
{
return
nil
}
func
(
self
*
WantExternalKubeInformerFactory
)
Validate
Initialization
()
error
{
return
nil
}
var
_
admission
.
Interface
=
&
WantExternalKubeInformerFactory
{}
var
_
initializer
.
WantsExternalKubeInformerFactory
=
&
WantExternalKubeInformerFactory
{}
...
...
@@ -112,7 +112,7 @@ type WantExternalKubeClientSet struct {
func
(
self
*
WantExternalKubeClientSet
)
SetExternalKubeClientSet
(
cs
kubernetes
.
Interface
)
{
self
.
cs
=
cs
}
func
(
self
*
WantExternalKubeClientSet
)
Admit
(
a
admission
.
Attributes
)
error
{
return
nil
}
func
(
self
*
WantExternalKubeClientSet
)
Handles
(
o
admission
.
Operation
)
bool
{
return
false
}
func
(
self
*
WantExternalKubeClientSet
)
Validate
()
error
{
return
nil
}
func
(
self
*
WantExternalKubeClientSet
)
Validate
Initialization
()
error
{
return
nil
}
var
_
admission
.
Interface
=
&
WantExternalKubeClientSet
{}
var
_
initializer
.
WantsExternalKubeClientSet
=
&
WantExternalKubeClientSet
{}
...
...
@@ -125,7 +125,7 @@ type WantAuthorizerAdmission struct {
func
(
self
*
WantAuthorizerAdmission
)
SetAuthorizer
(
a
authorizer
.
Authorizer
)
{
self
.
auth
=
a
}
func
(
self
*
WantAuthorizerAdmission
)
Admit
(
a
admission
.
Attributes
)
error
{
return
nil
}
func
(
self
*
WantAuthorizerAdmission
)
Handles
(
o
admission
.
Operation
)
bool
{
return
false
}
func
(
self
*
WantAuthorizerAdmission
)
Validate
()
error
{
return
nil
}
func
(
self
*
WantAuthorizerAdmission
)
Validate
Initialization
()
error
{
return
nil
}
var
_
admission
.
Interface
=
&
WantAuthorizerAdmission
{}
var
_
initializer
.
WantsAuthorizer
=
&
WantAuthorizerAdmission
{}
...
...
@@ -145,7 +145,7 @@ type clientCertWanter struct {
func
(
s
*
clientCertWanter
)
SetClientCert
(
cert
,
key
[]
byte
)
{
s
.
gotCert
,
s
.
gotKey
=
cert
,
key
}
func
(
s
*
clientCertWanter
)
Admit
(
a
admission
.
Attributes
)
error
{
return
nil
}
func
(
s
*
clientCertWanter
)
Handles
(
o
admission
.
Operation
)
bool
{
return
false
}
func
(
s
*
clientCertWanter
)
Validate
()
error
{
return
nil
}
func
(
s
*
clientCertWanter
)
Validate
Initialization
()
error
{
return
nil
}
// WantSchemeAdmission is a test stub that fulfills the WantsScheme interface.
type
WantSchemeAdmission
struct
{
...
...
@@ -155,7 +155,7 @@ type WantSchemeAdmission struct {
func
(
self
*
WantSchemeAdmission
)
SetScheme
(
s
*
runtime
.
Scheme
)
{
self
.
scheme
=
s
}
func
(
self
*
WantSchemeAdmission
)
Admit
(
a
admission
.
Attributes
)
error
{
return
nil
}
func
(
self
*
WantSchemeAdmission
)
Handles
(
o
admission
.
Operation
)
bool
{
return
false
}
func
(
self
*
WantSchemeAdmission
)
Validate
()
error
{
return
nil
}
func
(
self
*
WantSchemeAdmission
)
Validate
Initialization
()
error
{
return
nil
}
var
_
admission
.
Interface
=
&
WantSchemeAdmission
{}
var
_
initializer
.
WantsScheme
=
&
WantSchemeAdmission
{}
staging/src/k8s.io/apiserver/pkg/admission/initializer/interfaces.go
View file @
aedcf681
...
...
@@ -27,23 +27,23 @@ import (
// WantsExternalKubeClientSet defines a function which sets external ClientSet for admission plugins that need it
type
WantsExternalKubeClientSet
interface
{
SetExternalKubeClientSet
(
kubernetes
.
Interface
)
admission
.
Validator
admission
.
Initialization
Validator
}
// WantsExternalKubeInformerFactory defines a function which sets InformerFactory for admission plugins that need it
type
WantsExternalKubeInformerFactory
interface
{
SetExternalKubeInformerFactory
(
informers
.
SharedInformerFactory
)
admission
.
Validator
admission
.
Initialization
Validator
}
// WantsAuthorizer defines a function which sets Authorizer for admission plugins that need it.
type
WantsAuthorizer
interface
{
SetAuthorizer
(
authorizer
.
Authorizer
)
admission
.
Validator
admission
.
Initialization
Validator
}
// WantsScheme defines a function that accepts runtime.Scheme for admission plugins that need it.
type
WantsScheme
interface
{
SetScheme
(
*
runtime
.
Scheme
)
admission
.
Validator
admission
.
Initialization
Validator
}
staging/src/k8s.io/apiserver/pkg/admission/interfaces.go
View file @
aedcf681
...
...
@@ -69,8 +69,8 @@ type MutationInterface interface {
type
ValidationInterface
interface
{
Interface
// Validat
ingAdmit
makes an admission decision based on the request attributes. It is NOT allowed to mutate
Validat
ingAdmit
(
a
Attributes
)
(
err
error
)
// Validat
e
makes an admission decision based on the request attributes. It is NOT allowed to mutate
Validat
e
(
a
Attributes
)
(
err
error
)
}
// Operation is the type of resource operation being checked for admission control
...
...
@@ -90,10 +90,10 @@ type PluginInitializer interface {
Initialize
(
plugin
Interface
)
}
//
Validator holds Validate functions, which are responsible for validation of initialized shared resources
// and should be implemented on admission plugins
type
Validator
interface
{
Validate
()
error
//
InitializationValidator holds ValidateInitialization functions, which are responsible for validation of initialized
//
shared resources
and should be implemented on admission plugins
type
Initialization
Validator
interface
{
Validate
Initialization
()
error
}
// ConfigProvider provides a way to get configuration for an admission plugin based on its name
...
...
staging/src/k8s.io/apiserver/pkg/admission/plugin/initialization/initialization.go
View file @
aedcf681
...
...
@@ -74,8 +74,8 @@ func NewInitializer() admission.Interface {
return
&
initializer
{}
}
// Validate
implements the
Validator interface.
func
(
i
*
initializer
)
Validate
()
error
{
// Validate
Initialization implements the Initialization
Validator interface.
func
(
i
*
initializer
)
Validate
Initialization
()
error
{
if
i
.
config
==
nil
{
return
fmt
.
Errorf
(
"the Initializer admission plugin requires a Kubernetes client to be provided"
)
}
...
...
staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle/admission.go
View file @
aedcf681
...
...
@@ -214,8 +214,8 @@ func (l *Lifecycle) SetExternalKubeClientSet(client kubernetes.Interface) {
l
.
client
=
client
}
// Validate
implement the
Validator interface.
func
(
l
*
Lifecycle
)
Validate
()
error
{
// Validate
Initialization implements the Initialization
Validator interface.
func
(
l
*
Lifecycle
)
Validate
Initialization
()
error
{
if
l
.
namespaceLister
==
nil
{
return
fmt
.
Errorf
(
"missing namespaceLister"
)
}
...
...
staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle/admission_test.go
View file @
aedcf681
...
...
@@ -53,7 +53,7 @@ func newHandlerForTestWithClock(c clientset.Interface, cacheClock clock.Clock) (
return
handler
,
f
,
err
}
pluginInitializer
.
Initialize
(
handler
)
err
=
admission
.
Validate
(
handler
)
err
=
admission
.
Validate
Initialization
(
handler
)
return
handler
,
f
,
err
}
...
...
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/admission.go
View file @
aedcf681
...
...
@@ -156,9 +156,8 @@ func (a *GenericAdmissionWebhook) SetExternalKubeClientSet(client clientset.Inte
a
.
hookSource
=
configuration
.
NewExternalAdmissionHookConfigurationManager
(
client
.
Admissionregistration
()
.
ExternalAdmissionHookConfigurations
())
}
// Validator holds Validate functions, which are responsible for validation of initialized shared resources
// and should be implemented on admission plugins
func
(
a
*
GenericAdmissionWebhook
)
Validate
()
error
{
// ValidateInitialization implements the InitializationValidator interface.
func
(
a
*
GenericAdmissionWebhook
)
ValidateInitialization
()
error
{
if
a
.
hookSource
==
nil
{
return
fmt
.
Errorf
(
"the GenericAdmissionWebhook admission plugin requires a Kubernetes client to be provided"
)
}
...
...
staging/src/k8s.io/apiserver/pkg/admission/plugins.go
View file @
aedcf681
...
...
@@ -156,18 +156,18 @@ func (ps *Plugins) InitPlugin(name string, config io.Reader, pluginInitializer P
pluginInitializer
.
Initialize
(
plugin
)
// ensure that plugins have been properly initialized
if
err
:=
Validate
(
plugin
);
err
!=
nil
{
if
err
:=
Validate
Initialization
(
plugin
);
err
!=
nil
{
return
nil
,
err
}
return
plugin
,
nil
}
// Validate
will call the
Validate function in each plugin if they implement
// the Validator interface.
func
Validate
(
plugin
Interface
)
error
{
if
validater
,
ok
:=
plugin
.
(
Validator
);
ok
{
err
:=
validater
.
Validate
()
// Validate
Initialization will call the Initialization
Validate function in each plugin if they implement
// the
Initialization
Validator interface.
func
Validate
Initialization
(
plugin
Interface
)
error
{
if
validater
,
ok
:=
plugin
.
(
Initialization
Validator
);
ok
{
err
:=
validater
.
Validate
Initialization
()
if
err
!=
nil
{
return
err
}
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/delete.go
View file @
aedcf681
...
...
@@ -104,7 +104,7 @@ func DeleteResource(r rest.GracefulDeleter, allowsOptions bool, scope RequestSco
}
}
if
validatingAdmission
,
ok
:=
admit
.
(
admission
.
ValidationInterface
);
ok
{
if
err
:=
validatingAdmission
.
Validat
ingAdmit
(
attrs
);
err
!=
nil
{
if
err
:=
validatingAdmission
.
Validat
e
(
attrs
);
err
!=
nil
{
scope
.
err
(
err
,
w
,
req
)
return
}
...
...
@@ -192,7 +192,7 @@ func DeleteCollection(r rest.CollectionDeleter, checkBody bool, scope RequestSco
if
validatingAdmission
,
ok
:=
admit
.
(
admission
.
ValidationInterface
);
ok
&&
validatingAdmission
.
Handles
(
admission
.
Delete
)
{
userInfo
,
_
:=
request
.
UserFrom
(
ctx
)
err
=
validatingAdmission
.
Validat
ingAdmit
(
admission
.
NewAttributesRecord
(
nil
,
nil
,
scope
.
Kind
,
namespace
,
""
,
scope
.
Resource
,
scope
.
Subresource
,
admission
.
Delete
,
userInfo
))
err
=
validatingAdmission
.
Validat
e
(
admission
.
NewAttributesRecord
(
nil
,
nil
,
scope
.
Kind
,
namespace
,
""
,
scope
.
Resource
,
scope
.
Subresource
,
admission
.
Delete
,
userInfo
))
if
err
!=
nil
{
scope
.
err
(
err
,
w
,
req
)
return
...
...
staging/src/k8s.io/apiserver/pkg/registry/rest/create.go
View file @
aedcf681
...
...
@@ -174,6 +174,6 @@ func AdmissionToValidateObjectFunc(admit admission.Interface, staticAttributes a
if
!
validatingAdmission
.
Handles
(
finalAttributes
.
GetOperation
())
{
return
nil
}
return
validatingAdmission
.
Validat
ingAdmit
(
finalAttributes
)
return
validatingAdmission
.
Validat
e
(
finalAttributes
)
}
}
staging/src/k8s.io/apiserver/pkg/registry/rest/update.go
View file @
aedcf681
...
...
@@ -252,6 +252,6 @@ func AdmissionToValidateObjectUpdateFunc(admit admission.Interface, staticAttrib
if
!
validatingAdmission
.
Handles
(
finalAttributes
.
GetOperation
())
{
return
nil
}
return
validatingAdmission
.
Validat
ingAdmit
(
finalAttributes
)
return
validatingAdmission
.
Validat
e
(
finalAttributes
)
}
}
staging/src/k8s.io/sample-apiserver/pkg/admission/plugin/banflunder/admission.go
View file @
aedcf681
...
...
@@ -84,8 +84,8 @@ func (d *DisallowFlunder) SetInternalWardleInformerFactory(f informers.SharedInf
d
.
lister
=
f
.
Wardle
()
.
InternalVersion
()
.
Fischers
()
.
Lister
()
}
// Validate checks whether the plugin was correctly initialized.
func
(
d
*
DisallowFlunder
)
Validate
()
error
{
// Valida
ValidateInitialization
te checks whether the plugin was correctly initialized.
func
(
d
*
DisallowFlunder
)
Validate
Initialization
()
error
{
if
d
.
lister
==
nil
{
return
fmt
.
Errorf
(
"missing fischer lister"
)
}
...
...
staging/src/k8s.io/sample-apiserver/pkg/admission/plugin/banflunder/admission_test.go
View file @
aedcf681
...
...
@@ -119,7 +119,7 @@ func TestBanflunderAdmissionPlugin(t *testing.T) {
}
targetInitializer
.
Initialize
(
target
)
err
=
admission
.
Validate
(
target
)
err
=
admission
.
Validate
Initialization
(
target
)
if
err
!=
nil
{
t
.
Fatalf
(
"scenario %d: failed to initialize banflunder admission plugin due to =%v"
,
index
,
err
)
}
...
...
staging/src/k8s.io/sample-apiserver/pkg/admission/wardleinitializer/interfaces.go
View file @
aedcf681
...
...
@@ -24,5 +24,5 @@ import (
// WantsInternalWardleInformerFactory defines a function which sets InformerFactory for admission plugins that need it
type
WantsInternalWardleInformerFactory
interface
{
SetInternalWardleInformerFactory
(
informers
.
SharedInformerFactory
)
admission
.
Validator
admission
.
Initialization
Validator
}
staging/src/k8s.io/sample-apiserver/pkg/admission/wardleinitializer/wardleinitializer_test.go
View file @
aedcf681
...
...
@@ -52,7 +52,7 @@ func (self *wantInternalWardleInformerFactory) SetInternalWardleInformerFactory(
}
func
(
self
*
wantInternalWardleInformerFactory
)
Admit
(
a
admission
.
Attributes
)
error
{
return
nil
}
func
(
self
*
wantInternalWardleInformerFactory
)
Handles
(
o
admission
.
Operation
)
bool
{
return
false
}
func
(
self
*
wantInternalWardleInformerFactory
)
Validate
()
error
{
return
nil
}
func
(
self
*
wantInternalWardleInformerFactory
)
Validate
Initialization
()
error
{
return
nil
}
var
_
admission
.
Interface
=
&
wantInternalWardleInformerFactory
{}
var
_
wardleinitializer
.
WantsInternalWardleInformerFactory
=
&
wantInternalWardleInformerFactory
{}
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