Skip to content

Commit 6951d6e

Browse files
Merge pull request #55282 from mbohlool/webhooks
Automatic merge from submit-queue (batch tested with PRs 55268, 55282, 55419, 48340, 54829). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add MutatingWebhookConfiguration type As part of Mutating Webhook support, this PR adds the configuration for Mutating webhooks. It also renames existing ReadOnly webhook configurations from ExternalAdmissionHookConfiguration to ValidatingWebhookConfiguration. As part of the process some sub-types are also renamed. Lastly, the mutating webhook configurations are sorted by name to make the serial executing of them deterministic. ref: kubernetes/enhancements#492 Kubernetes-commit: 61f210859d9c4bd64af254ba696f6f693596ced9
2 parents 3cb0094 + 992c904 commit 6951d6e

23 files changed

+966
-523
lines changed

Godeps/Godeps.json

Lines changed: 80 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

informers/admissionregistration/v1alpha1/BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ load(
88
go_library(
99
name = "go_default_library",
1010
srcs = [
11-
"externaladmissionhookconfiguration.go",
1211
"initializerconfiguration.go",
1312
"interface.go",
13+
"mutatingwebhookconfiguration.go",
14+
"validatingwebhookconfiguration.go",
1415
],
1516
importpath = "k8s.io/client-go/informers/admissionregistration/v1alpha1",
1617
deps = [

informers/admissionregistration/v1alpha1/externaladmissionhookconfiguration.go

Lines changed: 0 additions & 87 deletions
This file was deleted.

informers/admissionregistration/v1alpha1/interface.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ import (
2424

2525
// Interface provides access to all the informers in this group version.
2626
type Interface interface {
27-
// ExternalAdmissionHookConfigurations returns a ExternalAdmissionHookConfigurationInformer.
28-
ExternalAdmissionHookConfigurations() ExternalAdmissionHookConfigurationInformer
2927
// InitializerConfigurations returns a InitializerConfigurationInformer.
3028
InitializerConfigurations() InitializerConfigurationInformer
29+
// MutatingWebhookConfigurations returns a MutatingWebhookConfigurationInformer.
30+
MutatingWebhookConfigurations() MutatingWebhookConfigurationInformer
31+
// ValidatingWebhookConfigurations returns a ValidatingWebhookConfigurationInformer.
32+
ValidatingWebhookConfigurations() ValidatingWebhookConfigurationInformer
3133
}
3234

3335
type version struct {
@@ -41,12 +43,17 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList
4143
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
4244
}
4345

44-
// ExternalAdmissionHookConfigurations returns a ExternalAdmissionHookConfigurationInformer.
45-
func (v *version) ExternalAdmissionHookConfigurations() ExternalAdmissionHookConfigurationInformer {
46-
return &externalAdmissionHookConfigurationInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
47-
}
48-
4946
// InitializerConfigurations returns a InitializerConfigurationInformer.
5047
func (v *version) InitializerConfigurations() InitializerConfigurationInformer {
5148
return &initializerConfigurationInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
5249
}
50+
51+
// MutatingWebhookConfigurations returns a MutatingWebhookConfigurationInformer.
52+
func (v *version) MutatingWebhookConfigurations() MutatingWebhookConfigurationInformer {
53+
return &mutatingWebhookConfigurationInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
54+
}
55+
56+
// ValidatingWebhookConfigurations returns a ValidatingWebhookConfigurationInformer.
57+
func (v *version) ValidatingWebhookConfigurations() ValidatingWebhookConfigurationInformer {
58+
return &validatingWebhookConfigurationInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
59+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
Copyright 2017 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// This file was automatically generated by informer-gen
18+
19+
package v1alpha1
20+
21+
import (
22+
admissionregistration_v1alpha1 "k8s.io/api/admissionregistration/v1alpha1"
23+
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
runtime "k8s.io/apimachinery/pkg/runtime"
25+
watch "k8s.io/apimachinery/pkg/watch"
26+
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
27+
kubernetes "k8s.io/client-go/kubernetes"
28+
v1alpha1 "k8s.io/client-go/listers/admissionregistration/v1alpha1"
29+
cache "k8s.io/client-go/tools/cache"
30+
time "time"
31+
)
32+
33+
// MutatingWebhookConfigurationInformer provides access to a shared informer and lister for
34+
// MutatingWebhookConfigurations.
35+
type MutatingWebhookConfigurationInformer interface {
36+
Informer() cache.SharedIndexInformer
37+
Lister() v1alpha1.MutatingWebhookConfigurationLister
38+
}
39+
40+
type mutatingWebhookConfigurationInformer struct {
41+
factory internalinterfaces.SharedInformerFactory
42+
tweakListOptions internalinterfaces.TweakListOptionsFunc
43+
}
44+
45+
// NewMutatingWebhookConfigurationInformer constructs a new informer for MutatingWebhookConfiguration type.
46+
// Always prefer using an informer factory to get a shared informer instead of getting an independent
47+
// one. This reduces memory footprint and number of connections to the server.
48+
func NewMutatingWebhookConfigurationInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
49+
return NewFilteredMutatingWebhookConfigurationInformer(client, resyncPeriod, indexers, nil)
50+
}
51+
52+
// NewFilteredMutatingWebhookConfigurationInformer constructs a new informer for MutatingWebhookConfiguration type.
53+
// Always prefer using an informer factory to get a shared informer instead of getting an independent
54+
// one. This reduces memory footprint and number of connections to the server.
55+
func NewFilteredMutatingWebhookConfigurationInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
56+
return cache.NewSharedIndexInformer(
57+
&cache.ListWatch{
58+
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
59+
if tweakListOptions != nil {
60+
tweakListOptions(&options)
61+
}
62+
return client.AdmissionregistrationV1alpha1().MutatingWebhookConfigurations().List(options)
63+
},
64+
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
65+
if tweakListOptions != nil {
66+
tweakListOptions(&options)
67+
}
68+
return client.AdmissionregistrationV1alpha1().MutatingWebhookConfigurations().Watch(options)
69+
},
70+
},
71+
&admissionregistration_v1alpha1.MutatingWebhookConfiguration{},
72+
resyncPeriod,
73+
indexers,
74+
)
75+
}
76+
77+
func (f *mutatingWebhookConfigurationInformer) defaultInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
78+
return NewFilteredMutatingWebhookConfigurationInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
79+
}
80+
81+
func (f *mutatingWebhookConfigurationInformer) Informer() cache.SharedIndexInformer {
82+
return f.factory.InformerFor(&admissionregistration_v1alpha1.MutatingWebhookConfiguration{}, f.defaultInformer)
83+
}
84+
85+
func (f *mutatingWebhookConfigurationInformer) Lister() v1alpha1.MutatingWebhookConfigurationLister {
86+
return v1alpha1.NewMutatingWebhookConfigurationLister(f.Informer().GetIndexer())
87+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
Copyright 2017 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// This file was automatically generated by informer-gen
18+
19+
package v1alpha1
20+
21+
import (
22+
admissionregistration_v1alpha1 "k8s.io/api/admissionregistration/v1alpha1"
23+
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
runtime "k8s.io/apimachinery/pkg/runtime"
25+
watch "k8s.io/apimachinery/pkg/watch"
26+
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
27+
kubernetes "k8s.io/client-go/kubernetes"
28+
v1alpha1 "k8s.io/client-go/listers/admissionregistration/v1alpha1"
29+
cache "k8s.io/client-go/tools/cache"
30+
time "time"
31+
)
32+
33+
// ValidatingWebhookConfigurationInformer provides access to a shared informer and lister for
34+
// ValidatingWebhookConfigurations.
35+
type ValidatingWebhookConfigurationInformer interface {
36+
Informer() cache.SharedIndexInformer
37+
Lister() v1alpha1.ValidatingWebhookConfigurationLister
38+
}
39+
40+
type validatingWebhookConfigurationInformer struct {
41+
factory internalinterfaces.SharedInformerFactory
42+
tweakListOptions internalinterfaces.TweakListOptionsFunc
43+
}
44+
45+
// NewValidatingWebhookConfigurationInformer constructs a new informer for ValidatingWebhookConfiguration type.
46+
// Always prefer using an informer factory to get a shared informer instead of getting an independent
47+
// one. This reduces memory footprint and number of connections to the server.
48+
func NewValidatingWebhookConfigurationInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
49+
return NewFilteredValidatingWebhookConfigurationInformer(client, resyncPeriod, indexers, nil)
50+
}
51+
52+
// NewFilteredValidatingWebhookConfigurationInformer constructs a new informer for ValidatingWebhookConfiguration type.
53+
// Always prefer using an informer factory to get a shared informer instead of getting an independent
54+
// one. This reduces memory footprint and number of connections to the server.
55+
func NewFilteredValidatingWebhookConfigurationInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
56+
return cache.NewSharedIndexInformer(
57+
&cache.ListWatch{
58+
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
59+
if tweakListOptions != nil {
60+
tweakListOptions(&options)
61+
}
62+
return client.AdmissionregistrationV1alpha1().ValidatingWebhookConfigurations().List(options)
63+
},
64+
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
65+
if tweakListOptions != nil {
66+
tweakListOptions(&options)
67+
}
68+
return client.AdmissionregistrationV1alpha1().ValidatingWebhookConfigurations().Watch(options)
69+
},
70+
},
71+
&admissionregistration_v1alpha1.ValidatingWebhookConfiguration{},
72+
resyncPeriod,
73+
indexers,
74+
)
75+
}
76+
77+
func (f *validatingWebhookConfigurationInformer) defaultInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
78+
return NewFilteredValidatingWebhookConfigurationInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
79+
}
80+
81+
func (f *validatingWebhookConfigurationInformer) Informer() cache.SharedIndexInformer {
82+
return f.factory.InformerFor(&admissionregistration_v1alpha1.ValidatingWebhookConfiguration{}, f.defaultInformer)
83+
}
84+
85+
func (f *validatingWebhookConfigurationInformer) Lister() v1alpha1.ValidatingWebhookConfigurationLister {
86+
return v1alpha1.NewValidatingWebhookConfigurationLister(f.Informer().GetIndexer())
87+
}

informers/generic.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ func (f *genericInformer) Lister() cache.GenericLister {
7272
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
7373
switch resource {
7474
// Group=admissionregistration.k8s.io, Version=v1alpha1
75-
case v1alpha1.SchemeGroupVersion.WithResource("externaladmissionhookconfigurations"):
76-
return &genericInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1alpha1().ExternalAdmissionHookConfigurations().Informer()}, nil
7775
case v1alpha1.SchemeGroupVersion.WithResource("initializerconfigurations"):
7876
return &genericInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1alpha1().InitializerConfigurations().Informer()}, nil
77+
case v1alpha1.SchemeGroupVersion.WithResource("mutatingwebhookconfigurations"):
78+
return &genericInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1alpha1().MutatingWebhookConfigurations().Informer()}, nil
79+
case v1alpha1.SchemeGroupVersion.WithResource("validatingwebhookconfigurations"):
80+
return &genericInformer{resource: resource.GroupResource(), informer: f.Admissionregistration().V1alpha1().ValidatingWebhookConfigurations().Informer()}, nil
7981

8082
// Group=apps, Version=v1
8183
case v1.SchemeGroupVersion.WithResource("controllerrevisions"):

kubernetes/typed/admissionregistration/v1alpha1/BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ go_library(
1010
srcs = [
1111
"admissionregistration_client.go",
1212
"doc.go",
13-
"externaladmissionhookconfiguration.go",
1413
"generated_expansion.go",
1514
"initializerconfiguration.go",
15+
"mutatingwebhookconfiguration.go",
16+
"validatingwebhookconfiguration.go",
1617
],
1718
importpath = "k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1",
1819
deps = [

kubernetes/typed/admissionregistration/v1alpha1/admissionregistration_client.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,28 @@ import (
2525

2626
type AdmissionregistrationV1alpha1Interface interface {
2727
RESTClient() rest.Interface
28-
ExternalAdmissionHookConfigurationsGetter
2928
InitializerConfigurationsGetter
29+
MutatingWebhookConfigurationsGetter
30+
ValidatingWebhookConfigurationsGetter
3031
}
3132

3233
// AdmissionregistrationV1alpha1Client is used to interact with features provided by the admissionregistration.k8s.io group.
3334
type AdmissionregistrationV1alpha1Client struct {
3435
restClient rest.Interface
3536
}
3637

37-
func (c *AdmissionregistrationV1alpha1Client) ExternalAdmissionHookConfigurations() ExternalAdmissionHookConfigurationInterface {
38-
return newExternalAdmissionHookConfigurations(c)
39-
}
40-
4138
func (c *AdmissionregistrationV1alpha1Client) InitializerConfigurations() InitializerConfigurationInterface {
4239
return newInitializerConfigurations(c)
4340
}
4441

42+
func (c *AdmissionregistrationV1alpha1Client) MutatingWebhookConfigurations() MutatingWebhookConfigurationInterface {
43+
return newMutatingWebhookConfigurations(c)
44+
}
45+
46+
func (c *AdmissionregistrationV1alpha1Client) ValidatingWebhookConfigurations() ValidatingWebhookConfigurationInterface {
47+
return newValidatingWebhookConfigurations(c)
48+
}
49+
4550
// NewForConfig creates a new AdmissionregistrationV1alpha1Client for the given config.
4651
func NewForConfig(c *rest.Config) (*AdmissionregistrationV1alpha1Client, error) {
4752
config := *c

0 commit comments

Comments
 (0)