mirror of https://github.com/k3s-io/k3s
admission: rename Validate{ -> Initialization}, Validat{ingAdmit -> e}
parent
2452afffe0
commit
aedcf681b3
|
@ -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.InitializationValidator
|
||||
}
|
||||
|
||||
// WantsInternalKubeInformerFactory defines a function which sets InformerFactory for admission plugins that need it
|
||||
type WantsInternalKubeInformerFactory interface {
|
||||
SetInternalKubeInformerFactory(informers.SharedInformerFactory)
|
||||
admission.Validator
|
||||
admission.InitializationValidator
|
||||
}
|
||||
|
||||
// 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.InitializationValidator
|
||||
}
|
||||
|
||||
// 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.InitializationValidator
|
||||
}
|
||||
|
||||
type PluginInitializer struct {
|
||||
|
|
|
@ -38,8 +38,8 @@ func (AlwaysAdmit) Admit(a admission.Attributes) (err error) {
|
|||
return nil
|
||||
}
|
||||
|
||||
// ValidatingAdmit makes an admission decision based on the request attributes. It is NOT allowed to mutate
|
||||
func (AlwaysAdmit) ValidatingAdmit(a admission.Attributes) (err error) {
|
||||
// Validate makes an admission decision based on the request attributes. It is NOT allowed to mutate.
|
||||
func (AlwaysAdmit) Validate(a admission.Attributes) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -135,8 +135,8 @@ func (d *DenyExec) SetInternalKubeClientSet(client internalclientset.Interface)
|
|||
d.client = client
|
||||
}
|
||||
|
||||
// Validate implements the Validator interface.
|
||||
func (d *DenyExec) Validate() error {
|
||||
// ValidateInitialization implements the InitializationValidator interface.
|
||||
func (d *DenyExec) ValidateInitialization() error {
|
||||
if d.client == nil {
|
||||
return fmt.Errorf("missing client")
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ func testAdmission(t *testing.T, pod *api.Pod, handler *DenyExec, shouldAccept b
|
|||
})
|
||||
|
||||
handler.SetInternalKubeClientSet(mockClient)
|
||||
admission.Validate(handler)
|
||||
admission.ValidateInitialization(handler)
|
||||
|
||||
// pods/exec
|
||||
{
|
||||
|
|
|
@ -260,7 +260,7 @@ func (a *gcPermissionsEnforcement) SetRESTMapper(restMapper meta.RESTMapper) {
|
|||
a.restMapper = restMapper
|
||||
}
|
||||
|
||||
func (a *gcPermissionsEnforcement) Validate() error {
|
||||
func (a *gcPermissionsEnforcement) ValidateInitialization() error {
|
||||
if a.authorizer == nil {
|
||||
return fmt.Errorf("missing authorizer")
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ func (l *LimitRanger) SetInternalKubeInformerFactory(f informers.SharedInformerF
|
|||
l.lister = limitRangeInformer.Lister()
|
||||
}
|
||||
|
||||
func (l *LimitRanger) Validate() error {
|
||||
func (l *LimitRanger) ValidateInitialization() error {
|
||||
if l.lister == nil {
|
||||
return fmt.Errorf("missing limitRange lister")
|
||||
}
|
||||
|
|
|
@ -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.ValidateInitialization(handler)
|
||||
return handler, f, err
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
// ValidateInitialization implements the InitializationValidator interface.
|
||||
func (p *Provision) ValidateInitialization() error {
|
||||
if p.namespaceLister == nil {
|
||||
return fmt.Errorf("missing namespaceLister")
|
||||
}
|
||||
|
|
|
@ -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.ValidateInitialization(handler)
|
||||
return handler, f, err
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
// ValidateInitialization implements the InitializationValidator interface.
|
||||
func (e *Exists) ValidateInitialization() error {
|
||||
if e.namespaceLister == nil {
|
||||
return fmt.Errorf("missing namespaceLister")
|
||||
}
|
||||
|
|
|
@ -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.ValidateInitialization(handler)
|
||||
return handler, f, err
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ func (p *nodePlugin) SetInternalKubeClientSet(f internalclientset.Interface) {
|
|||
p.podsGetter = f.Core()
|
||||
}
|
||||
|
||||
func (p *nodePlugin) Validate() error {
|
||||
func (p *nodePlugin) ValidateInitialization() error {
|
||||
if p.nodeIdentifier == nil {
|
||||
return fmt.Errorf("%s requires a node identifier", PluginName)
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ func (pvcr *persistentVolumeClaimResize) SetInternalKubeInformerFactory(f inform
|
|||
})
|
||||
}
|
||||
|
||||
// Validate ensures lister is set.
|
||||
func (pvcr *persistentVolumeClaimResize) Validate() error {
|
||||
// ValidateInitialization ensures lister is set.
|
||||
func (pvcr *persistentVolumeClaimResize) ValidateInitialization() error {
|
||||
if pvcr.pvLister == nil {
|
||||
return fmt.Errorf("missing persistent volume lister")
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ func (p *podNodeSelector) SetInternalKubeInformerFactory(f informers.SharedInfor
|
|||
p.SetReadyFunc(namespaceInformer.Informer().HasSynced)
|
||||
}
|
||||
|
||||
func (p *podNodeSelector) Validate() error {
|
||||
func (p *podNodeSelector) ValidateInitialization() error {
|
||||
if p.namespaceLister == nil {
|
||||
return fmt.Errorf("missing namespaceLister")
|
||||
}
|
||||
|
|
|
@ -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.ValidateInitialization(handler)
|
||||
return handler, f, err
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ func NewPlugin() *podPresetPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
func (plugin *podPresetPlugin) Validate() error {
|
||||
func (plugin *podPresetPlugin) ValidateInitialization() error {
|
||||
if plugin.client == nil {
|
||||
return fmt.Errorf("%s requires a client", pluginName)
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ func (p *podTolerationsPlugin) SetInternalKubeInformerFactory(f informers.Shared
|
|||
|
||||
}
|
||||
|
||||
func (p *podTolerationsPlugin) Validate() error {
|
||||
func (p *podTolerationsPlugin) ValidateInitialization() error {
|
||||
if p.namespaceLister == nil {
|
||||
return fmt.Errorf("missing namespaceLister")
|
||||
}
|
||||
|
|
|
@ -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.ValidateInitialization(handler)
|
||||
return handler, f, err
|
||||
}
|
||||
|
|
|
@ -74,8 +74,8 @@ func NewPlugin() *PriorityPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
// Validate implements the Validator interface.
|
||||
func (p *PriorityPlugin) Validate() error {
|
||||
// ValidateInitialization implements the InitializationValidator interface.
|
||||
func (p *PriorityPlugin) ValidateInitialization() error {
|
||||
if p.client == nil {
|
||||
return fmt.Errorf("%s requires a client", pluginName)
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
// ValidateInitialization ensures an authorizer is set.
|
||||
func (a *QuotaAdmission) ValidateInitialization() error {
|
||||
if a.quotaAccessor == nil {
|
||||
return fmt.Errorf("missing quotaAccessor")
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
// ValidateInitialization ensures an authorizer is set.
|
||||
func (plugin *podSecurityPolicyPlugin) ValidateInitialization() error {
|
||||
if plugin.authz == nil {
|
||||
return fmt.Errorf("%s requires an authorizer", PluginName)
|
||||
}
|
||||
|
|
|
@ -117,8 +117,8 @@ func (a *serviceAccount) SetInternalKubeInformerFactory(f informers.SharedInform
|
|||
})
|
||||
}
|
||||
|
||||
// Validate ensures an authorizer is set.
|
||||
func (a *serviceAccount) Validate() error {
|
||||
// ValidateInitialization ensures an authorizer is set.
|
||||
func (a *serviceAccount) ValidateInitialization() error {
|
||||
if a.client == nil {
|
||||
return fmt.Errorf("missing client")
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
// ValidateInitialization ensures lister is set.
|
||||
func (a *claimDefaulterPlugin) ValidateInitialization() error {
|
||||
if a.lister == nil {
|
||||
return fmt.Errorf("missing lister")
|
||||
}
|
||||
|
|
|
@ -40,14 +40,14 @@ func (admissionHandler chainAdmissionHandler) Admit(a Attributes) error {
|
|||
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 {
|
||||
// Validate performs an admission control check using a chain of handlers, and returns immediately on first error
|
||||
func (admissionHandler chainAdmissionHandler) Validate(a Attributes) error {
|
||||
for _, handler := range admissionHandler {
|
||||
if !handler.Handles(a.GetOperation()) {
|
||||
continue
|
||||
}
|
||||
if validator, ok := handler.(ValidationInterface); ok {
|
||||
err := validator.ValidatingAdmit(a)
|
||||
err := validator.Validate(a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -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) ValidateInitialization() 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) ValidateInitialization() 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) ValidateInitialization() 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) ValidateInitialization() 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) ValidateInitialization() error { return nil }
|
||||
|
||||
var _ admission.Interface = &WantSchemeAdmission{}
|
||||
var _ initializer.WantsScheme = &WantSchemeAdmission{}
|
||||
|
|
|
@ -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.InitializationValidator
|
||||
}
|
||||
|
||||
// WantsExternalKubeInformerFactory defines a function which sets InformerFactory for admission plugins that need it
|
||||
type WantsExternalKubeInformerFactory interface {
|
||||
SetExternalKubeInformerFactory(informers.SharedInformerFactory)
|
||||
admission.Validator
|
||||
admission.InitializationValidator
|
||||
}
|
||||
|
||||
// WantsAuthorizer defines a function which sets Authorizer for admission plugins that need it.
|
||||
type WantsAuthorizer interface {
|
||||
SetAuthorizer(authorizer.Authorizer)
|
||||
admission.Validator
|
||||
admission.InitializationValidator
|
||||
}
|
||||
|
||||
// WantsScheme defines a function that accepts runtime.Scheme for admission plugins that need it.
|
||||
type WantsScheme interface {
|
||||
SetScheme(*runtime.Scheme)
|
||||
admission.Validator
|
||||
admission.InitializationValidator
|
||||
}
|
||||
|
|
|
@ -69,8 +69,8 @@ type MutationInterface interface {
|
|||
type ValidationInterface interface {
|
||||
Interface
|
||||
|
||||
// ValidatingAdmit makes an admission decision based on the request attributes. It is NOT allowed to mutate
|
||||
ValidatingAdmit(a Attributes) (err error)
|
||||
// Validate makes an admission decision based on the request attributes. It is NOT allowed to mutate
|
||||
Validate(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 InitializationValidator interface {
|
||||
ValidateInitialization() error
|
||||
}
|
||||
|
||||
// ConfigProvider provides a way to get configuration for an admission plugin based on its name
|
||||
|
|
|
@ -74,8 +74,8 @@ func NewInitializer() admission.Interface {
|
|||
return &initializer{}
|
||||
}
|
||||
|
||||
// Validate implements the Validator interface.
|
||||
func (i *initializer) Validate() error {
|
||||
// ValidateInitialization implements the InitializationValidator interface.
|
||||
func (i *initializer) ValidateInitialization() error {
|
||||
if i.config == nil {
|
||||
return fmt.Errorf("the Initializer admission plugin requires a Kubernetes client to be provided")
|
||||
}
|
||||
|
|
|
@ -214,8 +214,8 @@ func (l *Lifecycle) SetExternalKubeClientSet(client kubernetes.Interface) {
|
|||
l.client = client
|
||||
}
|
||||
|
||||
// Validate implement the Validator interface.
|
||||
func (l *Lifecycle) Validate() error {
|
||||
// ValidateInitialization implements the InitializationValidator interface.
|
||||
func (l *Lifecycle) ValidateInitialization() error {
|
||||
if l.namespaceLister == nil {
|
||||
return fmt.Errorf("missing namespaceLister")
|
||||
}
|
||||
|
|
|
@ -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.ValidateInitialization(handler)
|
||||
return handler, f, err
|
||||
}
|
||||
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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 := ValidateInitialization(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()
|
||||
// ValidateInitialization will call the InitializationValidate function in each plugin if they implement
|
||||
// the InitializationValidator interface.
|
||||
func ValidateInitialization(plugin Interface) error {
|
||||
if validater, ok := plugin.(InitializationValidator); ok {
|
||||
err := validater.ValidateInitialization()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ func DeleteResource(r rest.GracefulDeleter, allowsOptions bool, scope RequestSco
|
|||
}
|
||||
}
|
||||
if validatingAdmission, ok := admit.(admission.ValidationInterface); ok {
|
||||
if err := validatingAdmission.ValidatingAdmit(attrs); err != nil {
|
||||
if err := validatingAdmission.Validate(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.ValidatingAdmit(admission.NewAttributesRecord(nil, nil, scope.Kind, namespace, "", scope.Resource, scope.Subresource, admission.Delete, userInfo))
|
||||
err = validatingAdmission.Validate(admission.NewAttributesRecord(nil, nil, scope.Kind, namespace, "", scope.Resource, scope.Subresource, admission.Delete, userInfo))
|
||||
if err != nil {
|
||||
scope.err(err, w, req)
|
||||
return
|
||||
|
|
|
@ -174,6 +174,6 @@ func AdmissionToValidateObjectFunc(admit admission.Interface, staticAttributes a
|
|||
if !validatingAdmission.Handles(finalAttributes.GetOperation()) {
|
||||
return nil
|
||||
}
|
||||
return validatingAdmission.ValidatingAdmit(finalAttributes)
|
||||
return validatingAdmission.Validate(finalAttributes)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -252,6 +252,6 @@ func AdmissionToValidateObjectUpdateFunc(admit admission.Interface, staticAttrib
|
|||
if !validatingAdmission.Handles(finalAttributes.GetOperation()) {
|
||||
return nil
|
||||
}
|
||||
return validatingAdmission.ValidatingAdmit(finalAttributes)
|
||||
return validatingAdmission.Validate(finalAttributes)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
// ValidaValidateInitializationte checks whether the plugin was correctly initialized.
|
||||
func (d *DisallowFlunder) ValidateInitialization() error {
|
||||
if d.lister == nil {
|
||||
return fmt.Errorf("missing fischer lister")
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ func TestBanflunderAdmissionPlugin(t *testing.T) {
|
|||
}
|
||||
targetInitializer.Initialize(target)
|
||||
|
||||
err = admission.Validate(target)
|
||||
err = admission.ValidateInitialization(target)
|
||||
if err != nil {
|
||||
t.Fatalf("scenario %d: failed to initialize banflunder admission plugin due to =%v", index, err)
|
||||
}
|
||||
|
|
|
@ -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.InitializationValidator
|
||||
}
|
||||
|
|
|
@ -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) ValidateInitialization() error { return nil }
|
||||
|
||||
var _ admission.Interface = &wantInternalWardleInformerFactory{}
|
||||
var _ wardleinitializer.WantsInternalWardleInformerFactory = &wantInternalWardleInformerFactory{}
|
||||
|
|
Loading…
Reference in New Issue