diff --git a/client/injection/apiextensions/informers/apiextensions/v1/customresourcedefinition/customresourcedefinition.go b/client/injection/apiextensions/informers/apiextensions/v1/customresourcedefinition/customresourcedefinition.go new file mode 100644 index 0000000000..9c7757d3e4 --- /dev/null +++ b/client/injection/apiextensions/informers/apiextensions/v1/customresourcedefinition/customresourcedefinition.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 The Knative 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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package customresourcedefinition + +import ( + context "context" + + v1 "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1" + factory "knative.dev/pkg/client/injection/apiextensions/informers/factory" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Default.RegisterInformer(withInformer) +} + +// Key is used for associating the Informer inside the context.Context. +type Key struct{} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := factory.Get(ctx) + inf := f.Apiextensions().V1().CustomResourceDefinitions() + return context.WithValue(ctx, Key{}, inf), inf.Informer() +} + +// Get extracts the typed informer from the context. +func Get(ctx context.Context) v1.CustomResourceDefinitionInformer { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1.CustomResourceDefinitionInformer from context.") + } + return untyped.(v1.CustomResourceDefinitionInformer) +} diff --git a/client/injection/apiextensions/informers/apiextensions/v1/customresourcedefinition/fake/fake.go b/client/injection/apiextensions/informers/apiextensions/v1/customresourcedefinition/fake/fake.go new file mode 100644 index 0000000000..4eb1a3cb30 --- /dev/null +++ b/client/injection/apiextensions/informers/apiextensions/v1/customresourcedefinition/fake/fake.go @@ -0,0 +1,40 @@ +/* +Copyright 2020 The Knative 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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package fake + +import ( + context "context" + + customresourcedefinition "knative.dev/pkg/client/injection/apiextensions/informers/apiextensions/v1/customresourcedefinition" + fake "knative.dev/pkg/client/injection/apiextensions/informers/factory/fake" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" +) + +var Get = customresourcedefinition.Get + +func init() { + injection.Fake.RegisterInformer(withInformer) +} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := fake.Get(ctx) + inf := f.Apiextensions().V1().CustomResourceDefinitions() + return context.WithValue(ctx, customresourcedefinition.Key{}, inf), inf.Informer() +} diff --git a/client/injection/apiextensions/reconciler/apiextensions/v1/customresourcedefinition/controller.go b/client/injection/apiextensions/reconciler/apiextensions/v1/customresourcedefinition/controller.go new file mode 100644 index 0000000000..1130d910d9 --- /dev/null +++ b/client/injection/apiextensions/reconciler/apiextensions/v1/customresourcedefinition/controller.go @@ -0,0 +1,118 @@ +/* +Copyright 2020 The Knative 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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package customresourcedefinition + +import ( + context "context" + fmt "fmt" + reflect "reflect" + strings "strings" + + corev1 "k8s.io/api/core/v1" + clientsetscheme "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme" + watch "k8s.io/apimachinery/pkg/watch" + scheme "k8s.io/client-go/kubernetes/scheme" + v1 "k8s.io/client-go/kubernetes/typed/core/v1" + record "k8s.io/client-go/tools/record" + client "knative.dev/pkg/client/injection/apiextensions/client" + customresourcedefinition "knative.dev/pkg/client/injection/apiextensions/informers/apiextensions/v1/customresourcedefinition" + kubeclient "knative.dev/pkg/client/injection/kube/client" + controller "knative.dev/pkg/controller" + logging "knative.dev/pkg/logging" +) + +const ( + defaultControllerAgentName = "customresourcedefinition-controller" + defaultFinalizerName = "customresourcedefinitions.apiextensions.k8s.io" +) + +// NewImpl returns a controller.Impl that handles queuing and feeding work from +// the queue through an implementation of controller.Reconciler, delegating to +// the provided Interface and optional Finalizer methods. OptionsFn is used to return +// controller.Options to be used but the internal reconciler. +func NewImpl(ctx context.Context, r Interface, optionsFns ...controller.OptionsFn) *controller.Impl { + logger := logging.FromContext(ctx) + + // Check the options function input. It should be 0 or 1. + if len(optionsFns) > 1 { + logger.Fatalf("up to one options function is supported, found %d", len(optionsFns)) + } + + customresourcedefinitionInformer := customresourcedefinition.Get(ctx) + + rec := &reconcilerImpl{ + Client: client.Get(ctx), + Lister: customresourcedefinitionInformer.Lister(), + reconciler: r, + finalizerName: defaultFinalizerName, + } + + t := reflect.TypeOf(r).Elem() + queueName := fmt.Sprintf("%s.%s", strings.ReplaceAll(t.PkgPath(), "/", "-"), t.Name()) + + impl := controller.NewImpl(rec, logger, queueName) + agentName := defaultControllerAgentName + + // Pass impl to the options. Save any optional results. + for _, fn := range optionsFns { + opts := fn(impl) + if opts.ConfigStore != nil { + rec.configStore = opts.ConfigStore + } + if opts.FinalizerName != "" { + rec.finalizerName = opts.FinalizerName + } + if opts.AgentName != "" { + agentName = opts.AgentName + } + } + + rec.Recorder = createRecorder(ctx, agentName) + + return impl +} + +func createRecorder(ctx context.Context, agentName string) record.EventRecorder { + logger := logging.FromContext(ctx) + + recorder := controller.GetEventRecorder(ctx) + if recorder == nil { + // Create event broadcaster + logger.Debug("Creating event broadcaster") + eventBroadcaster := record.NewBroadcaster() + watches := []watch.Interface{ + eventBroadcaster.StartLogging(logger.Named("event-broadcaster").Infof), + eventBroadcaster.StartRecordingToSink( + &v1.EventSinkImpl{Interface: kubeclient.Get(ctx).CoreV1().Events("")}), + } + recorder = eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: agentName}) + go func() { + <-ctx.Done() + for _, w := range watches { + w.Stop() + } + }() + } + + return recorder +} + +func init() { + clientsetscheme.AddToScheme(scheme.Scheme) +} diff --git a/client/injection/apiextensions/reconciler/apiextensions/v1/customresourcedefinition/reconciler.go b/client/injection/apiextensions/reconciler/apiextensions/v1/customresourcedefinition/reconciler.go new file mode 100644 index 0000000000..4f858c9c2b --- /dev/null +++ b/client/injection/apiextensions/reconciler/apiextensions/v1/customresourcedefinition/reconciler.go @@ -0,0 +1,353 @@ +/* +Copyright 2020 The Knative 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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package customresourcedefinition + +import ( + context "context" + json "encoding/json" + reflect "reflect" + + zap "go.uber.org/zap" + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + clientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1" + equality "k8s.io/apimachinery/pkg/api/equality" + errors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + sets "k8s.io/apimachinery/pkg/util/sets" + cache "k8s.io/client-go/tools/cache" + record "k8s.io/client-go/tools/record" + controller "knative.dev/pkg/controller" + logging "knative.dev/pkg/logging" + reconciler "knative.dev/pkg/reconciler" +) + +// Interface defines the strongly typed interfaces to be implemented by a +// controller reconciling v1.CustomResourceDefinition. +type Interface interface { + // ReconcileKind implements custom logic to reconcile v1.CustomResourceDefinition. Any changes + // to the objects .Status or .Finalizers will be propagated to the stored + // object. It is recommended that implementors do not call any update calls + // for the Kind inside of ReconcileKind, it is the responsibility of the calling + // controller to propagate those properties. The resource passed to ReconcileKind + // will always have an empty deletion timestamp. + ReconcileKind(ctx context.Context, o *v1.CustomResourceDefinition) reconciler.Event +} + +// Finalizer defines the strongly typed interfaces to be implemented by a +// controller finalizing v1.CustomResourceDefinition. +type Finalizer interface { + // FinalizeKind implements custom logic to finalize v1.CustomResourceDefinition. Any changes + // to the objects .Status or .Finalizers will be ignored. Returning a nil or + // Normal type reconciler.Event will allow the finalizer to be deleted on + // the resource. The resource passed to FinalizeKind will always have a set + // deletion timestamp. + FinalizeKind(ctx context.Context, o *v1.CustomResourceDefinition) reconciler.Event +} + +// reconcilerImpl implements controller.Reconciler for v1.CustomResourceDefinition resources. +type reconcilerImpl struct { + // Client is used to write back status updates. + Client clientset.Interface + + // Listers index properties about resources + Lister apiextensionsv1.CustomResourceDefinitionLister + + // Recorder is an event recorder for recording Event resources to the + // Kubernetes API. + Recorder record.EventRecorder + + // configStore allows for decorating a context with config maps. + // +optional + configStore reconciler.ConfigStore + + // reconciler is the implementation of the business logic of the resource. + reconciler Interface + + // finalizerName is the name of the finalizer to reconcile. + finalizerName string +} + +// Check that our Reconciler implements controller.Reconciler +var _ controller.Reconciler = (*reconcilerImpl)(nil) + +func NewReconciler(ctx context.Context, logger *zap.SugaredLogger, client clientset.Interface, lister apiextensionsv1.CustomResourceDefinitionLister, recorder record.EventRecorder, r Interface, options ...controller.Options) controller.Reconciler { + // Check the options function input. It should be 0 or 1. + if len(options) > 1 { + logger.Fatalf("up to one options struct is supported, found %d", len(options)) + } + + rec := &reconcilerImpl{ + Client: client, + Lister: lister, + Recorder: recorder, + reconciler: r, + finalizerName: defaultFinalizerName, + } + + for _, opts := range options { + if opts.ConfigStore != nil { + rec.configStore = opts.ConfigStore + } + if opts.FinalizerName != "" { + rec.finalizerName = opts.FinalizerName + } + } + + return rec +} + +// Reconcile implements controller.Reconciler +func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { + logger := logging.FromContext(ctx) + + // If configStore is set, attach the frozen configuration to the context. + if r.configStore != nil { + ctx = r.configStore.ToContext(ctx) + } + + // Add the recorder to context. + ctx = controller.WithEventRecorder(ctx, r.Recorder) + + // Convert the namespace/name string into a distinct namespace and name + + _, name, err := cache.SplitMetaNamespaceKey(key) + + if err != nil { + logger.Errorf("invalid resource key: %s", key) + return nil + } + + // Get the resource with this namespace/name. + + getter := r.Lister + + original, err := getter.Get(name) + + if errors.IsNotFound(err) { + // The resource may no longer exist, in which case we stop processing. + logger.Debugf("resource %q no longer exists", key) + return nil + } else if err != nil { + return err + } + + // Don't modify the informers copy. + resource := original.DeepCopy() + + var reconcileEvent reconciler.Event + if resource.GetDeletionTimestamp().IsZero() { + // Append the target method to the logger. + logger = logger.With(zap.String("targetMethod", "ReconcileKind")) + + // Set and update the finalizer on resource if r.reconciler + // implements Finalizer. + if resource, err = r.setFinalizerIfFinalizer(ctx, resource); err != nil { + logger.Warnw("Failed to set finalizers", zap.Error(err)) + } + + // Reconcile this copy of the resource and then write back any status + // updates regardless of whether the reconciliation errored out. + reconcileEvent = r.reconciler.ReconcileKind(ctx, resource) + + } else if fin, ok := r.reconciler.(Finalizer); ok { + // Append the target method to the logger. + logger = logger.With(zap.String("targetMethod", "FinalizeKind")) + + // For finalizing reconcilers, if this resource being marked for deletion + // and reconciled cleanly (nil or normal event), remove the finalizer. + reconcileEvent = fin.FinalizeKind(ctx, resource) + if resource, err = r.clearFinalizer(ctx, resource, reconcileEvent); err != nil { + logger.Warnw("Failed to clear finalizers", zap.Error(err)) + } + } + + // Synchronize the status. + if equality.Semantic.DeepEqual(original.Status, resource.Status) { + // If we didn't change anything then don't call updateStatus. + // This is important because the copy we loaded from the injectionInformer's + // cache may be stale and we don't want to overwrite a prior update + // to status with this stale state. + } else if err = r.updateStatus(original, resource); err != nil { + logger.Warnw("Failed to update resource status", zap.Error(err)) + r.Recorder.Eventf(resource, corev1.EventTypeWarning, "UpdateFailed", + "Failed to update status for %q: %v", resource.Name, err) + return err + } + + // Report the reconciler event, if any. + if reconcileEvent != nil { + var event *reconciler.ReconcilerEvent + if reconciler.EventAs(reconcileEvent, &event) { + logger.Infow("Returned an event", zap.Any("event", reconcileEvent)) + r.Recorder.Eventf(resource, event.EventType, event.Reason, event.Format, event.Args...) + + // the event was wrapped inside an error, consider the reconciliation as failed + if _, isEvent := reconcileEvent.(*reconciler.ReconcilerEvent); !isEvent { + return reconcileEvent + } + return nil + } + + logger.Errorw("Returned an error", zap.Error(reconcileEvent)) + r.Recorder.Event(resource, corev1.EventTypeWarning, "InternalError", reconcileEvent.Error()) + return reconcileEvent + } + + return nil +} + +func (r *reconcilerImpl) updateStatus(existing *v1.CustomResourceDefinition, desired *v1.CustomResourceDefinition) error { + existing = existing.DeepCopy() + return reconciler.RetryUpdateConflicts(func(attempts int) (err error) { + // The first iteration tries to use the injectionInformer's state, subsequent attempts fetch the latest state via API. + if attempts > 0 { + + getter := r.Client.ApiextensionsV1().CustomResourceDefinitions() + + existing, err = getter.Get(desired.Name, metav1.GetOptions{}) + if err != nil { + return err + } + } + + // If there's nothing to update, just return. + if reflect.DeepEqual(existing.Status, desired.Status) { + return nil + } + + existing.Status = desired.Status + + updater := r.Client.ApiextensionsV1().CustomResourceDefinitions() + + _, err = updater.UpdateStatus(existing) + return err + }) +} + +// updateFinalizersFiltered will update the Finalizers of the resource. +// TODO: this method could be generic and sync all finalizers. For now it only +// updates defaultFinalizerName or its override. +func (r *reconcilerImpl) updateFinalizersFiltered(ctx context.Context, resource *v1.CustomResourceDefinition) (*v1.CustomResourceDefinition, error) { + + getter := r.Lister + + actual, err := getter.Get(resource.Name) + if err != nil { + return resource, err + } + + // Don't modify the informers copy. + existing := actual.DeepCopy() + + var finalizers []string + + // If there's nothing to update, just return. + existingFinalizers := sets.NewString(existing.Finalizers...) + desiredFinalizers := sets.NewString(resource.Finalizers...) + + if desiredFinalizers.Has(r.finalizerName) { + if existingFinalizers.Has(r.finalizerName) { + // Nothing to do. + return resource, nil + } + // Add the finalizer. + finalizers = append(existing.Finalizers, r.finalizerName) + } else { + if !existingFinalizers.Has(r.finalizerName) { + // Nothing to do. + return resource, nil + } + // Remove the finalizer. + existingFinalizers.Delete(r.finalizerName) + finalizers = existingFinalizers.List() + } + + mergePatch := map[string]interface{}{ + "metadata": map[string]interface{}{ + "finalizers": finalizers, + "resourceVersion": existing.ResourceVersion, + }, + } + + patch, err := json.Marshal(mergePatch) + if err != nil { + return resource, err + } + + patcher := r.Client.ApiextensionsV1().CustomResourceDefinitions() + + resourceName := resource.Name + resource, err = patcher.Patch(resourceName, types.MergePatchType, patch) + if err != nil { + r.Recorder.Eventf(resource, corev1.EventTypeWarning, "FinalizerUpdateFailed", + "Failed to update finalizers for %q: %v", resourceName, err) + } else { + r.Recorder.Eventf(resource, corev1.EventTypeNormal, "FinalizerUpdate", + "Updated %q finalizers", resource.GetName()) + } + return resource, err +} + +func (r *reconcilerImpl) setFinalizerIfFinalizer(ctx context.Context, resource *v1.CustomResourceDefinition) (*v1.CustomResourceDefinition, error) { + if _, ok := r.reconciler.(Finalizer); !ok { + return resource, nil + } + + finalizers := sets.NewString(resource.Finalizers...) + + // If this resource is not being deleted, mark the finalizer. + if resource.GetDeletionTimestamp().IsZero() { + finalizers.Insert(r.finalizerName) + } + + resource.Finalizers = finalizers.List() + + // Synchronize the finalizers filtered by r.finalizerName. + return r.updateFinalizersFiltered(ctx, resource) +} + +func (r *reconcilerImpl) clearFinalizer(ctx context.Context, resource *v1.CustomResourceDefinition, reconcileEvent reconciler.Event) (*v1.CustomResourceDefinition, error) { + if _, ok := r.reconciler.(Finalizer); !ok { + return resource, nil + } + if resource.GetDeletionTimestamp().IsZero() { + return resource, nil + } + + finalizers := sets.NewString(resource.Finalizers...) + + if reconcileEvent != nil { + var event *reconciler.ReconcilerEvent + if reconciler.EventAs(reconcileEvent, &event) { + if event.EventType == corev1.EventTypeNormal { + finalizers.Delete(r.finalizerName) + } + } + } else { + finalizers.Delete(r.finalizerName) + } + + resource.Finalizers = finalizers.List() + + // Synchronize the finalizers filtered by r.finalizerName. + return r.updateFinalizersFiltered(ctx, resource) +} diff --git a/client/injection/apiextensions/reconciler/apiextensions/v1/customresourcedefinition/stub/controller.go b/client/injection/apiextensions/reconciler/apiextensions/v1/customresourcedefinition/stub/controller.go new file mode 100644 index 0000000000..4ac22d3e79 --- /dev/null +++ b/client/injection/apiextensions/reconciler/apiextensions/v1/customresourcedefinition/stub/controller.go @@ -0,0 +1,54 @@ +/* +Copyright 2020 The Knative 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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package customresourcedefinition + +import ( + context "context" + + customresourcedefinition "knative.dev/pkg/client/injection/apiextensions/informers/apiextensions/v1/customresourcedefinition" + v1customresourcedefinition "knative.dev/pkg/client/injection/apiextensions/reconciler/apiextensions/v1/customresourcedefinition" + configmap "knative.dev/pkg/configmap" + controller "knative.dev/pkg/controller" + logging "knative.dev/pkg/logging" +) + +// TODO: PLEASE COPY AND MODIFY THIS FILE AS A STARTING POINT + +// NewController creates a Reconciler for CustomResourceDefinition and returns the result of NewImpl. +func NewController( + ctx context.Context, + cmw configmap.Watcher, +) *controller.Impl { + logger := logging.FromContext(ctx) + + customresourcedefinitionInformer := customresourcedefinition.Get(ctx) + + // TODO: setup additional informers here. + + r := &Reconciler{} + impl := v1customresourcedefinition.NewImpl(ctx, r) + + logger.Info("Setting up event handlers.") + + customresourcedefinitionInformer.Informer().AddEventHandler(controller.HandleAll(impl.Enqueue)) + + // TODO: add additional informer event handlers here. + + return impl +} diff --git a/client/injection/apiextensions/reconciler/apiextensions/v1/customresourcedefinition/stub/reconciler.go b/client/injection/apiextensions/reconciler/apiextensions/v1/customresourcedefinition/stub/reconciler.go new file mode 100644 index 0000000000..2f95a95a28 --- /dev/null +++ b/client/injection/apiextensions/reconciler/apiextensions/v1/customresourcedefinition/stub/reconciler.go @@ -0,0 +1,66 @@ +/* +Copyright 2020 The Knative 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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package customresourcedefinition + +import ( + context "context" + + v1 "k8s.io/api/core/v1" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + customresourcedefinition "knative.dev/pkg/client/injection/apiextensions/reconciler/apiextensions/v1/customresourcedefinition" + reconciler "knative.dev/pkg/reconciler" +) + +// TODO: PLEASE COPY AND MODIFY THIS FILE AS A STARTING POINT + +// newReconciledNormal makes a new reconciler event with event type Normal, and +// reason CustomResourceDefinitionReconciled. +func newReconciledNormal(namespace, name string) reconciler.Event { + return reconciler.NewEvent(v1.EventTypeNormal, "CustomResourceDefinitionReconciled", "CustomResourceDefinition reconciled: \"%s/%s\"", namespace, name) +} + +// Reconciler implements controller.Reconciler for CustomResourceDefinition resources. +type Reconciler struct { + // TODO: add additional requirements here. +} + +// Check that our Reconciler implements Interface +var _ customresourcedefinition.Interface = (*Reconciler)(nil) + +// Optionally check that our Reconciler implements Finalizer +//var _ customresourcedefinition.Finalizer = (*Reconciler)(nil) + +// ReconcileKind implements Interface.ReconcileKind. +func (r *Reconciler) ReconcileKind(ctx context.Context, o *apiextensionsv1.CustomResourceDefinition) reconciler.Event { + // TODO: use this if the resource implements InitializeConditions. + // o.Status.InitializeConditions() + + // TODO: add custom reconciliation logic here. + + // TODO: use this if the object has .status.ObservedGeneration. + // o.Status.ObservedGeneration = o.Generation + return newReconciledNormal(o.Namespace, o.Name) +} + +// Optionally, use FinalizeKind to add finalizers. FinalizeKind will be called +// when the resource is deleted. +//func (r *Reconciler) FinalizeKind(ctx context.Context, o *apiextensionsv1.CustomResourceDefinition) reconciler.Event { +// // TODO: add custom finalization logic here. +// return nil +//} diff --git a/client/injection/kube/informers/admissionregistration/v1/mutatingwebhookconfiguration/fake/fake.go b/client/injection/kube/informers/admissionregistration/v1/mutatingwebhookconfiguration/fake/fake.go new file mode 100644 index 0000000000..50aa0e1118 --- /dev/null +++ b/client/injection/kube/informers/admissionregistration/v1/mutatingwebhookconfiguration/fake/fake.go @@ -0,0 +1,40 @@ +/* +Copyright 2020 The Knative 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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package fake + +import ( + context "context" + + mutatingwebhookconfiguration "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1/mutatingwebhookconfiguration" + fake "knative.dev/pkg/client/injection/kube/informers/factory/fake" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" +) + +var Get = mutatingwebhookconfiguration.Get + +func init() { + injection.Fake.RegisterInformer(withInformer) +} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := fake.Get(ctx) + inf := f.Admissionregistration().V1().MutatingWebhookConfigurations() + return context.WithValue(ctx, mutatingwebhookconfiguration.Key{}, inf), inf.Informer() +} diff --git a/client/injection/kube/informers/admissionregistration/v1/mutatingwebhookconfiguration/mutatingwebhookconfiguration.go b/client/injection/kube/informers/admissionregistration/v1/mutatingwebhookconfiguration/mutatingwebhookconfiguration.go new file mode 100644 index 0000000000..27b95afa69 --- /dev/null +++ b/client/injection/kube/informers/admissionregistration/v1/mutatingwebhookconfiguration/mutatingwebhookconfiguration.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 The Knative 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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package mutatingwebhookconfiguration + +import ( + context "context" + + v1 "k8s.io/client-go/informers/admissionregistration/v1" + factory "knative.dev/pkg/client/injection/kube/informers/factory" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Default.RegisterInformer(withInformer) +} + +// Key is used for associating the Informer inside the context.Context. +type Key struct{} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := factory.Get(ctx) + inf := f.Admissionregistration().V1().MutatingWebhookConfigurations() + return context.WithValue(ctx, Key{}, inf), inf.Informer() +} + +// Get extracts the typed informer from the context. +func Get(ctx context.Context) v1.MutatingWebhookConfigurationInformer { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch k8s.io/client-go/informers/admissionregistration/v1.MutatingWebhookConfigurationInformer from context.") + } + return untyped.(v1.MutatingWebhookConfigurationInformer) +} diff --git a/client/injection/kube/informers/admissionregistration/v1/validatingwebhookconfiguration/fake/fake.go b/client/injection/kube/informers/admissionregistration/v1/validatingwebhookconfiguration/fake/fake.go new file mode 100644 index 0000000000..de9b29cbee --- /dev/null +++ b/client/injection/kube/informers/admissionregistration/v1/validatingwebhookconfiguration/fake/fake.go @@ -0,0 +1,40 @@ +/* +Copyright 2020 The Knative 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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package fake + +import ( + context "context" + + validatingwebhookconfiguration "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1/validatingwebhookconfiguration" + fake "knative.dev/pkg/client/injection/kube/informers/factory/fake" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" +) + +var Get = validatingwebhookconfiguration.Get + +func init() { + injection.Fake.RegisterInformer(withInformer) +} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := fake.Get(ctx) + inf := f.Admissionregistration().V1().ValidatingWebhookConfigurations() + return context.WithValue(ctx, validatingwebhookconfiguration.Key{}, inf), inf.Informer() +} diff --git a/client/injection/kube/informers/admissionregistration/v1/validatingwebhookconfiguration/validatingwebhookconfiguration.go b/client/injection/kube/informers/admissionregistration/v1/validatingwebhookconfiguration/validatingwebhookconfiguration.go new file mode 100644 index 0000000000..7cc5ac316e --- /dev/null +++ b/client/injection/kube/informers/admissionregistration/v1/validatingwebhookconfiguration/validatingwebhookconfiguration.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 The Knative 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. +*/ + +// Code generated by injection-gen. DO NOT EDIT. + +package validatingwebhookconfiguration + +import ( + context "context" + + v1 "k8s.io/client-go/informers/admissionregistration/v1" + factory "knative.dev/pkg/client/injection/kube/informers/factory" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Default.RegisterInformer(withInformer) +} + +// Key is used for associating the Informer inside the context.Context. +type Key struct{} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := factory.Get(ctx) + inf := f.Admissionregistration().V1().ValidatingWebhookConfigurations() + return context.WithValue(ctx, Key{}, inf), inf.Informer() +} + +// Get extracts the typed informer from the context. +func Get(ctx context.Context) v1.ValidatingWebhookConfigurationInformer { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch k8s.io/client-go/informers/admissionregistration/v1.ValidatingWebhookConfigurationInformer from context.") + } + return untyped.(v1.ValidatingWebhookConfigurationInformer) +} diff --git a/go.sum b/go.sum index 1d1a0d0eae..4683234a24 100644 --- a/go.sum +++ b/go.sum @@ -251,6 +251,7 @@ github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r github.com/docker/docker v1.4.2-0.20180531152204-71cd53e4a197/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v1.4.2-0.20200203170920-46ec8731fbce/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo= github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.6.3/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index d049c42cbc..1337f81100 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -41,7 +41,7 @@ EXTERNAL_INFORMER_PKG="k8s.io/client-go/informers" \ ${REPO_ROOT_DIR}/hack/generate-knative.sh "injection" \ k8s.io/client-go \ k8s.io/api \ - "admissionregistration:v1beta1 apps:v1 autoscaling:v1,v2beta1 batch:v1,v1beta1 core:v1 rbac:v1" \ + "admissionregistration:v1beta1,v1 apps:v1 autoscaling:v1,v2beta1 batch:v1,v1beta1 core:v1 rbac:v1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt \ --force-genreconciler-kinds "Namespace" @@ -50,7 +50,7 @@ VERSIONED_CLIENTSET_PKG="k8s.io/apiextensions-apiserver/pkg/client/clientset/cli ${REPO_ROOT_DIR}/hack/generate-knative.sh "injection" \ k8s.io/apiextensions-apiserver/pkg/client \ k8s.io/apiextensions-apiserver/pkg/apis \ - "apiextensions:v1beta1" \ + "apiextensions:v1beta1,v1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt \ --force-genreconciler-kinds "CustomResourceDefinition" diff --git a/test/webhook-apicoverage/webhook/apicoverage_recorder.go b/test/webhook-apicoverage/webhook/apicoverage_recorder.go index 814a4f1e8f..d78f54194d 100644 --- a/test/webhook-apicoverage/webhook/apicoverage_recorder.go +++ b/test/webhook-apicoverage/webhook/apicoverage_recorder.go @@ -25,8 +25,8 @@ import ( "reflect" "go.uber.org/zap" - "k8s.io/api/admission/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "k8s.io/api/admission/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/serializer" @@ -104,7 +104,7 @@ func (a *APICoverageRecorder) RecordResourceCoverage(w http.ResponseWriter, r *h err error ) - review := &v1beta1.AdmissionReview{} + review := &v1.AdmissionReview{} if body, err = ioutil.ReadAll(r.Body); err != nil { a.Logger.Errorf("Failed reading request body: %v", err) a.appendAndWriteAdmissionResponse(review, false, "Admission Denied", w) @@ -136,10 +136,10 @@ func (a *APICoverageRecorder) RecordResourceCoverage(w http.ResponseWriter, r *h a.appendAndWriteAdmissionResponse(review, true, "Welcome Aboard", w) } -func (a *APICoverageRecorder) appendAndWriteAdmissionResponse(review *v1beta1.AdmissionReview, allowed bool, message string, w http.ResponseWriter) { - review.Response = &v1beta1.AdmissionResponse{ +func (a *APICoverageRecorder) appendAndWriteAdmissionResponse(review *v1.AdmissionReview, allowed bool, message string, w http.ResponseWriter) { + review.Response = &v1.AdmissionResponse{ Allowed: allowed, - Result: &v1.Status{ + Result: &metav1.Status{ Message: message, }, } diff --git a/vendor/k8s.io/api/admission/v1beta1/doc.go b/vendor/k8s.io/api/admission/v1/doc.go similarity index 87% rename from vendor/k8s.io/api/admission/v1beta1/doc.go rename to vendor/k8s.io/api/admission/v1/doc.go index 92f7c19d26..cbc6bb59dd 100644 --- a/vendor/k8s.io/api/admission/v1beta1/doc.go +++ b/vendor/k8s.io/api/admission/v1/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2019 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. @@ -20,4 +20,4 @@ limitations under the License. // +groupName=admission.k8s.io -package v1beta1 // import "k8s.io/api/admission/v1beta1" +package v1 // import "k8s.io/api/admission/v1" diff --git a/vendor/k8s.io/api/admission/v1beta1/generated.pb.go b/vendor/k8s.io/api/admission/v1/generated.pb.go similarity index 87% rename from vendor/k8s.io/api/admission/v1beta1/generated.pb.go rename to vendor/k8s.io/api/admission/v1/generated.pb.go index 10d3bead6f..e6b4f7240e 100644 --- a/vendor/k8s.io/api/admission/v1beta1/generated.pb.go +++ b/vendor/k8s.io/api/admission/v1/generated.pb.go @@ -15,9 +15,9 @@ limitations under the License. */ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: k8s.io/kubernetes/vendor/k8s.io/api/admission/v1beta1/generated.proto +// source: k8s.io/kubernetes/vendor/k8s.io/api/admission/v1/generated.proto -package v1beta1 +package v1 import ( fmt "fmt" @@ -50,7 +50,7 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package func (m *AdmissionRequest) Reset() { *m = AdmissionRequest{} } func (*AdmissionRequest) ProtoMessage() {} func (*AdmissionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b87c2352de86eab9, []int{0} + return fileDescriptor_4b73421fd5edef9f, []int{0} } func (m *AdmissionRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -78,7 +78,7 @@ var xxx_messageInfo_AdmissionRequest proto.InternalMessageInfo func (m *AdmissionResponse) Reset() { *m = AdmissionResponse{} } func (*AdmissionResponse) ProtoMessage() {} func (*AdmissionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b87c2352de86eab9, []int{1} + return fileDescriptor_4b73421fd5edef9f, []int{1} } func (m *AdmissionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -106,7 +106,7 @@ var xxx_messageInfo_AdmissionResponse proto.InternalMessageInfo func (m *AdmissionReview) Reset() { *m = AdmissionReview{} } func (*AdmissionReview) ProtoMessage() {} func (*AdmissionReview) Descriptor() ([]byte, []int) { - return fileDescriptor_b87c2352de86eab9, []int{2} + return fileDescriptor_4b73421fd5edef9f, []int{2} } func (m *AdmissionReview) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -132,75 +132,75 @@ func (m *AdmissionReview) XXX_DiscardUnknown() { var xxx_messageInfo_AdmissionReview proto.InternalMessageInfo func init() { - proto.RegisterType((*AdmissionRequest)(nil), "k8s.io.api.admission.v1beta1.AdmissionRequest") - proto.RegisterType((*AdmissionResponse)(nil), "k8s.io.api.admission.v1beta1.AdmissionResponse") - proto.RegisterMapType((map[string]string)(nil), "k8s.io.api.admission.v1beta1.AdmissionResponse.AuditAnnotationsEntry") - proto.RegisterType((*AdmissionReview)(nil), "k8s.io.api.admission.v1beta1.AdmissionReview") + proto.RegisterType((*AdmissionRequest)(nil), "k8s.io.api.admission.v1.AdmissionRequest") + proto.RegisterType((*AdmissionResponse)(nil), "k8s.io.api.admission.v1.AdmissionResponse") + proto.RegisterMapType((map[string]string)(nil), "k8s.io.api.admission.v1.AdmissionResponse.AuditAnnotationsEntry") + proto.RegisterType((*AdmissionReview)(nil), "k8s.io.api.admission.v1.AdmissionReview") } func init() { - proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/api/admission/v1beta1/generated.proto", fileDescriptor_b87c2352de86eab9) + proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/api/admission/v1/generated.proto", fileDescriptor_4b73421fd5edef9f) } -var fileDescriptor_b87c2352de86eab9 = []byte{ - // 902 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0xd6, 0x8e, 0xed, 0x1d, 0x87, 0xda, 0x9d, 0x82, 0xb4, 0xb2, 0xd0, 0xda, 0xe4, 0x80, - 0x82, 0xd4, 0xcc, 0x92, 0x08, 0xaa, 0xa8, 0xe2, 0x92, 0x25, 0x11, 0x0a, 0x48, 0x4d, 0x34, 0xad, - 0x51, 0xe1, 0x80, 0x34, 0xf6, 0x4e, 0xed, 0xc5, 0xf6, 0xcc, 0xb2, 0x33, 0xeb, 0xe0, 0x1b, 0xe2, - 0xca, 0x85, 0x6f, 0xc0, 0x87, 0xe1, 0x92, 0x63, 0x8f, 0x3d, 0x59, 0xc4, 0x7c, 0x8b, 0x9c, 0xd0, - 0xcc, 0xce, 0x7a, 0xb7, 0x76, 0x02, 0xfd, 0xc3, 0xc9, 0xf3, 0xfe, 0xfc, 0x7e, 0xef, 0xf9, 0xf7, - 0x76, 0xde, 0x80, 0x93, 0xf1, 0xa1, 0x40, 0x21, 0xf7, 0xc6, 0x49, 0x9f, 0xc6, 0x8c, 0x4a, 0x2a, - 0xbc, 0x19, 0x65, 0x01, 0x8f, 0x3d, 0x13, 0x20, 0x51, 0xe8, 0x91, 0x60, 0x1a, 0x0a, 0x11, 0x72, - 0xe6, 0xcd, 0xf6, 0xfb, 0x54, 0x92, 0x7d, 0x6f, 0x48, 0x19, 0x8d, 0x89, 0xa4, 0x01, 0x8a, 0x62, - 0x2e, 0x39, 0xfc, 0x30, 0xcd, 0x46, 0x24, 0x0a, 0xd1, 0x2a, 0x1b, 0x99, 0xec, 0xf6, 0xde, 0x30, - 0x94, 0xa3, 0xa4, 0x8f, 0x06, 0x7c, 0xea, 0x0d, 0xf9, 0x90, 0x7b, 0x1a, 0xd4, 0x4f, 0x9e, 0x6b, - 0x4b, 0x1b, 0xfa, 0x94, 0x92, 0xb5, 0x1f, 0x14, 0x4b, 0x27, 0x72, 0x44, 0x99, 0x0c, 0x07, 0x44, - 0xa6, 0xf5, 0xd7, 0x4b, 0xb7, 0x3f, 0xcb, 0xb3, 0xa7, 0x64, 0x30, 0x0a, 0x19, 0x8d, 0xe7, 0x5e, - 0x34, 0x1e, 0x2a, 0x87, 0xf0, 0xa6, 0x54, 0x92, 0x9b, 0x50, 0xde, 0x6d, 0xa8, 0x38, 0x61, 0x32, - 0x9c, 0xd2, 0x0d, 0xc0, 0xc3, 0xff, 0x02, 0x88, 0xc1, 0x88, 0x4e, 0xc9, 0x3a, 0x6e, 0xe7, 0x0f, - 0x1b, 0xb4, 0x8e, 0x32, 0x45, 0x30, 0xfd, 0x29, 0xa1, 0x42, 0x42, 0x1f, 0x94, 0x93, 0x30, 0x70, - 0xac, 0xae, 0xb5, 0x6b, 0xfb, 0x9f, 0x5e, 0x2e, 0x3a, 0xa5, 0xe5, 0xa2, 0x53, 0xee, 0x9d, 0x1e, - 0x5f, 0x2f, 0x3a, 0x1f, 0xdd, 0x56, 0x48, 0xce, 0x23, 0x2a, 0x50, 0xef, 0xf4, 0x18, 0x2b, 0x30, - 0x7c, 0x06, 0x2a, 0xe3, 0x90, 0x05, 0xce, 0x9d, 0xae, 0xb5, 0xdb, 0x38, 0x78, 0x88, 0xf2, 0x09, - 0xac, 0x60, 0x28, 0x1a, 0x0f, 0x95, 0x43, 0x20, 0x25, 0x03, 0x9a, 0xed, 0xa3, 0xaf, 0x62, 0x9e, - 0x44, 0xdf, 0xd2, 0x58, 0x35, 0xf3, 0x4d, 0xc8, 0x02, 0x7f, 0xdb, 0x14, 0xaf, 0x28, 0x0b, 0x6b, - 0x46, 0x38, 0x02, 0xf5, 0x98, 0x0a, 0x9e, 0xc4, 0x03, 0xea, 0x94, 0x35, 0xfb, 0xa3, 0x37, 0x67, - 0xc7, 0x86, 0xc1, 0x6f, 0x99, 0x0a, 0xf5, 0xcc, 0x83, 0x57, 0xec, 0xf0, 0x73, 0xd0, 0x10, 0x49, - 0x3f, 0x0b, 0x38, 0x15, 0xad, 0xc7, 0x7d, 0x03, 0x68, 0x3c, 0xc9, 0x43, 0xb8, 0x98, 0x07, 0x43, - 0xd0, 0x88, 0x53, 0x25, 0x55, 0xd7, 0xce, 0x7b, 0xef, 0xa4, 0x40, 0x53, 0x95, 0xc2, 0x39, 0x1d, - 0x2e, 0x72, 0xc3, 0x39, 0x68, 0x1a, 0x73, 0xd5, 0xe5, 0xdd, 0x77, 0x96, 0xe4, 0xfe, 0x72, 0xd1, - 0x69, 0xe2, 0x57, 0x69, 0xf1, 0x7a, 0x1d, 0xf8, 0x35, 0x80, 0xc6, 0x55, 0x10, 0xc2, 0x69, 0x6a, - 0x8d, 0xda, 0x46, 0x23, 0x88, 0x37, 0x32, 0xf0, 0x0d, 0x28, 0xd8, 0x05, 0x15, 0x46, 0xa6, 0xd4, - 0xd9, 0xd2, 0xe8, 0xd5, 0xd0, 0x1f, 0x93, 0x29, 0xc5, 0x3a, 0x02, 0x3d, 0x60, 0xab, 0x5f, 0x11, - 0x91, 0x01, 0x75, 0xaa, 0x3a, 0xed, 0x9e, 0x49, 0xb3, 0x1f, 0x67, 0x01, 0x9c, 0xe7, 0xc0, 0x2f, - 0x80, 0xcd, 0x23, 0xf5, 0xa9, 0x87, 0x9c, 0x39, 0x35, 0x0d, 0x70, 0x33, 0xc0, 0x59, 0x16, 0xb8, - 0x2e, 0x1a, 0x38, 0x07, 0xc0, 0xa7, 0xa0, 0x9e, 0x08, 0x1a, 0x9f, 0xb2, 0xe7, 0xdc, 0xa9, 0x6b, - 0x41, 0x3f, 0x46, 0xc5, 0x1d, 0xf2, 0xca, 0xb5, 0x57, 0x42, 0xf6, 0x4c, 0x76, 0xfe, 0x3d, 0x65, - 0x1e, 0xbc, 0x62, 0x82, 0x3d, 0x50, 0xe5, 0xfd, 0x1f, 0xe9, 0x40, 0x3a, 0xb6, 0xe6, 0xdc, 0xbb, - 0x75, 0x48, 0xe6, 0xd6, 0x22, 0x4c, 0x2e, 0x4e, 0x7e, 0x96, 0x94, 0xa9, 0xf9, 0xf8, 0x77, 0x0d, - 0x75, 0xf5, 0x4c, 0x93, 0x60, 0x43, 0x06, 0x7f, 0x00, 0x36, 0x9f, 0x04, 0xa9, 0xd3, 0x01, 0x6f, - 0xc3, 0xbc, 0x92, 0xf2, 0x2c, 0xe3, 0xc1, 0x39, 0x25, 0xdc, 0x01, 0xd5, 0x20, 0x9e, 0xe3, 0x84, - 0x39, 0x8d, 0xae, 0xb5, 0x5b, 0xf7, 0x81, 0xea, 0xe1, 0x58, 0x7b, 0xb0, 0x89, 0xc0, 0x67, 0xa0, - 0xc6, 0x23, 0x25, 0x86, 0x70, 0xb6, 0xdf, 0xa6, 0x83, 0xa6, 0xe9, 0xa0, 0x76, 0x96, 0xb2, 0xe0, - 0x8c, 0x6e, 0xe7, 0xd7, 0x0a, 0xb8, 0x57, 0xd8, 0x50, 0x22, 0xe2, 0x4c, 0xd0, 0xff, 0x65, 0x45, - 0x7d, 0x02, 0x6a, 0x64, 0x32, 0xe1, 0x17, 0x34, 0xdd, 0x52, 0xf5, 0xbc, 0x89, 0xa3, 0xd4, 0x8d, - 0xb3, 0x38, 0x3c, 0x07, 0x55, 0x21, 0x89, 0x4c, 0x84, 0xd9, 0x38, 0x0f, 0x5e, 0xef, 0x7a, 0x3d, - 0xd1, 0x98, 0x54, 0x30, 0x4c, 0x45, 0x32, 0x91, 0xd8, 0xf0, 0xc0, 0x0e, 0xd8, 0x8a, 0x88, 0x1c, - 0x8c, 0xf4, 0x56, 0xd9, 0xf6, 0xed, 0xe5, 0xa2, 0xb3, 0x75, 0xae, 0x1c, 0x38, 0xf5, 0xc3, 0x43, - 0x60, 0xeb, 0xc3, 0xd3, 0x79, 0x94, 0x5d, 0x8c, 0xb6, 0x1a, 0xd1, 0x79, 0xe6, 0xbc, 0x2e, 0x1a, - 0x38, 0x4f, 0x86, 0xbf, 0x59, 0xa0, 0x45, 0x92, 0x20, 0x94, 0x47, 0x8c, 0x71, 0x49, 0xd2, 0xa9, - 0x54, 0xbb, 0xe5, 0xdd, 0xc6, 0xc1, 0x09, 0xfa, 0xb7, 0x97, 0x10, 0x6d, 0xe8, 0x8c, 0x8e, 0xd6, - 0x78, 0x4e, 0x98, 0x8c, 0xe7, 0xbe, 0x63, 0x84, 0x6a, 0xad, 0x87, 0xf1, 0x46, 0xe1, 0xf6, 0x97, - 0xe0, 0x83, 0x1b, 0x49, 0x60, 0x0b, 0x94, 0xc7, 0x74, 0x9e, 0x8e, 0x10, 0xab, 0x23, 0x7c, 0x1f, - 0x6c, 0xcd, 0xc8, 0x24, 0xa1, 0x7a, 0x1c, 0x36, 0x4e, 0x8d, 0x47, 0x77, 0x0e, 0xad, 0x9d, 0x3f, - 0x2d, 0xd0, 0x2c, 0x34, 0x37, 0x0b, 0xe9, 0x05, 0xec, 0x81, 0x9a, 0x59, 0x25, 0x9a, 0xa3, 0x71, - 0x80, 0x5e, 0xfb, 0xcf, 0x69, 0x94, 0xdf, 0x50, 0xa3, 0xce, 0xf6, 0x5c, 0xc6, 0x05, 0xbf, 0xd3, - 0xcf, 0x8b, 0xfe, 0xf7, 0xe6, 0xf1, 0xf2, 0xde, 0x50, 0x34, 0x7f, 0xdb, 0xbc, 0x27, 0xda, 0xc2, - 0x2b, 0x3a, 0x7f, 0xef, 0xf2, 0xca, 0x2d, 0xbd, 0xb8, 0x72, 0x4b, 0x2f, 0xaf, 0xdc, 0xd2, 0x2f, - 0x4b, 0xd7, 0xba, 0x5c, 0xba, 0xd6, 0x8b, 0xa5, 0x6b, 0xbd, 0x5c, 0xba, 0xd6, 0x5f, 0x4b, 0xd7, - 0xfa, 0xfd, 0x6f, 0xb7, 0xf4, 0x7d, 0xcd, 0x10, 0xff, 0x13, 0x00, 0x00, 0xff, 0xff, 0x8b, 0xd1, - 0x27, 0x74, 0xfd, 0x08, 0x00, 0x00, +var fileDescriptor_4b73421fd5edef9f = []byte{ + // 898 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4d, 0x6f, 0x1b, 0x45, + 0x18, 0xf6, 0xc6, 0x89, 0xed, 0x1d, 0x87, 0xda, 0x9d, 0x82, 0x58, 0xf9, 0xb0, 0x36, 0x39, 0x20, + 0x17, 0xb5, 0xb3, 0x24, 0x82, 0x2a, 0xaa, 0x38, 0x34, 0x4b, 0x2a, 0x14, 0x90, 0x9a, 0x68, 0xda, + 0xa0, 0x8a, 0x03, 0xd2, 0xd8, 0x3b, 0xb5, 0x17, 0xdb, 0x33, 0xcb, 0xce, 0xac, 0x83, 0x6f, 0x9c, + 0x38, 0xf3, 0x0f, 0xf8, 0x1d, 0xfc, 0x83, 0x1c, 0x7b, 0xec, 0xc9, 0x22, 0xe6, 0x5f, 0x44, 0x42, + 0x42, 0x33, 0x3b, 0xfb, 0xd1, 0x7c, 0x88, 0xd0, 0xf4, 0xe4, 0x79, 0x3f, 0x9e, 0xe7, 0x7d, 0xfd, + 0xbc, 0x3b, 0xef, 0x80, 0x27, 0x93, 0x5d, 0x81, 0x42, 0xee, 0x4d, 0x92, 0x01, 0x8d, 0x19, 0x95, + 0x54, 0x78, 0x73, 0xca, 0x02, 0x1e, 0x7b, 0x26, 0x40, 0xa2, 0xd0, 0x23, 0xc1, 0x2c, 0x14, 0x22, + 0xe4, 0xcc, 0x9b, 0x6f, 0x7b, 0x23, 0xca, 0x68, 0x4c, 0x24, 0x0d, 0x50, 0x14, 0x73, 0xc9, 0xe1, + 0xc7, 0x69, 0x22, 0x22, 0x51, 0x88, 0xf2, 0x44, 0x34, 0xdf, 0xee, 0x3c, 0x1c, 0x85, 0x72, 0x9c, + 0x0c, 0xd0, 0x90, 0xcf, 0xbc, 0x11, 0x1f, 0x71, 0x4f, 0xe7, 0x0f, 0x92, 0x57, 0xda, 0xd2, 0x86, + 0x3e, 0xa5, 0x3c, 0x9d, 0x07, 0xe5, 0x82, 0x89, 0x1c, 0x53, 0x26, 0xc3, 0x21, 0x91, 0x57, 0x57, + 0xed, 0x7c, 0x51, 0x64, 0xcf, 0xc8, 0x70, 0x1c, 0x32, 0x1a, 0x2f, 0xbc, 0x68, 0x32, 0x52, 0x0e, + 0xe1, 0xcd, 0xa8, 0x24, 0x57, 0xa1, 0xbc, 0xeb, 0x50, 0x71, 0xc2, 0x64, 0x38, 0xa3, 0x97, 0x00, + 0x8f, 0xfe, 0x0b, 0x20, 0x86, 0x63, 0x3a, 0x23, 0x17, 0x71, 0x5b, 0x7f, 0xd8, 0xa0, 0xbd, 0x97, + 0x89, 0x81, 0xe9, 0xcf, 0x09, 0x15, 0x12, 0xfa, 0xa0, 0x9a, 0x84, 0x81, 0x63, 0xf5, 0xac, 0xbe, + 0xed, 0x7f, 0x7e, 0xba, 0xec, 0x56, 0x56, 0xcb, 0x6e, 0xf5, 0xf8, 0x60, 0xff, 0x7c, 0xd9, 0xfd, + 0xe4, 0xba, 0x42, 0x72, 0x11, 0x51, 0x81, 0x8e, 0x0f, 0xf6, 0xb1, 0x02, 0xc3, 0x97, 0x60, 0x7d, + 0x12, 0xb2, 0xc0, 0x59, 0xeb, 0x59, 0xfd, 0xe6, 0xce, 0x23, 0x54, 0x88, 0x9f, 0xc3, 0x50, 0x34, + 0x19, 0x29, 0x87, 0x40, 0x4a, 0x06, 0x34, 0xdf, 0x46, 0xdf, 0xc4, 0x3c, 0x89, 0xbe, 0xa7, 0xb1, + 0x6a, 0xe6, 0xbb, 0x90, 0x05, 0xfe, 0xa6, 0x29, 0xbe, 0xae, 0x2c, 0xac, 0x19, 0xe1, 0x18, 0x34, + 0x62, 0x2a, 0x78, 0x12, 0x0f, 0xa9, 0x53, 0xd5, 0xec, 0x8f, 0xff, 0x3f, 0x3b, 0x36, 0x0c, 0x7e, + 0xdb, 0x54, 0x68, 0x64, 0x1e, 0x9c, 0xb3, 0xc3, 0x2f, 0x41, 0x53, 0x24, 0x83, 0x2c, 0xe0, 0xac, + 0x6b, 0x3d, 0xee, 0x19, 0x40, 0xf3, 0x79, 0x11, 0xc2, 0xe5, 0x3c, 0x18, 0x82, 0x66, 0x9c, 0x2a, + 0xa9, 0xba, 0x76, 0x3e, 0xb8, 0x95, 0x02, 0x2d, 0x55, 0x0a, 0x17, 0x74, 0xb8, 0xcc, 0x0d, 0x17, + 0xa0, 0x65, 0xcc, 0xbc, 0xcb, 0x3b, 0xb7, 0x96, 0xe4, 0xde, 0x6a, 0xd9, 0x6d, 0xe1, 0xb7, 0x69, + 0xf1, 0xc5, 0x3a, 0xf0, 0x5b, 0x00, 0x8d, 0xab, 0x24, 0x84, 0xd3, 0xd2, 0x1a, 0x75, 0x8c, 0x46, + 0x10, 0x5f, 0xca, 0xc0, 0x57, 0xa0, 0x60, 0x0f, 0xac, 0x33, 0x32, 0xa3, 0xce, 0x86, 0x46, 0xe7, + 0x43, 0x7f, 0x46, 0x66, 0x14, 0xeb, 0x08, 0xf4, 0x80, 0xad, 0x7e, 0x45, 0x44, 0x86, 0xd4, 0xa9, + 0xe9, 0xb4, 0xbb, 0x26, 0xcd, 0x7e, 0x96, 0x05, 0x70, 0x91, 0x03, 0xbf, 0x02, 0x36, 0x8f, 0xd4, + 0xa7, 0x1e, 0x72, 0xe6, 0xd4, 0x35, 0xc0, 0xcd, 0x00, 0x87, 0x59, 0xe0, 0xbc, 0x6c, 0xe0, 0x02, + 0x00, 0x5f, 0x80, 0x46, 0x22, 0x68, 0x7c, 0xc0, 0x5e, 0x71, 0xa7, 0xa1, 0x05, 0xfd, 0x14, 0x95, + 0xd7, 0xc7, 0x5b, 0xd7, 0x5e, 0x09, 0x79, 0x6c, 0xb2, 0x8b, 0xef, 0x29, 0xf3, 0xe0, 0x9c, 0x09, + 0x1e, 0x83, 0x1a, 0x1f, 0xfc, 0x44, 0x87, 0xd2, 0xb1, 0x35, 0xe7, 0xc3, 0x6b, 0x87, 0x64, 0x6e, + 0x2d, 0xc2, 0xe4, 0xe4, 0xe9, 0x2f, 0x92, 0x32, 0x35, 0x1f, 0xff, 0x8e, 0xa1, 0xae, 0x1d, 0x6a, + 0x12, 0x6c, 0xc8, 0xe0, 0x8f, 0xc0, 0xe6, 0xd3, 0x20, 0x75, 0x3a, 0xe0, 0x5d, 0x98, 0x73, 0x29, + 0x0f, 0x33, 0x1e, 0x5c, 0x50, 0xc2, 0x2d, 0x50, 0x0b, 0xe2, 0x05, 0x4e, 0x98, 0xd3, 0xec, 0x59, + 0xfd, 0x86, 0x0f, 0x54, 0x0f, 0xfb, 0xda, 0x83, 0x4d, 0x04, 0xbe, 0x04, 0x75, 0x1e, 0x29, 0x31, + 0x84, 0xb3, 0xf9, 0x2e, 0x1d, 0xb4, 0x4c, 0x07, 0xf5, 0xc3, 0x94, 0x05, 0x67, 0x74, 0x5b, 0xff, + 0x54, 0xc1, 0xdd, 0xd2, 0x86, 0x12, 0x11, 0x67, 0x82, 0xbe, 0x97, 0x15, 0x75, 0x1f, 0xd4, 0xc9, + 0x74, 0xca, 0x4f, 0x68, 0xba, 0xa5, 0x1a, 0x45, 0x13, 0x7b, 0xa9, 0x1b, 0x67, 0x71, 0x78, 0x04, + 0x6a, 0x42, 0x12, 0x99, 0x08, 0xb3, 0x71, 0x1e, 0xdc, 0xec, 0x7a, 0x3d, 0xd7, 0x98, 0x54, 0x30, + 0x4c, 0x45, 0x32, 0x95, 0xd8, 0xf0, 0xc0, 0x2e, 0xd8, 0x88, 0x88, 0x1c, 0x8e, 0xf5, 0x56, 0xd9, + 0xf4, 0xed, 0xd5, 0xb2, 0xbb, 0x71, 0xa4, 0x1c, 0x38, 0xf5, 0xc3, 0x5d, 0x60, 0xeb, 0xc3, 0x8b, + 0x45, 0x94, 0x5d, 0x8c, 0x8e, 0x1a, 0xd1, 0x51, 0xe6, 0x3c, 0x2f, 0x1b, 0xb8, 0x48, 0x86, 0xbf, + 0x59, 0xa0, 0x4d, 0x92, 0x20, 0x94, 0x7b, 0x8c, 0x71, 0x49, 0xd2, 0xa9, 0xd4, 0x7a, 0xd5, 0x7e, + 0x73, 0xe7, 0x09, 0xba, 0xe6, 0x11, 0x44, 0x97, 0x24, 0x46, 0x7b, 0x17, 0x28, 0x9e, 0x32, 0x19, + 0x2f, 0x7c, 0xc7, 0x68, 0xd4, 0xbe, 0x18, 0xc6, 0x97, 0x6a, 0x76, 0xbe, 0x06, 0x1f, 0x5d, 0x49, + 0x02, 0xdb, 0xa0, 0x3a, 0xa1, 0x8b, 0x74, 0x7a, 0x58, 0x1d, 0xe1, 0x87, 0x60, 0x63, 0x4e, 0xa6, + 0x09, 0xd5, 0x93, 0xb0, 0x71, 0x6a, 0x3c, 0x5e, 0xdb, 0xb5, 0xb6, 0xfe, 0xb4, 0x40, 0xab, 0xd4, + 0xdc, 0x3c, 0xa4, 0x27, 0xf0, 0x08, 0xd4, 0xcd, 0x16, 0xd1, 0x1c, 0xcd, 0x9d, 0xfb, 0x37, 0xf9, + 0x5f, 0x1a, 0xe0, 0x37, 0xd5, 0x80, 0xb3, 0xed, 0x96, 0xd1, 0xa8, 0x0b, 0x1f, 0x9b, 0x3f, 0x6e, + 0x9e, 0xac, 0xcf, 0x6e, 0x2e, 0x95, 0xbf, 0x69, 0x1e, 0x10, 0x6d, 0xe1, 0x9c, 0xc9, 0xef, 0x9f, + 0x9e, 0xb9, 0x95, 0xd7, 0x67, 0x6e, 0xe5, 0xcd, 0x99, 0x5b, 0xf9, 0x75, 0xe5, 0x5a, 0xa7, 0x2b, + 0xd7, 0x7a, 0xbd, 0x72, 0xad, 0x37, 0x2b, 0xd7, 0xfa, 0x6b, 0xe5, 0x5a, 0xbf, 0xff, 0xed, 0x56, + 0x7e, 0x58, 0x9b, 0x6f, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x37, 0xc7, 0x3f, 0x71, 0xdf, 0x08, + 0x00, 0x00, } func (m *AdmissionRequest) Marshal() (dAtA []byte, err error) { diff --git a/vendor/k8s.io/api/admission/v1beta1/generated.proto b/vendor/k8s.io/api/admission/v1/generated.proto similarity index 98% rename from vendor/k8s.io/api/admission/v1beta1/generated.proto rename to vendor/k8s.io/api/admission/v1/generated.proto index 6999b80c27..8d960a17d3 100644 --- a/vendor/k8s.io/api/admission/v1beta1/generated.proto +++ b/vendor/k8s.io/api/admission/v1/generated.proto @@ -19,7 +19,7 @@ limitations under the License. syntax = 'proto2'; -package k8s.io.api.admission.v1beta1; +package k8s.io.api.admission.v1; import "k8s.io/api/authentication/v1/generated.proto"; import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto"; @@ -27,7 +27,7 @@ import "k8s.io/apimachinery/pkg/runtime/generated.proto"; import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto"; // Package-wide variables from generator "generated". -option go_package = "v1beta1"; +option go_package = "v1"; // AdmissionRequest describes the admission.Attributes for the admission request. message AdmissionRequest { @@ -120,7 +120,7 @@ message AdmissionRequest { // AdmissionResponse describes an admission response. message AdmissionResponse { // UID is an identifier for the individual request/response. - // This should be copied over from the corresponding AdmissionRequest. + // This must be copied over from the corresponding AdmissionRequest. optional string uid = 1; // Allowed indicates whether or not the admission request was permitted. diff --git a/vendor/k8s.io/api/admission/v1beta1/register.go b/vendor/k8s.io/api/admission/v1/register.go similarity index 95% rename from vendor/k8s.io/api/admission/v1beta1/register.go rename to vendor/k8s.io/api/admission/v1/register.go index 78d21a0c8a..b548509ab3 100644 --- a/vendor/k8s.io/api/admission/v1beta1/register.go +++ b/vendor/k8s.io/api/admission/v1/register.go @@ -1,5 +1,5 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2019 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. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -26,7 +26,7 @@ import ( const GroupName = "admission.k8s.io" // SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} // Resource takes an unqualified resource and returns a Group qualified GroupResource func Resource(resource string) schema.GroupResource { diff --git a/vendor/k8s.io/api/admission/v1beta1/types.go b/vendor/k8s.io/api/admission/v1/types.go similarity index 98% rename from vendor/k8s.io/api/admission/v1beta1/types.go rename to vendor/k8s.io/api/admission/v1/types.go index 2cb9ea55a3..a40cb0d52e 100644 --- a/vendor/k8s.io/api/admission/v1beta1/types.go +++ b/vendor/k8s.io/api/admission/v1/types.go @@ -1,5 +1,5 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2019 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. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1 import ( authenticationv1 "k8s.io/api/authentication/v1" @@ -115,7 +115,7 @@ type AdmissionRequest struct { // AdmissionResponse describes an admission response. type AdmissionResponse struct { // UID is an identifier for the individual request/response. - // This should be copied over from the corresponding AdmissionRequest. + // This must be copied over from the corresponding AdmissionRequest. UID types.UID `json:"uid" protobuf:"bytes,1,opt,name=uid"` // Allowed indicates whether or not the admission request was permitted. diff --git a/vendor/k8s.io/api/admission/v1beta1/types_swagger_doc_generated.go b/vendor/k8s.io/api/admission/v1/types_swagger_doc_generated.go similarity index 98% rename from vendor/k8s.io/api/admission/v1beta1/types_swagger_doc_generated.go rename to vendor/k8s.io/api/admission/v1/types_swagger_doc_generated.go index 2ef98db872..62351b1617 100644 --- a/vendor/k8s.io/api/admission/v1beta1/types_swagger_doc_generated.go +++ b/vendor/k8s.io/api/admission/v1/types_swagger_doc_generated.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1 // This file contains a collection of methods that can be used from go-restful to // generate Swagger API documentation for its models. Please read this PR for more @@ -52,7 +52,7 @@ func (AdmissionRequest) SwaggerDoc() map[string]string { var map_AdmissionResponse = map[string]string{ "": "AdmissionResponse describes an admission response.", - "uid": "UID is an identifier for the individual request/response. This should be copied over from the corresponding AdmissionRequest.", + "uid": "UID is an identifier for the individual request/response. This must be copied over from the corresponding AdmissionRequest.", "allowed": "Allowed indicates whether or not the admission request was permitted.", "status": "Result contains extra details into why an admission request was denied. This field IS NOT consulted in any way if \"Allowed\" is \"true\".", "patch": "The patch body. Currently we only support \"JSONPatch\" which implements RFC 6902.", diff --git a/vendor/k8s.io/api/admission/v1beta1/zz_generated.deepcopy.go b/vendor/k8s.io/api/admission/v1/zz_generated.deepcopy.go similarity index 95% rename from vendor/k8s.io/api/admission/v1beta1/zz_generated.deepcopy.go rename to vendor/k8s.io/api/admission/v1/zz_generated.deepcopy.go index e4704c86dd..42954ca427 100644 --- a/vendor/k8s.io/api/admission/v1beta1/zz_generated.deepcopy.go +++ b/vendor/k8s.io/api/admission/v1/zz_generated.deepcopy.go @@ -18,10 +18,10 @@ limitations under the License. // Code generated by deepcopy-gen. DO NOT EDIT. -package v1beta1 +package v1 import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -32,12 +32,12 @@ func (in *AdmissionRequest) DeepCopyInto(out *AdmissionRequest) { out.Resource = in.Resource if in.RequestKind != nil { in, out := &in.RequestKind, &out.RequestKind - *out = new(v1.GroupVersionKind) + *out = new(metav1.GroupVersionKind) **out = **in } if in.RequestResource != nil { in, out := &in.RequestResource, &out.RequestResource - *out = new(v1.GroupVersionResource) + *out = new(metav1.GroupVersionResource) **out = **in } in.UserInfo.DeepCopyInto(&out.UserInfo) @@ -67,7 +67,7 @@ func (in *AdmissionResponse) DeepCopyInto(out *AdmissionResponse) { *out = *in if in.Result != nil { in, out := &in.Result, &out.Result - *out = new(v1.Status) + *out = new(metav1.Status) (*in).DeepCopyInto(*out) } if in.Patch != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index 6bbe92abd0..086338d7f4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -530,7 +530,7 @@ honnef.co/go/tools/unused honnef.co/go/tools/version # k8s.io/api v0.17.6 => k8s.io/api v0.17.6 ## explicit -k8s.io/api/admission/v1beta1 +k8s.io/api/admission/v1 k8s.io/api/admissionregistration/v1 k8s.io/api/admissionregistration/v1beta1 k8s.io/api/apps/v1 diff --git a/webhook/admission.go b/webhook/admission.go index da9c526311..086f39dab1 100644 --- a/webhook/admission.go +++ b/webhook/admission.go @@ -24,7 +24,7 @@ import ( "time" "go.uber.org/zap" - admissionv1beta1 "k8s.io/api/admission/v1beta1" + admissionv1 "k8s.io/api/admission/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "knative.dev/pkg/logging" "knative.dev/pkg/logging/logkey" @@ -36,7 +36,7 @@ type AdmissionController interface { Path() string // Admit is the callback which is invoked when an HTTPS request comes in on Path(). - Admit(context.Context, *admissionv1beta1.AdmissionRequest) *admissionv1beta1.AdmissionResponse + Admit(context.Context, *admissionv1.AdmissionRequest) *admissionv1.AdmissionResponse } // StatelessAdmissionController is implemented by AdmissionControllers where Admit may be safely @@ -48,9 +48,9 @@ type StatelessAdmissionController interface { } // MakeErrorStatus creates an 'BadRequest' error AdmissionResponse -func MakeErrorStatus(reason string, args ...interface{}) *admissionv1beta1.AdmissionResponse { +func MakeErrorStatus(reason string, args ...interface{}) *admissionv1.AdmissionResponse { result := apierrors.NewBadRequest(fmt.Sprintf(reason, args...)).Status() - return &admissionv1beta1.AdmissionResponse{ + return &admissionv1.AdmissionResponse{ Result: &result, Allowed: false, } @@ -71,7 +71,7 @@ func admissionHandler(rootLogger *zap.SugaredLogger, stats StatsReporter, c Admi logger := rootLogger logger.Infof("Webhook ServeHTTP request=%#v", r) - var review admissionv1beta1.AdmissionReview + var review admissionv1.AdmissionReview if err := json.NewDecoder(r.Body).Decode(&review); err != nil { http.Error(w, fmt.Sprintf("could not decode body: %v", err), http.StatusBadRequest) return @@ -88,7 +88,7 @@ func admissionHandler(rootLogger *zap.SugaredLogger, stats StatsReporter, c Admi ctx := logging.WithLogger(r.Context(), logger) - var response admissionv1beta1.AdmissionReview + var response admissionv1.AdmissionReview reviewResponse := c.Admit(ctx, review.Request) var patchType string if reviewResponse.PatchType != nil { diff --git a/webhook/admission_integration_test.go b/webhook/admission_integration_test.go index 4f741c408d..82be9bb1f6 100644 --- a/webhook/admission_integration_test.go +++ b/webhook/admission_integration_test.go @@ -30,7 +30,7 @@ import ( "golang.org/x/sync/errgroup" jsonpatch "gomodules.xyz/jsonpatch/v2" - admissionv1beta1 "k8s.io/api/admission/v1beta1" + admissionv1 "k8s.io/api/admission/v1" authenticationv1 "k8s.io/api/authentication/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/metrics/metricstest" @@ -39,7 +39,7 @@ import ( type fixedAdmissionController struct { path string - response *admissionv1beta1.AdmissionResponse + response *admissionv1.AdmissionResponse } var _ AdmissionController = (*fixedAdmissionController)(nil) @@ -48,14 +48,14 @@ func (fac *fixedAdmissionController) Path() string { return fac.path } -func (fac *fixedAdmissionController) Admit(ctx context.Context, req *admissionv1beta1.AdmissionRequest) *admissionv1beta1.AdmissionResponse { +func (fac *fixedAdmissionController) Admit(ctx context.Context, req *admissionv1.AdmissionRequest) *admissionv1.AdmissionResponse { return fac.response } func TestAdmissionEmptyRequestBody(t *testing.T) { c := &fixedAdmissionController{ path: "/bazinga", - response: &admissionv1beta1.AdmissionResponse{}, + response: &admissionv1.AdmissionResponse{}, } testEmptyRequestBody(t, c) @@ -64,7 +64,7 @@ func TestAdmissionEmptyRequestBody(t *testing.T) { func TestAdmissionValidResponseForResource(t *testing.T) { ac := &fixedAdmissionController{ path: "/bazinga", - response: &admissionv1beta1.AdmissionResponse{}, + response: &admissionv1.AdmissionResponse{}, } wh, serverURL, ctx, cancel, err := testSetup(t, ac) if err != nil { @@ -89,8 +89,8 @@ func TestAdmissionValidResponseForResource(t *testing.T) { t.Fatalf("createSecureTLSClient() = %v", err) } - admissionreq := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + admissionreq := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -105,7 +105,7 @@ func TestAdmissionValidResponseForResource(t *testing.T) { admissionreq.Resource.Group = "pkg.knative.dev" admissionreq.Object.Raw = marshaled - rev := &admissionv1beta1.AdmissionReview{ + rev := &admissionv1.AdmissionReview{ Request: admissionreq, } @@ -149,7 +149,7 @@ func TestAdmissionValidResponseForResource(t *testing.T) { return } - reviewResponse := admissionv1beta1.AdmissionReview{} + reviewResponse := admissionv1.AdmissionReview{} err = json.NewDecoder(bytes.NewReader(responseBody)).Decode(&reviewResponse) if err != nil { @@ -216,8 +216,8 @@ func TestAdmissionInvalidResponseForResource(t *testing.T) { t.Fatalf("Failed to marshal resource: %s", err) } - admissionreq := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + admissionreq := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -231,7 +231,7 @@ func TestAdmissionInvalidResponseForResource(t *testing.T) { admissionreq.Resource.Group = "pkg.knative.dev" admissionreq.Object.Raw = marshaled - rev := &admissionv1beta1.AdmissionReview{ + rev := &admissionv1.AdmissionReview{ Request: admissionreq, } reqBuf := new(bytes.Buffer) @@ -269,7 +269,7 @@ func TestAdmissionInvalidResponseForResource(t *testing.T) { t.Fatalf("Failed to read response body %v", err) } - reviewResponse := admissionv1beta1.AdmissionReview{} + reviewResponse := admissionv1.AdmissionReview{} err = json.NewDecoder(bytes.NewReader(respBody)).Decode(&reviewResponse) if err != nil { diff --git a/webhook/configmaps/configmaps.go b/webhook/configmaps/configmaps.go index 62d213eb37..4d466aa8fa 100644 --- a/webhook/configmaps/configmaps.go +++ b/webhook/configmaps/configmaps.go @@ -24,12 +24,12 @@ import ( "fmt" "reflect" - admissionv1beta1 "k8s.io/api/admission/v1beta1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + admissionv1 "k8s.io/api/admission/v1" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" - admissionlisters "k8s.io/client-go/listers/admissionregistration/v1beta1" + admissionlisters "k8s.io/client-go/listers/admissionregistration/v1" corelisters "k8s.io/client-go/listers/core/v1" "knative.dev/pkg/configmap" @@ -85,20 +85,20 @@ func (ac *reconciler) Path() string { } // Admit implements AdmissionController -func (ac *reconciler) Admit(ctx context.Context, request *admissionv1beta1.AdmissionRequest) *admissionv1beta1.AdmissionResponse { +func (ac *reconciler) Admit(ctx context.Context, request *admissionv1.AdmissionRequest) *admissionv1.AdmissionResponse { logger := logging.FromContext(ctx) switch request.Operation { - case admissionv1beta1.Create, admissionv1beta1.Update: + case admissionv1.Create, admissionv1.Update: default: logger.Infof("Unhandled webhook operation, letting it through %v", request.Operation) - return &admissionv1beta1.AdmissionResponse{Allowed: true} + return &admissionv1.AdmissionResponse{Allowed: true} } if err := ac.validate(ctx, request); err != nil { return webhook.MakeErrorStatus("validation failed: %v", err) } - return &admissionv1beta1.AdmissionResponse{ + return &admissionv1.AdmissionResponse{ Allowed: true, } } @@ -106,13 +106,13 @@ func (ac *reconciler) Admit(ctx context.Context, request *admissionv1beta1.Admis func (ac *reconciler) reconcileValidatingWebhook(ctx context.Context, caCert []byte) error { logger := logging.FromContext(ctx) - ruleScope := admissionregistrationv1beta1.NamespacedScope - rules := []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{ - admissionregistrationv1beta1.Create, - admissionregistrationv1beta1.Update, + ruleScope := admissionregistrationv1.NamespacedScope + rules := []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{ + admissionregistrationv1.Create, + admissionregistrationv1.Update, }, - Rule: admissionregistrationv1beta1.Rule{ + Rule: admissionregistrationv1.Rule{ APIGroups: []string{""}, APIVersions: []string{"v1"}, Resources: []string{"configmaps/*"}, @@ -147,7 +147,7 @@ func (ac *reconciler) reconcileValidatingWebhook(ctx context.Context, caCert []b return fmt.Errorf("error diffing webhooks: %w", err) } else if !ok { logger.Info("Updating webhook") - vwhclient := ac.client.AdmissionregistrationV1beta1().ValidatingWebhookConfigurations() + vwhclient := ac.client.AdmissionregistrationV1().ValidatingWebhookConfigurations() if _, err := vwhclient.Update(webhook); err != nil { return fmt.Errorf("failed to update webhook: %w", err) } @@ -158,7 +158,7 @@ func (ac *reconciler) reconcileValidatingWebhook(ctx context.Context, caCert []b return nil } -func (ac *reconciler) validate(ctx context.Context, req *admissionv1beta1.AdmissionRequest) error { +func (ac *reconciler) validate(ctx context.Context, req *admissionv1.AdmissionRequest) error { logger := logging.FromContext(ctx) kind := req.Kind newBytes := req.Object.Raw diff --git a/webhook/configmaps/configmaps_test.go b/webhook/configmaps/configmaps_test.go index 26f9223195..f595116e18 100644 --- a/webhook/configmaps/configmaps_test.go +++ b/webhook/configmaps/configmaps_test.go @@ -25,11 +25,11 @@ import ( // Injection stuff _ "knative.dev/pkg/client/injection/kube/client/fake" - _ "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1beta1/validatingwebhookconfiguration/fake" + _ "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1/validatingwebhookconfiguration/fake" _ "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret/fake" - admissionv1beta1 "k8s.io/api/admission/v1beta1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + admissionv1 "k8s.io/api/admission/v1" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" authenticationv1 "k8s.io/api/authentication/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -55,14 +55,14 @@ var ( validations = configmap.Constructors{ testConfigName: newConfigFromConfigMap, } - initialConfigWebhook = &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + initialConfigWebhook = &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: testConfigValidationName, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: testConfigValidationName, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", }, @@ -100,8 +100,8 @@ func newTestConfigValidationController(t *testing.T) *reconciler { func TestDeleteAllowedForConfigMap(t *testing.T) { _, ac := newNonRunningTestConfigValidationController(t) - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Delete, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Delete, } if resp := ac.Admit(TestContextWithLogger(t), req); !resp.Allowed { @@ -112,8 +112,8 @@ func TestDeleteAllowedForConfigMap(t *testing.T) { func TestConnectAllowedForConfigMap(t *testing.T) { _, ac := newNonRunningTestConfigValidationController(t) - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Connect, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Connect, } resp := ac.Admit(TestContextWithLogger(t), req) @@ -125,8 +125,8 @@ func TestConnectAllowedForConfigMap(t *testing.T) { func TestNonConfigMapKindFails(t *testing.T) { _, ac := newNonRunningTestConfigValidationController(t) - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -313,21 +313,21 @@ func createConfigMap(value string) *corev1.ConfigMap { } } -func createCreateConfigMapRequest(ctx context.Context, t *testing.T, r *corev1.ConfigMap) *admissionv1beta1.AdmissionRequest { - return configMapRequest(t, r, admissionv1beta1.Create) +func createCreateConfigMapRequest(ctx context.Context, t *testing.T, r *corev1.ConfigMap) *admissionv1.AdmissionRequest { + return configMapRequest(t, r, admissionv1.Create) } -func updateCreateConfigMapRequest(ctx context.Context, t *testing.T, r *corev1.ConfigMap) *admissionv1beta1.AdmissionRequest { - return configMapRequest(t, r, admissionv1beta1.Update) +func updateCreateConfigMapRequest(ctx context.Context, t *testing.T, r *corev1.ConfigMap) *admissionv1.AdmissionRequest { + return configMapRequest(t, r, admissionv1.Update) } func configMapRequest( t *testing.T, r *corev1.ConfigMap, - o admissionv1beta1.Operation, -) *admissionv1beta1.AdmissionRequest { + o admissionv1.Operation, +) *admissionv1.AdmissionRequest { t.Helper() - req := &admissionv1beta1.AdmissionRequest{ + req := &admissionv1.AdmissionRequest{ Operation: o, Kind: metav1.GroupVersionKind{ Group: "", diff --git a/webhook/configmaps/controller.go b/webhook/configmaps/controller.go index 1e62f58ecb..bf1b7b0392 100644 --- a/webhook/configmaps/controller.go +++ b/webhook/configmaps/controller.go @@ -22,7 +22,7 @@ import ( // Injection stuff kubeclient "knative.dev/pkg/client/injection/kube/client" - vwhinformer "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1beta1/validatingwebhookconfiguration" + vwhinformer "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1/validatingwebhookconfiguration" secretinformer "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret" "k8s.io/client-go/tools/cache" diff --git a/webhook/configmaps/table_test.go b/webhook/configmaps/table_test.go index aad9a250df..c5953c6d3c 100644 --- a/webhook/configmaps/table_test.go +++ b/webhook/configmaps/table_test.go @@ -24,7 +24,7 @@ import ( kubeclient "knative.dev/pkg/client/injection/kube/client/fake" _ "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret/fake" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -56,12 +56,12 @@ func TestReconcile(t *testing.T) { }, } - ruleScope := admissionregistrationv1beta1.NamespacedScope + ruleScope := admissionregistrationv1.NamespacedScope // These are the rules we expect given the context of "validations". - expectedRules := []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + expectedRules := []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{""}, APIVersions: []string{"v1"}, Resources: []string{"configmaps/*"}, @@ -101,11 +101,11 @@ func TestReconcile(t *testing.T) { Name: "secret and VWH exist, missing service reference", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, }}, }, @@ -115,14 +115,14 @@ func TestReconcile(t *testing.T) { Name: "secret and VWH exist, missing other stuff", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", }, @@ -131,14 +131,14 @@ func TestReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + Object: &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is added. @@ -156,14 +156,14 @@ func TestReconcile(t *testing.T) { Name: "secret and VWH exist, added fields are incorrect", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Incorrect @@ -173,9 +173,9 @@ func TestReconcile(t *testing.T) { CABundle: []byte("incorrect"), }, // Incorrect - Rules: []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Rules: []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.dev"}, APIVersions: []string{"v1alpha1"}, Resources: []string{"innerdefaultresources/*"}, @@ -185,14 +185,14 @@ func TestReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + Object: &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fixed. @@ -214,14 +214,14 @@ func TestReconcile(t *testing.T) { InduceFailure("update", "validatingwebhookconfigurations"), }, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Incorrect @@ -231,9 +231,9 @@ func TestReconcile(t *testing.T) { CABundle: []byte("incorrect"), }, // Incorrect - Rules: []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Rules: []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.dev"}, APIVersions: []string{"v1alpha1"}, Resources: []string{"innerdefaultresources/*"}, @@ -243,14 +243,14 @@ func TestReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + Object: &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fixed. @@ -268,14 +268,14 @@ func TestReconcile(t *testing.T) { Name: ":fire: everything is fine :fire:", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fine. diff --git a/webhook/conversion.go b/webhook/conversion.go index 59575c34f7..146ac259f9 100644 --- a/webhook/conversion.go +++ b/webhook/conversion.go @@ -23,7 +23,7 @@ import ( "net/http" "go.uber.org/zap" - apixv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + apixv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "knative.dev/pkg/logging" ) @@ -33,7 +33,7 @@ type ConversionController interface { Path() string // Convert is the callback which is invoked when an HTTPS request comes in on Path(). - Convert(context.Context, *apixv1beta1.ConversionRequest) *apixv1beta1.ConversionResponse + Convert(context.Context, *apixv1.ConversionRequest) *apixv1.ConversionResponse } func conversionHandler(rootLogger *zap.SugaredLogger, stats StatsReporter, c ConversionController) http.HandlerFunc { @@ -41,7 +41,7 @@ func conversionHandler(rootLogger *zap.SugaredLogger, stats StatsReporter, c Con logger := rootLogger logger.Infof("Webhook ServeHTTP request=%#v", r) - var review apixv1beta1.ConversionReview + var review apixv1.ConversionReview if err := json.NewDecoder(r.Body).Decode(&review); err != nil { http.Error(w, fmt.Sprintf("could not decode body: %v", err), http.StatusBadRequest) return @@ -53,7 +53,7 @@ func conversionHandler(rootLogger *zap.SugaredLogger, stats StatsReporter, c Con ) ctx := logging.WithLogger(r.Context(), logger) - response := apixv1beta1.ConversionReview{ + response := apixv1.ConversionReview{ Response: c.Convert(ctx, review.Request), } diff --git a/webhook/conversion_integration_test.go b/webhook/conversion_integration_test.go index be1c6e582a..67879caff3 100644 --- a/webhook/conversion_integration_test.go +++ b/webhook/conversion_integration_test.go @@ -26,7 +26,7 @@ import ( "testing" "golang.org/x/sync/errgroup" - apixv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + apixv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" @@ -34,7 +34,7 @@ import ( type fixedConversionController struct { path string - response *apixv1beta1.ConversionResponse + response *apixv1.ConversionResponse } var _ ConversionController = (*fixedConversionController)(nil) @@ -43,14 +43,14 @@ func (fcc *fixedConversionController) Path() string { return fcc.path } -func (fcc *fixedConversionController) Convert(context.Context, *apixv1beta1.ConversionRequest) *apixv1beta1.ConversionResponse { +func (fcc *fixedConversionController) Convert(context.Context, *apixv1.ConversionRequest) *apixv1.ConversionResponse { return fcc.response } func TestConversionEmptyRequestBody(t *testing.T) { c := &fixedConversionController{ path: "/bazinga", - response: &apixv1beta1.ConversionResponse{}, + response: &apixv1.ConversionResponse{}, } testEmptyRequestBody(t, c) @@ -59,7 +59,7 @@ func TestConversionEmptyRequestBody(t *testing.T) { func TestConversionValidResponse(t *testing.T) { cc := &fixedConversionController{ path: "/bazinga", - response: &apixv1beta1.ConversionResponse{ + response: &apixv1.ConversionResponse{ UID: types.UID("some-uid"), }, } @@ -86,12 +86,12 @@ func TestConversionValidResponse(t *testing.T) { t.Fatalf("createSecureTLSClient() = %v", err) } - review := apixv1beta1.ConversionReview{ + review := apixv1.ConversionReview{ TypeMeta: metav1.TypeMeta{ - APIVersion: "apiextensions.k8s.io/v1beta1", + APIVersion: "apiextensions.k8s.io/v1", Kind: "ConversionReview", }, - Request: &apixv1beta1.ConversionRequest{ + Request: &apixv1.ConversionRequest{ UID: types.UID("some-uid"), DesiredAPIVersion: "example.com/v1", Objects: []runtime.RawExtension{}, @@ -126,7 +126,7 @@ func TestConversionValidResponse(t *testing.T) { t.Fatalf("Failed to read response body %v", err) } - reviewResponse := apixv1beta1.ConversionReview{} + reviewResponse := apixv1.ConversionReview{} err = json.NewDecoder(bytes.NewReader(responseBody)).Decode(&reviewResponse) if err != nil { @@ -141,7 +141,7 @@ func TestConversionValidResponse(t *testing.T) { func TestConversionInvalidResponse(t *testing.T) { cc := &fixedConversionController{ path: "/bazinga", - response: &apixv1beta1.ConversionResponse{ + response: &apixv1.ConversionResponse{ UID: types.UID("some-uid"), Result: metav1.Status{ Status: metav1.StatusFailure, @@ -171,12 +171,12 @@ func TestConversionInvalidResponse(t *testing.T) { t.Fatalf("createSecureTLSClient() = %v", err) } - review := apixv1beta1.ConversionReview{ + review := apixv1.ConversionReview{ TypeMeta: metav1.TypeMeta{ - APIVersion: "apiextensions.k8s.io/v1beta1", + APIVersion: "apiextensions.k8s.io/v1", Kind: "ConversionReview", }, - Request: &apixv1beta1.ConversionRequest{ + Request: &apixv1.ConversionRequest{ UID: types.UID("some-uid"), DesiredAPIVersion: "example.com/v1", Objects: []runtime.RawExtension{}, @@ -211,7 +211,7 @@ func TestConversionInvalidResponse(t *testing.T) { t.Fatalf("Failed to read response body %v", err) } - reviewResponse := apixv1beta1.ConversionReview{} + reviewResponse := apixv1.ConversionReview{} err = json.NewDecoder(bytes.NewReader(responseBody)).Decode(&reviewResponse) if err != nil { diff --git a/webhook/psbinding/controller.go b/webhook/psbinding/controller.go index 76238d28b5..567ddaefc3 100644 --- a/webhook/psbinding/controller.go +++ b/webhook/psbinding/controller.go @@ -21,7 +21,7 @@ import ( // Injection stuff kubeclient "knative.dev/pkg/client/injection/kube/client" - mwhinformer "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1beta1/mutatingwebhookconfiguration" + mwhinformer "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1/mutatingwebhookconfiguration" secretinformer "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret" "k8s.io/apimachinery/pkg/types" diff --git a/webhook/psbinding/psbinding.go b/webhook/psbinding/psbinding.go index ce0fb7f963..3b28ea84e4 100644 --- a/webhook/psbinding/psbinding.go +++ b/webhook/psbinding/psbinding.go @@ -26,15 +26,15 @@ import ( "sync" "github.com/markbates/inflect" - admissionv1beta1 "k8s.io/api/admission/v1beta1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + admissionv1 "k8s.io/api/admission/v1" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/client-go/kubernetes" - admissionlisters "k8s.io/client-go/listers/admissionregistration/v1beta1" + admissionlisters "k8s.io/client-go/listers/admissionregistration/v1" corelisters "k8s.io/client-go/listers/core/v1" "knative.dev/pkg/apis/duck" duckv1 "knative.dev/pkg/apis/duck/v1" @@ -168,12 +168,12 @@ func (ac *Reconciler) Path() string { } // Admit implements AdmissionController -func (ac *Reconciler) Admit(ctx context.Context, request *admissionv1beta1.AdmissionRequest) *admissionv1beta1.AdmissionResponse { +func (ac *Reconciler) Admit(ctx context.Context, request *admissionv1.AdmissionRequest) *admissionv1.AdmissionResponse { switch request.Operation { - case admissionv1beta1.Create, admissionv1beta1.Update: + case admissionv1.Create, admissionv1.Update: default: logging.FromContext(ctx).Infof("Unhandled webhook operation, letting it through %v", request.Operation) - return &admissionv1beta1.AdmissionResponse{Allowed: true} + return &admissionv1.AdmissionResponse{Allowed: true} } orig := &duckv1.WithPod{} @@ -209,7 +209,7 @@ func (ac *Reconciler) Admit(ctx context.Context, request *admissionv1beta1.Admis }() if fb == nil { // This doesn't apply! - return &admissionv1beta1.AdmissionResponse{Allowed: true} + return &admissionv1.AdmissionResponse{Allowed: true} } // Callback into the user's code to setup the context with additional @@ -235,11 +235,11 @@ func (ac *Reconciler) Admit(ctx context.Context, request *admissionv1beta1.Admis if err != nil { return webhook.MakeErrorStatus("unable to create patch with binding: %v", err) } - return &admissionv1beta1.AdmissionResponse{ + return &admissionv1.AdmissionResponse{ Patch: patchBytes, Allowed: true, - PatchType: func() *admissionv1beta1.PatchType { - pt := admissionv1beta1.PatchTypeJSONPatch + PatchType: func() *admissionv1.PatchType { + pt := admissionv1.PatchTypeJSONPatch return &pt }(), } @@ -302,16 +302,16 @@ func (ac *Reconciler) reconcileMutatingWebhook(ctx context.Context, caCert []byt ac.inexact = inexact }() - rules := make([]admissionregistrationv1beta1.RuleWithOperations, 0, len(gks)) + rules := make([]admissionregistrationv1.RuleWithOperations, 0, len(gks)) for gk, versions := range gks { plural := strings.ToLower(inflect.Pluralize(gk.Kind)) - rules = append(rules, admissionregistrationv1beta1.RuleWithOperations{ - Operations: []admissionregistrationv1beta1.OperationType{ - admissionregistrationv1beta1.Create, - admissionregistrationv1beta1.Update, + rules = append(rules, admissionregistrationv1.RuleWithOperations{ + Operations: []admissionregistrationv1.OperationType{ + admissionregistrationv1.Create, + admissionregistrationv1.Update, }, - Rule: admissionregistrationv1beta1.Rule{ + Rule: admissionregistrationv1.Rule{ APIGroups: []string{gk.Group}, APIVersions: versions.List(), Resources: []string{plural + "/*"}, @@ -339,7 +339,7 @@ func (ac *Reconciler) reconcileMutatingWebhook(ctx context.Context, caCert []byt // Use the "Equivalent" match policy so that we don't need to enumerate versions for same-types. // This is only supported by 1.15+ clusters. - matchPolicy := admissionregistrationv1beta1.Equivalent + matchPolicy := admissionregistrationv1.Equivalent for i, wh := range webhook.Webhooks { if wh.Name != webhook.Name { @@ -358,7 +358,7 @@ func (ac *Reconciler) reconcileMutatingWebhook(ctx context.Context, caCert []byt if ok := equality.Semantic.DeepEqual(configuredWebhook, webhook); !ok { logging.FromContext(ctx).Info("Updating webhook") - mwhclient := ac.Client.AdmissionregistrationV1beta1().MutatingWebhookConfigurations() + mwhclient := ac.Client.AdmissionregistrationV1().MutatingWebhookConfigurations() if _, err := mwhclient.Update(webhook); err != nil { return fmt.Errorf("failed to update webhook: %w", err) } diff --git a/webhook/psbinding/table_test.go b/webhook/psbinding/table_test.go index 7926071a7b..9ee1bb392d 100644 --- a/webhook/psbinding/table_test.go +++ b/webhook/psbinding/table_test.go @@ -29,15 +29,15 @@ import ( "knative.dev/pkg/apis" "knative.dev/pkg/client/injection/ducks/duck/v1/podspecable" kubeclient "knative.dev/pkg/client/injection/kube/client/fake" - mwhinformer "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1beta1/mutatingwebhookconfiguration" - _ "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1beta1/mutatingwebhookconfiguration/fake" + mwhinformer "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1/mutatingwebhookconfiguration" + _ "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1/mutatingwebhookconfiguration/fake" dynamicclient "knative.dev/pkg/injection/clients/dynamicclient/fake" secretinformer "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret" _ "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret/fake" "knative.dev/pkg/tracker" - admissionv1beta1 "k8s.io/api/admission/v1beta1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + admissionv1 "k8s.io/api/admission/v1" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apierrs "k8s.io/apimachinery/pkg/api/errors" @@ -91,8 +91,8 @@ func checkDeploymentIsPatched(t *testing.T, r *TableRow) { t.Fatalf("Unable to serialize deployment: %v", err) } - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "apps", Version: "v1", @@ -146,8 +146,8 @@ func checkDeploymentIsPatchedBack(t *testing.T, r *TableRow) { t.Fatalf("Unable to serialize deployment: %v", err) } - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "apps", Version: "v1", @@ -193,8 +193,8 @@ func checkDeploymentIsNotPatched(t *testing.T, r *TableRow) { t.Fatalf("Unable to serialize deployment: %v", err) } - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "apps", Version: "v1", @@ -239,8 +239,8 @@ func checkDeleteIgnored(t *testing.T, r *TableRow) { t.Fatalf("Unable to serialize deployment: %v", err) } - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Delete, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Delete, Kind: metav1.GroupVersionKind{ Group: "apps", Version: "v1", @@ -274,7 +274,7 @@ func TestWebhookReconcile(t *testing.T) { }, } - equivalent := admissionregistrationv1beta1.Equivalent + equivalent := admissionregistrationv1.Equivalent // The key to use, which for this singleton reconciler doesn't matter (although the // namespace matters for namespace validation). @@ -308,11 +308,11 @@ func TestWebhookReconcile(t *testing.T) { Name: "secret and MWH exist, missing service reference", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, }}, }, @@ -322,14 +322,14 @@ func TestWebhookReconcile(t *testing.T) { Name: "secret and MWH exist, missing other stuff", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", }, @@ -338,14 +338,14 @@ func TestWebhookReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + Object: &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is added. @@ -368,14 +368,14 @@ func TestWebhookReconcile(t *testing.T) { Name: "secret and MWH exist, added fields are incorrect", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Incorrect @@ -385,9 +385,9 @@ func TestWebhookReconcile(t *testing.T) { CABundle: []byte("incorrect"), }, // Incorrect (really just incomplete) - Rules: []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Rules: []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.dev"}, APIVersions: []string{"v1alpha1"}, Resources: []string{"innerdefaultresources/*"}, @@ -397,14 +397,14 @@ func TestWebhookReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + Object: &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fixed. @@ -431,14 +431,14 @@ func TestWebhookReconcile(t *testing.T) { InduceFailure("update", "mutatingwebhookconfigurations"), }, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Incorrect @@ -448,9 +448,9 @@ func TestWebhookReconcile(t *testing.T) { CABundle: []byte("incorrect"), }, // Incorrect (really just incomplete) - Rules: []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Rules: []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.dev"}, APIVersions: []string{"v1alpha1"}, Resources: []string{"innerdefaultresources/*"}, @@ -460,14 +460,14 @@ func TestWebhookReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + Object: &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fixed. @@ -490,14 +490,14 @@ func TestWebhookReconcile(t *testing.T) { Name: ":fire: everything is fine :fire:", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fine. @@ -536,14 +536,14 @@ func TestWebhookReconcile(t *testing.T) { }, }, }, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fine. @@ -563,14 +563,14 @@ func TestWebhookReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + Object: &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", Path: ptr.String(path), @@ -578,9 +578,9 @@ func TestWebhookReconcile(t *testing.T) { CABundle: []byte("present"), }, // A new rule is added to intercept the new type. - Rules: []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Rules: []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"random.knative.dev"}, APIVersions: []string{"v2beta3"}, Resources: []string{"knoodles/*"}, @@ -630,14 +630,14 @@ func TestWebhookReconcile(t *testing.T) { Foo: "the-value", }, }, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", Path: ptr.String(path), @@ -645,16 +645,16 @@ func TestWebhookReconcile(t *testing.T) { CABundle: []byte("present"), }, // A new rule is added to intercept the new type. - Rules: []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Rules: []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"apps"}, APIVersions: []string{"v1"}, Resources: []string{"deployments/*"}, }, }, { - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"random.knative.dev"}, APIVersions: []string{"v2beta3"}, Resources: []string{"knoodles/*"}, @@ -718,14 +718,14 @@ func TestWebhookReconcile(t *testing.T) { Foo: "the-value", }, }, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", Path: ptr.String(path), @@ -733,16 +733,16 @@ func TestWebhookReconcile(t *testing.T) { CABundle: []byte("present"), }, // A new rule is added to intercept the new type. - Rules: []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Rules: []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"apps"}, APIVersions: []string{"v1"}, Resources: []string{"deployments/*"}, }, }, { - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"random.knative.dev"}, APIVersions: []string{"v2beta3"}, Resources: []string{"knoodles/*"}, @@ -787,23 +787,23 @@ func TestWebhookReconcile(t *testing.T) { Foo: "the-value", }, }, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", Path: ptr.String(path), }, CABundle: []byte("present"), }, - Rules: []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Rules: []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"apps"}, APIVersions: []string{"v1"}, Resources: []string{"deployments/*"}, @@ -858,14 +858,14 @@ func TestWebhookReconcile(t *testing.T) { }, }, }, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fine. @@ -885,14 +885,14 @@ func TestWebhookReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + Object: &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", Path: ptr.String(path), @@ -900,16 +900,16 @@ func TestWebhookReconcile(t *testing.T) { CABundle: []byte("present"), }, // New rules are added to intercept the new types. - Rules: []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Rules: []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pseudorandom.knative.dev"}, APIVersions: []string{"v3beta1"}, Resources: []string{"knoogles/*"}, }, }, { - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"random.knative.dev"}, APIVersions: []string{"v2beta3"}, Resources: []string{"knoodles/*"}, @@ -945,14 +945,14 @@ func TestWebhookReconcile(t *testing.T) { }, }, }, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fine. @@ -972,14 +972,14 @@ func TestWebhookReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + Object: &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", Path: ptr.String(path), @@ -987,9 +987,9 @@ func TestWebhookReconcile(t *testing.T) { CABundle: []byte("present"), }, // A new rule is added to intercept the new type. - Rules: []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Rules: []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"random.knative.dev"}, APIVersions: []string{"v2beta3"}, Resources: []string{"knoodles/*"}, diff --git a/webhook/resourcesemantics/conversion/controller.go b/webhook/resourcesemantics/conversion/controller.go index 1d107aacf7..cd8f6884dc 100644 --- a/webhook/resourcesemantics/conversion/controller.go +++ b/webhook/resourcesemantics/conversion/controller.go @@ -25,7 +25,7 @@ import ( "k8s.io/client-go/tools/cache" "knative.dev/pkg/apis" apixclient "knative.dev/pkg/client/injection/apiextensions/client" - crdinformer "knative.dev/pkg/client/injection/apiextensions/informers/apiextensions/v1beta1/customresourcedefinition" + crdinformer "knative.dev/pkg/client/injection/apiextensions/informers/apiextensions/v1/customresourcedefinition" "knative.dev/pkg/controller" secretinformer "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret" "knative.dev/pkg/logging" diff --git a/webhook/resourcesemantics/conversion/conversion.go b/webhook/resourcesemantics/conversion/conversion.go index 3fab95bad0..5fa7beb9f1 100644 --- a/webhook/resourcesemantics/conversion/conversion.go +++ b/webhook/resourcesemantics/conversion/conversion.go @@ -23,7 +23,7 @@ import ( "go.uber.org/zap" - apixv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + apixv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -37,14 +37,14 @@ import ( // Convert implements webhook.ConversionController func (r *reconciler) Convert( ctx context.Context, - req *apixv1beta1.ConversionRequest, -) *apixv1beta1.ConversionResponse { + req *apixv1.ConversionRequest, +) *apixv1.ConversionResponse { if r.withContext != nil { ctx = r.withContext(ctx) } - res := &apixv1beta1.ConversionResponse{ + res := &apixv1.ConversionResponse{ UID: req.UID, Result: metav1.Status{ Status: metav1.StatusSuccess, diff --git a/webhook/resourcesemantics/conversion/conversion_test.go b/webhook/resourcesemantics/conversion/conversion_test.go index 050bc9f7ec..9b01cf2ba6 100644 --- a/webhook/resourcesemantics/conversion/conversion_test.go +++ b/webhook/resourcesemantics/conversion/conversion_test.go @@ -24,12 +24,12 @@ import ( "testing" // injection - _ "knative.dev/pkg/client/injection/apiextensions/informers/apiextensions/v1beta1/customresourcedefinition/fake" + _ "knative.dev/pkg/client/injection/apiextensions/informers/apiextensions/v1/customresourcedefinition/fake" _ "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret/fake" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - apixv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + apixv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" @@ -96,7 +96,7 @@ func TestWebhookPath(t *testing.T) { func TestConversionToHub(t *testing.T) { ctx, conversion := newConversion(t) - req := &apixv1beta1.ConversionRequest{ + req := &apixv1.ConversionRequest{ UID: "some-uid", DesiredAPIVersion: testAPIVersion("v1"), Objects: []runtime.RawExtension{ @@ -105,7 +105,7 @@ func TestConversionToHub(t *testing.T) { }, } - want := &apixv1beta1.ConversionResponse{ + want := &apixv1.ConversionResponse{ UID: "some-uid", Result: metav1.Status{Status: metav1.StatusSuccess}, ConvertedObjects: []runtime.RawExtension{ @@ -138,7 +138,7 @@ func TestConversionFromHub(t *testing.T) { for _, test := range tests { t.Run(test.version, func(t *testing.T) { ctx, conversion := newConversion(t) - req := &apixv1beta1.ConversionRequest{ + req := &apixv1.ConversionRequest{ UID: "some-uid", DesiredAPIVersion: testAPIVersion(test.version), Objects: []runtime.RawExtension{ @@ -146,7 +146,7 @@ func TestConversionFromHub(t *testing.T) { }, } - want := &apixv1beta1.ConversionResponse{ + want := &apixv1.ConversionResponse{ UID: "some-uid", Result: metav1.Status{Status: metav1.StatusSuccess}, ConvertedObjects: []runtime.RawExtension{ @@ -184,7 +184,7 @@ func TestConversionThroughHub(t *testing.T) { t.Run(test.version, func(t *testing.T) { ctx, conversion := newConversion(t) - req := &apixv1beta1.ConversionRequest{ + req := &apixv1.ConversionRequest{ UID: "some-uid", DesiredAPIVersion: testAPIVersion(test.version), Objects: []runtime.RawExtension{ @@ -192,7 +192,7 @@ func TestConversionThroughHub(t *testing.T) { }, } - want := &apixv1beta1.ConversionResponse{ + want := &apixv1.ConversionResponse{ UID: "some-uid", Result: metav1.Status{Status: metav1.StatusSuccess}, ConvertedObjects: []runtime.RawExtension{ @@ -239,7 +239,7 @@ func TestConversionErrorBadGVK(t *testing.T) { ctx, conversion := newConversion(t) - req := &apixv1beta1.ConversionRequest{ + req := &apixv1.ConversionRequest{ UID: "some-uid", DesiredAPIVersion: testAPIVersion("v1"), Objects: []runtime.RawExtension{ @@ -247,7 +247,7 @@ func TestConversionErrorBadGVK(t *testing.T) { }, } - want := &apixv1beta1.ConversionResponse{ + want := &apixv1.ConversionResponse{ UID: "some-uid", Result: metav1.Status{ Status: metav1.StatusFailure, @@ -281,7 +281,7 @@ func TestConversionUnknownInputGVK(t *testing.T) { ctx, conversion := newConversion(t) - req := &apixv1beta1.ConversionRequest{ + req := &apixv1.ConversionRequest{ UID: "some-uid", DesiredAPIVersion: testAPIVersion("v3"), Objects: []runtime.RawExtension{ @@ -289,7 +289,7 @@ func TestConversionUnknownInputGVK(t *testing.T) { }, } - want := &apixv1beta1.ConversionResponse{ + want := &apixv1.ConversionResponse{ UID: "some-uid", Result: metav1.Status{ Message: "no conversion support for type [kind=Resource group=some.api.group.dev]", @@ -306,7 +306,7 @@ func TestConversionUnknownInputGVK(t *testing.T) { func TestConversionInvalidTypeMeta(t *testing.T) { ctx, conversion := newConversionWithKinds(t, nil) - req := &apixv1beta1.ConversionRequest{ + req := &apixv1.ConversionRequest{ UID: "some-uid", DesiredAPIVersion: "some-version", Objects: []runtime.RawExtension{ @@ -314,7 +314,7 @@ func TestConversionInvalidTypeMeta(t *testing.T) { }, } - want := &apixv1beta1.ConversionResponse{ + want := &apixv1.ConversionResponse{ UID: "some-uid", Result: metav1.Status{ Status: metav1.StatusFailure, @@ -339,7 +339,7 @@ func TestConversionInvalidTypeMeta(t *testing.T) { func TestConversionFailureToUnmarshalInput(t *testing.T) { ctx, conversion := newConversion(t) - req := &apixv1beta1.ConversionRequest{ + req := &apixv1.ConversionRequest{ UID: "some-uid", DesiredAPIVersion: testAPIVersion("v1"), Objects: []runtime.RawExtension{ @@ -347,7 +347,7 @@ func TestConversionFailureToUnmarshalInput(t *testing.T) { }, } - want := &apixv1beta1.ConversionResponse{ + want := &apixv1.ConversionResponse{ UID: "some-uid", Result: metav1.Status{ Status: metav1.StatusFailure, @@ -372,7 +372,7 @@ func TestConversionFailureToUnmarshalInput(t *testing.T) { func TestConversionFailureToMarshalOutput(t *testing.T) { ctx, conversion := newConversion(t) - req := &apixv1beta1.ConversionRequest{ + req := &apixv1.ConversionRequest{ UID: "some-uid", DesiredAPIVersion: testAPIVersion("error"), Objects: []runtime.RawExtension{ @@ -382,7 +382,7 @@ func TestConversionFailureToMarshalOutput(t *testing.T) { }, } - want := &apixv1beta1.ConversionResponse{ + want := &apixv1.ConversionResponse{ UID: "some-uid", Result: metav1.Status{ Status: metav1.StatusFailure, @@ -428,7 +428,7 @@ func TestConversionFailureToConvert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { ctx, conversion := newConversionWithKinds(t, kinds) - req := &apixv1beta1.ConversionRequest{ + req := &apixv1.ConversionRequest{ UID: "some-uid", DesiredAPIVersion: testAPIVersion("v3"), Objects: []runtime.RawExtension{ @@ -437,7 +437,7 @@ func TestConversionFailureToConvert(t *testing.T) { }, } - want := &apixv1beta1.ConversionResponse{ + want := &apixv1.ConversionResponse{ UID: "some-uid", Result: metav1.Status{ Status: metav1.StatusFailure, @@ -484,7 +484,7 @@ func TestConversionFailureInvalidDesiredAPIVersion(t *testing.T) { t.Run(test.name, func(t *testing.T) { ctx, conversion := newConversion(t) - req := &apixv1beta1.ConversionRequest{ + req := &apixv1.ConversionRequest{ UID: "some-uid", DesiredAPIVersion: test.version, Objects: []runtime.RawExtension{ @@ -492,7 +492,7 @@ func TestConversionFailureInvalidDesiredAPIVersion(t *testing.T) { }, } - want := &apixv1beta1.ConversionResponse{ + want := &apixv1.ConversionResponse{ UID: "some-uid", Result: metav1.Status{ Message: fmt.Sprintf("desired API version %q is not valid", test.version), @@ -546,7 +546,7 @@ func TestConversionMissingZygotes(t *testing.T) { ctx, conversion := newConversionWithKinds(t, kinds) - req := &apixv1beta1.ConversionRequest{ + req := &apixv1.ConversionRequest{ UID: "some-uid", DesiredAPIVersion: testAPIVersion("v3"), Objects: []runtime.RawExtension{ @@ -554,7 +554,7 @@ func TestConversionMissingZygotes(t *testing.T) { }, } - want := &apixv1beta1.ConversionResponse{ + want := &apixv1.ConversionResponse{ UID: "some-uid", Result: metav1.Status{ Status: metav1.StatusFailure, @@ -592,7 +592,7 @@ func TestContextDecoration(t *testing.T) { controller := NewConversionController(ctx, webhookPath, kinds, decorator) r := controller.Reconciler.(*reconciler) - r.Convert(ctx, &apixv1beta1.ConversionRequest{}) + r.Convert(ctx, &apixv1.ConversionRequest{}) if !decoratorCalled { t.Errorf("context decorator was not invoked") diff --git a/webhook/resourcesemantics/conversion/reconciler.go b/webhook/resourcesemantics/conversion/reconciler.go index ab8944620b..0d5d29bde2 100644 --- a/webhook/resourcesemantics/conversion/reconciler.go +++ b/webhook/resourcesemantics/conversion/reconciler.go @@ -20,9 +20,9 @@ import ( "context" "fmt" - apixv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + apixv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apixclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - apixlisters "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1" + apixlisters "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1" "k8s.io/apimachinery/pkg/runtime/schema" corelisters "k8s.io/client-go/listers/core/v1" "knative.dev/pkg/controller" @@ -83,20 +83,20 @@ func (r *reconciler) reconcileCRD(ctx context.Context, cacert []byte, key string crd := configuredCRD.DeepCopy() if crd.Spec.Conversion == nil || - crd.Spec.Conversion.Strategy != apixv1beta1.WebhookConverter || - crd.Spec.Conversion.WebhookClientConfig == nil || - crd.Spec.Conversion.WebhookClientConfig.Service == nil { + crd.Spec.Conversion.Strategy != apixv1.WebhookConverter || + crd.Spec.Conversion.Webhook.ClientConfig == nil || + crd.Spec.Conversion.Webhook.ClientConfig.Service == nil { return fmt.Errorf("custom resource %q isn't configured for webhook conversion", key) } - crd.Spec.Conversion.WebhookClientConfig.CABundle = cacert - crd.Spec.Conversion.WebhookClientConfig.Service.Path = ptr.String(r.path) + crd.Spec.Conversion.Webhook.ClientConfig.CABundle = cacert + crd.Spec.Conversion.Webhook.ClientConfig.Service.Path = ptr.String(r.path) if ok, err := kmp.SafeEqual(configuredCRD, crd); err != nil { return fmt.Errorf("error diffing custom resource definitions: %w", err) } else if !ok { logger.Infof("updating CRD") - crdClient := r.client.ApiextensionsV1beta1().CustomResourceDefinitions() + crdClient := r.client.ApiextensionsV1().CustomResourceDefinitions() if _, err := crdClient.Update(crd); err != nil { return fmt.Errorf("failed to update webhook: %w", err) } diff --git a/webhook/resourcesemantics/conversion/table_test.go b/webhook/resourcesemantics/conversion/table_test.go index 2daeb93edb..98e420a72f 100644 --- a/webhook/resourcesemantics/conversion/table_test.go +++ b/webhook/resourcesemantics/conversion/table_test.go @@ -21,7 +21,7 @@ import ( "testing" corev1 "k8s.io/api/core/v1" - apixv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + apixv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" clientgotesting "k8s.io/client-go/testing" @@ -82,12 +82,12 @@ func TestReconcile(t *testing.T) { Key: key, Objects: []runtime.Object{ secret, - &apixv1beta1.CustomResourceDefinition{ + &apixv1.CustomResourceDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: key, }, - Spec: apixv1beta1.CustomResourceDefinitionSpec{ - Conversion: &apixv1beta1.CustomResourceConversion{}, + Spec: apixv1.CustomResourceDefinitionSpec{ + Conversion: &apixv1.CustomResourceConversion{}, }, }, }, @@ -97,17 +97,19 @@ func TestReconcile(t *testing.T) { Key: key, Objects: []runtime.Object{ secret, - &apixv1beta1.CustomResourceDefinition{ + &apixv1.CustomResourceDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: key, }, - Spec: apixv1beta1.CustomResourceDefinitionSpec{ - Conversion: &apixv1beta1.CustomResourceConversion{ - Strategy: apixv1beta1.WebhookConverter, - WebhookClientConfig: &apixv1beta1.WebhookClientConfig{ - Service: &apixv1beta1.ServiceReference{ - Namespace: system.Namespace(), - Name: "webhook", + Spec: apixv1.CustomResourceDefinitionSpec{ + Conversion: &apixv1.CustomResourceConversion{ + Strategy: apixv1.WebhookConverter, + Webhook: &apixv1.WebhookConversion{ + ClientConfig: &apixv1.WebhookClientConfig{ + Service: &apixv1.ServiceReference{ + Namespace: system.Namespace(), + Name: "webhook", + }, }, }, }, @@ -115,22 +117,24 @@ func TestReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &apixv1beta1.CustomResourceDefinition{ + Object: &apixv1.CustomResourceDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: key, }, - Spec: apixv1beta1.CustomResourceDefinitionSpec{ - Conversion: &apixv1beta1.CustomResourceConversion{ - Strategy: apixv1beta1.WebhookConverter, - WebhookClientConfig: &apixv1beta1.WebhookClientConfig{ - Service: &apixv1beta1.ServiceReference{ - Namespace: system.Namespace(), - Name: "webhook", - // Path is added. - Path: ptr.String(path), + Spec: apixv1.CustomResourceDefinitionSpec{ + Conversion: &apixv1.CustomResourceConversion{ + Strategy: apixv1.WebhookConverter, + Webhook: &apixv1.WebhookConversion{ + ClientConfig: &apixv1.WebhookClientConfig{ + Service: &apixv1.ServiceReference{ + Namespace: system.Namespace(), + Name: "webhook", + // Path is added. + Path: ptr.String(path), + }, + // CABundle is added. + CABundle: []byte("present"), }, - // CABundle is added. - CABundle: []byte("present"), }, }, }, @@ -141,44 +145,48 @@ func TestReconcile(t *testing.T) { Key: key, Objects: []runtime.Object{ secret, - &apixv1beta1.CustomResourceDefinition{ + &apixv1.CustomResourceDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: key, }, - Spec: apixv1beta1.CustomResourceDefinitionSpec{ - Conversion: &apixv1beta1.CustomResourceConversion{ - Strategy: apixv1beta1.WebhookConverter, - WebhookClientConfig: &apixv1beta1.WebhookClientConfig{ - Service: &apixv1beta1.ServiceReference{ - Namespace: system.Namespace(), - Name: "webhook", - // Incorrect path - Path: ptr.String("/incorrect"), + Spec: apixv1.CustomResourceDefinitionSpec{ + Conversion: &apixv1.CustomResourceConversion{ + Strategy: apixv1.WebhookConverter, + Webhook: &apixv1.WebhookConversion{ + ClientConfig: &apixv1.WebhookClientConfig{ + Service: &apixv1.ServiceReference{ + Namespace: system.Namespace(), + Name: "webhook", + // Incorrect path + Path: ptr.String("/incorrect"), + }, + // CABundle is added. + CABundle: []byte("incorrect"), }, - // CABundle is added. - CABundle: []byte("incorrect"), }, }, }, }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &apixv1beta1.CustomResourceDefinition{ + Object: &apixv1.CustomResourceDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: key, }, - Spec: apixv1beta1.CustomResourceDefinitionSpec{ - Conversion: &apixv1beta1.CustomResourceConversion{ - Strategy: apixv1beta1.WebhookConverter, - WebhookClientConfig: &apixv1beta1.WebhookClientConfig{ - Service: &apixv1beta1.ServiceReference{ - Namespace: system.Namespace(), - Name: "webhook", - // Path is added. - Path: ptr.String(path), + Spec: apixv1.CustomResourceDefinitionSpec{ + Conversion: &apixv1.CustomResourceConversion{ + Strategy: apixv1.WebhookConverter, + Webhook: &apixv1.WebhookConversion{ + ClientConfig: &apixv1.WebhookClientConfig{ + Service: &apixv1.ServiceReference{ + Namespace: system.Namespace(), + Name: "webhook", + // Path is added. + Path: ptr.String(path), + }, + // CABundle is added. + CABundle: []byte("present"), }, - // CABundle is added. - CABundle: []byte("present"), }, }, }, @@ -193,44 +201,48 @@ func TestReconcile(t *testing.T) { }, Objects: []runtime.Object{ secret, - &apixv1beta1.CustomResourceDefinition{ + &apixv1.CustomResourceDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: key, }, - Spec: apixv1beta1.CustomResourceDefinitionSpec{ - Conversion: &apixv1beta1.CustomResourceConversion{ - Strategy: apixv1beta1.WebhookConverter, - WebhookClientConfig: &apixv1beta1.WebhookClientConfig{ - Service: &apixv1beta1.ServiceReference{ - Namespace: system.Namespace(), - Name: "webhook", - // Incorrect path - Path: ptr.String("/incorrect"), + Spec: apixv1.CustomResourceDefinitionSpec{ + Conversion: &apixv1.CustomResourceConversion{ + Strategy: apixv1.WebhookConverter, + Webhook: &apixv1.WebhookConversion{ + ClientConfig: &apixv1.WebhookClientConfig{ + Service: &apixv1.ServiceReference{ + Namespace: system.Namespace(), + Name: "webhook", + // Incorrect path + Path: ptr.String("/incorrect"), + }, + // CABundle is added. + CABundle: []byte("incorrect"), }, - // CABundle is added. - CABundle: []byte("incorrect"), }, }, }, }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &apixv1beta1.CustomResourceDefinition{ + Object: &apixv1.CustomResourceDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: key, }, - Spec: apixv1beta1.CustomResourceDefinitionSpec{ - Conversion: &apixv1beta1.CustomResourceConversion{ - Strategy: apixv1beta1.WebhookConverter, - WebhookClientConfig: &apixv1beta1.WebhookClientConfig{ - Service: &apixv1beta1.ServiceReference{ - Namespace: system.Namespace(), - Name: "webhook", - // Path is added. - Path: ptr.String(path), + Spec: apixv1.CustomResourceDefinitionSpec{ + Conversion: &apixv1.CustomResourceConversion{ + Strategy: apixv1.WebhookConverter, + Webhook: &apixv1.WebhookConversion{ + ClientConfig: &apixv1.WebhookClientConfig{ + Service: &apixv1.ServiceReference{ + Namespace: system.Namespace(), + Name: "webhook", + // Path is added. + Path: ptr.String(path), + }, + // CABundle is added. + CABundle: []byte("present"), }, - // CABundle is added. - CABundle: []byte("present"), }, }, }, @@ -241,21 +253,23 @@ func TestReconcile(t *testing.T) { Key: key, Objects: []runtime.Object{ secret, - &apixv1beta1.CustomResourceDefinition{ + &apixv1.CustomResourceDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: key, }, - Spec: apixv1beta1.CustomResourceDefinitionSpec{ - Conversion: &apixv1beta1.CustomResourceConversion{ - Strategy: apixv1beta1.WebhookConverter, - WebhookClientConfig: &apixv1beta1.WebhookClientConfig{ - Service: &apixv1beta1.ServiceReference{ - Namespace: system.Namespace(), - Name: "webhook", - Path: ptr.String(path), + Spec: apixv1.CustomResourceDefinitionSpec{ + Conversion: &apixv1.CustomResourceConversion{ + Strategy: apixv1.WebhookConverter, + Webhook: &apixv1.WebhookConversion{ + ClientConfig: &apixv1.WebhookClientConfig{ + Service: &apixv1.ServiceReference{ + Namespace: system.Namespace(), + Name: "webhook", + Path: ptr.String(path), + }, + // CABundle is added. + CABundle: []byte("present"), }, - // CABundle is added. - CABundle: []byte("present"), }, }, }, diff --git a/webhook/resourcesemantics/defaulting/controller.go b/webhook/resourcesemantics/defaulting/controller.go index 8d99732b52..3f7a4822ff 100644 --- a/webhook/resourcesemantics/defaulting/controller.go +++ b/webhook/resourcesemantics/defaulting/controller.go @@ -21,7 +21,7 @@ import ( // Injection stuff kubeclient "knative.dev/pkg/client/injection/kube/client" - mwhinformer "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1beta1/mutatingwebhookconfiguration" + mwhinformer "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1/mutatingwebhookconfiguration" secretinformer "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/webhook/resourcesemantics/defaulting/defaulting.go b/webhook/resourcesemantics/defaulting/defaulting.go index d84e6ed9c8..96081f40d4 100644 --- a/webhook/resourcesemantics/defaulting/defaulting.go +++ b/webhook/resourcesemantics/defaulting/defaulting.go @@ -28,12 +28,12 @@ import ( "github.com/markbates/inflect" "go.uber.org/zap" jsonpatch "gomodules.xyz/jsonpatch/v2" - admissionv1beta1 "k8s.io/api/admission/v1beta1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + admissionv1 "k8s.io/api/admission/v1" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" - admissionlisters "k8s.io/client-go/listers/admissionregistration/v1beta1" + admissionlisters "k8s.io/client-go/listers/admissionregistration/v1" corelisters "k8s.io/client-go/listers/core/v1" "knative.dev/pkg/apis" "knative.dev/pkg/apis/duck" @@ -96,17 +96,17 @@ func (ac *reconciler) Path() string { } // Admit implements AdmissionController -func (ac *reconciler) Admit(ctx context.Context, request *admissionv1beta1.AdmissionRequest) *admissionv1beta1.AdmissionResponse { +func (ac *reconciler) Admit(ctx context.Context, request *admissionv1.AdmissionRequest) *admissionv1.AdmissionResponse { if ac.withContext != nil { ctx = ac.withContext(ctx) } logger := logging.FromContext(ctx) switch request.Operation { - case admissionv1beta1.Create, admissionv1beta1.Update: + case admissionv1.Create, admissionv1.Update: default: logger.Infof("Unhandled webhook operation, letting it through %v", request.Operation) - return &admissionv1beta1.AdmissionResponse{Allowed: true} + return &admissionv1.AdmissionResponse{Allowed: true} } patchBytes, err := ac.mutate(ctx, request) @@ -115,11 +115,11 @@ func (ac *reconciler) Admit(ctx context.Context, request *admissionv1beta1.Admis } logger.Infof("Kind: %q PatchBytes: %v", request.Kind, string(patchBytes)) - return &admissionv1beta1.AdmissionResponse{ + return &admissionv1.AdmissionResponse{ Patch: patchBytes, Allowed: true, - PatchType: func() *admissionv1beta1.PatchType { - pt := admissionv1beta1.PatchTypeJSONPatch + PatchType: func() *admissionv1.PatchType { + pt := admissionv1.PatchTypeJSONPatch return &pt }(), } @@ -128,16 +128,16 @@ func (ac *reconciler) Admit(ctx context.Context, request *admissionv1beta1.Admis func (ac *reconciler) reconcileMutatingWebhook(ctx context.Context, caCert []byte) error { logger := logging.FromContext(ctx) - rules := make([]admissionregistrationv1beta1.RuleWithOperations, 0, len(ac.handlers)) + rules := make([]admissionregistrationv1.RuleWithOperations, 0, len(ac.handlers)) for gvk := range ac.handlers { plural := strings.ToLower(inflect.Pluralize(gvk.Kind)) - rules = append(rules, admissionregistrationv1beta1.RuleWithOperations{ - Operations: []admissionregistrationv1beta1.OperationType{ - admissionregistrationv1beta1.Create, - admissionregistrationv1beta1.Update, + rules = append(rules, admissionregistrationv1.RuleWithOperations{ + Operations: []admissionregistrationv1.OperationType{ + admissionregistrationv1.Create, + admissionregistrationv1.Update, }, - Rule: admissionregistrationv1beta1.Rule{ + Rule: admissionregistrationv1.Rule{ APIGroups: []string{gvk.Group}, APIVersions: []string{gvk.Version}, Resources: []string{plural + "/*"}, @@ -190,7 +190,7 @@ func (ac *reconciler) reconcileMutatingWebhook(ctx context.Context, caCert []byt return fmt.Errorf("error diffing webhooks: %w", err) } else if !ok { logger.Info("Updating webhook") - mwhclient := ac.client.AdmissionregistrationV1beta1().MutatingWebhookConfigurations() + mwhclient := ac.client.AdmissionregistrationV1().MutatingWebhookConfigurations() if _, err := mwhclient.Update(webhook); err != nil { return fmt.Errorf("failed to update webhook: %w", err) } @@ -200,7 +200,7 @@ func (ac *reconciler) reconcileMutatingWebhook(ctx context.Context, caCert []byt return nil } -func (ac *reconciler) mutate(ctx context.Context, req *admissionv1beta1.AdmissionRequest) ([]byte, error) { +func (ac *reconciler) mutate(ctx context.Context, req *admissionv1.AdmissionRequest) ([]byte, error) { kind := req.Kind newBytes := req.Object.Raw oldBytes := req.OldObject.Raw diff --git a/webhook/resourcesemantics/defaulting/defaulting_test.go b/webhook/resourcesemantics/defaulting/defaulting_test.go index deae5a7f95..e8aa2ecc5b 100644 --- a/webhook/resourcesemantics/defaulting/defaulting_test.go +++ b/webhook/resourcesemantics/defaulting/defaulting_test.go @@ -23,12 +23,12 @@ import ( // Injection stuff _ "knative.dev/pkg/client/injection/kube/client/fake" - _ "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1beta1/mutatingwebhookconfiguration/fake" + _ "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1/mutatingwebhookconfiguration/fake" _ "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret/fake" jsonpatch "gomodules.xyz/jsonpatch/v2" - admissionv1beta1 "k8s.io/api/admission/v1beta1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + admissionv1 "k8s.io/api/admission/v1" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" authenticationv1 "k8s.io/api/authentication/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" @@ -78,17 +78,17 @@ var ( }: &InnerDefaultResource{}, } - initialResourceWebhook = &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + initialResourceWebhook = &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: "webhook.knative.dev", OwnerReferences: []metav1.OwnerReference{{ Name: "asdf", }}, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: "webhook.knative.dev", - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", }, @@ -112,8 +112,8 @@ func newNonRunningTestResourceAdmissionController(t *testing.T) ( func TestDeleteAllowed(t *testing.T) { _, ac := newNonRunningTestResourceAdmissionController(t) - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Delete, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Delete, } if resp := ac.Admit(TestContextWithLogger(t), req); !resp.Allowed { @@ -124,8 +124,8 @@ func TestDeleteAllowed(t *testing.T) { func TestConnectAllowed(t *testing.T) { _, ac := newNonRunningTestResourceAdmissionController(t) - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Connect, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Connect, } resp := ac.Admit(TestContextWithLogger(t), req) @@ -137,8 +137,8 @@ func TestConnectAllowed(t *testing.T) { func TestUnknownKindFails(t *testing.T) { _, ac := newNonRunningTestResourceAdmissionController(t) - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -151,8 +151,8 @@ func TestUnknownKindFails(t *testing.T) { func TestUnknownVersionFails(t *testing.T) { _, ac := newNonRunningTestResourceAdmissionController(t) - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1beta2", @@ -164,8 +164,8 @@ func TestUnknownVersionFails(t *testing.T) { func TestUnknownFieldFails(t *testing.T) { _, ac := newNonRunningTestResourceAdmissionController(t) - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -319,10 +319,10 @@ func TestAdmitCreates(t *testing.T) { } } -func createCreateResource(ctx context.Context, t *testing.T, r *Resource) *admissionv1beta1.AdmissionRequest { +func createCreateResource(ctx context.Context, t *testing.T, r *Resource) *admissionv1.AdmissionRequest { t.Helper() - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -429,10 +429,10 @@ func TestAdmitUpdates(t *testing.T) { } } -func createUpdateResource(ctx context.Context, t *testing.T, old, new *Resource) *admissionv1beta1.AdmissionRequest { +func createUpdateResource(ctx context.Context, t *testing.T, old, new *Resource) *admissionv1.AdmissionRequest { t.Helper() - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Update, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Update, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -455,8 +455,8 @@ func createUpdateResource(ctx context.Context, t *testing.T, old, new *Resource) } func TestValidCreateResourceSucceedsWithRoundTripAndDefaultPatch(t *testing.T) { - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", diff --git a/webhook/resourcesemantics/defaulting/table_test.go b/webhook/resourcesemantics/defaulting/table_test.go index 433cba7e78..6ac9aeb1ee 100644 --- a/webhook/resourcesemantics/defaulting/table_test.go +++ b/webhook/resourcesemantics/defaulting/table_test.go @@ -23,7 +23,7 @@ import ( kubeclient "knative.dev/pkg/client/injection/kube/client/fake" _ "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret/fake" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -66,30 +66,30 @@ func TestReconcile(t *testing.T) { } // These are the rules we expect given the context of "handlers". - expectedRules := []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + expectedRules := []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.dev"}, APIVersions: []string{"v1alpha1"}, Resources: []string{"innerdefaultresources/*"}, }, }, { - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.dev"}, APIVersions: []string{"v1alpha1"}, Resources: []string{"resources/*"}, }, }, { - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.dev"}, APIVersions: []string{"v1beta1"}, Resources: []string{"resources/*"}, }, }, { - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.io"}, APIVersions: []string{"v1alpha1"}, Resources: []string{"innerdefaultresources/*"}, @@ -128,11 +128,11 @@ func TestReconcile(t *testing.T) { Name: "secret and MWH exist, missing service reference", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, }}, }, @@ -142,14 +142,14 @@ func TestReconcile(t *testing.T) { Name: "secret and MWH exist, missing other stuff", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", }, @@ -158,14 +158,14 @@ func TestReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + Object: &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is added. @@ -184,14 +184,14 @@ func TestReconcile(t *testing.T) { Name: "secret and MWH exist, added fields are incorrect", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Incorrect @@ -201,9 +201,9 @@ func TestReconcile(t *testing.T) { CABundle: []byte("incorrect"), }, // Incorrect (really just incomplete) - Rules: []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Rules: []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.dev"}, APIVersions: []string{"v1alpha1"}, Resources: []string{"innerdefaultresources/*"}, @@ -213,14 +213,14 @@ func TestReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + Object: &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fixed. @@ -243,14 +243,14 @@ func TestReconcile(t *testing.T) { InduceFailure("update", "mutatingwebhookconfigurations"), }, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Incorrect @@ -260,9 +260,9 @@ func TestReconcile(t *testing.T) { CABundle: []byte("incorrect"), }, // Incorrect (really just incomplete) - Rules: []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Rules: []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.dev"}, APIVersions: []string{"v1alpha1"}, Resources: []string{"innerdefaultresources/*"}, @@ -272,14 +272,14 @@ func TestReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + Object: &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fixed. @@ -298,14 +298,14 @@ func TestReconcile(t *testing.T) { Name: ":fire: everything is fine :fire:", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.MutatingWebhookConfiguration{ + &admissionregistrationv1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.MutatingWebhook{{ + Webhooks: []admissionregistrationv1.MutatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fine. diff --git a/webhook/resourcesemantics/validation/controller.go b/webhook/resourcesemantics/validation/controller.go index cbaeaa5b29..e86574f82b 100644 --- a/webhook/resourcesemantics/validation/controller.go +++ b/webhook/resourcesemantics/validation/controller.go @@ -21,7 +21,7 @@ import ( // Injection stuff kubeclient "knative.dev/pkg/client/injection/kube/client" - vwhinformer "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1beta1/validatingwebhookconfiguration" + vwhinformer "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1/validatingwebhookconfiguration" secretinformer "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/webhook/resourcesemantics/validation/reconcile_config.go b/webhook/resourcesemantics/validation/reconcile_config.go index c17db6281c..a6818fa27b 100644 --- a/webhook/resourcesemantics/validation/reconcile_config.go +++ b/webhook/resourcesemantics/validation/reconcile_config.go @@ -24,11 +24,11 @@ import ( "github.com/markbates/inflect" "go.uber.org/zap" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" - admissionlisters "k8s.io/client-go/listers/admissionregistration/v1beta1" + admissionlisters "k8s.io/client-go/listers/admissionregistration/v1" corelisters "k8s.io/client-go/listers/core/v1" "knative.dev/pkg/controller" "knative.dev/pkg/kmp" @@ -90,17 +90,17 @@ func (ac *reconciler) Reconcile(ctx context.Context, key string) error { func (ac *reconciler) reconcileValidatingWebhook(ctx context.Context, caCert []byte) error { logger := logging.FromContext(ctx) - rules := make([]admissionregistrationv1beta1.RuleWithOperations, 0, len(ac.handlers)) + rules := make([]admissionregistrationv1.RuleWithOperations, 0, len(ac.handlers)) for gvk := range ac.handlers { plural := strings.ToLower(inflect.Pluralize(gvk.Kind)) - rules = append(rules, admissionregistrationv1beta1.RuleWithOperations{ - Operations: []admissionregistrationv1beta1.OperationType{ - admissionregistrationv1beta1.Create, - admissionregistrationv1beta1.Update, - admissionregistrationv1beta1.Delete, + rules = append(rules, admissionregistrationv1.RuleWithOperations{ + Operations: []admissionregistrationv1.OperationType{ + admissionregistrationv1.Create, + admissionregistrationv1.Update, + admissionregistrationv1.Delete, }, - Rule: admissionregistrationv1beta1.Rule{ + Rule: admissionregistrationv1.Rule{ APIGroups: []string{gvk.Group}, APIVersions: []string{gvk.Version}, Resources: []string{plural + "/*"}, @@ -153,7 +153,7 @@ func (ac *reconciler) reconcileValidatingWebhook(ctx context.Context, caCert []b return fmt.Errorf("error diffing webhooks: %w", err) } else if !ok { logger.Info("Updating webhook") - vwhclient := ac.client.AdmissionregistrationV1beta1().ValidatingWebhookConfigurations() + vwhclient := ac.client.AdmissionregistrationV1().ValidatingWebhookConfigurations() if _, err := vwhclient.Update(webhook); err != nil { return fmt.Errorf("failed to update webhook: %w", err) } diff --git a/webhook/resourcesemantics/validation/reconcile_config_test.go b/webhook/resourcesemantics/validation/reconcile_config_test.go index cbe9033982..6dc98f4616 100644 --- a/webhook/resourcesemantics/validation/reconcile_config_test.go +++ b/webhook/resourcesemantics/validation/reconcile_config_test.go @@ -23,7 +23,7 @@ import ( kubeclient "knative.dev/pkg/client/injection/kube/client/fake" _ "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret/fake" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -66,30 +66,30 @@ func TestReconcile(t *testing.T) { } // These are the rules we expect given the context of "handlers". - expectedRules := []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE", "DELETE"}, - Rule: admissionregistrationv1beta1.Rule{ + expectedRules := []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE", "DELETE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.dev"}, APIVersions: []string{"v1alpha1"}, Resources: []string{"innerdefaultresources/*"}, }, }, { - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE", "DELETE"}, - Rule: admissionregistrationv1beta1.Rule{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE", "DELETE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.dev"}, APIVersions: []string{"v1alpha1"}, Resources: []string{"resources/*"}, }, }, { - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE", "DELETE"}, - Rule: admissionregistrationv1beta1.Rule{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE", "DELETE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.dev"}, APIVersions: []string{"v1beta1"}, Resources: []string{"resources/*"}, }, }, { - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE", "DELETE"}, - Rule: admissionregistrationv1beta1.Rule{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE", "DELETE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.io"}, APIVersions: []string{"v1alpha1"}, Resources: []string{"innerdefaultresources/*"}, @@ -128,11 +128,11 @@ func TestReconcile(t *testing.T) { Name: "secret and VWH exist, missing service reference", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, }}, }, @@ -142,14 +142,14 @@ func TestReconcile(t *testing.T) { Name: "secret and VWH exist, missing other stuff", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", }, @@ -158,14 +158,14 @@ func TestReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + Object: &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is added. @@ -184,14 +184,14 @@ func TestReconcile(t *testing.T) { Name: "secret and VWH exist, added fields are incorrect", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Incorrect @@ -201,9 +201,9 @@ func TestReconcile(t *testing.T) { CABundle: []byte("incorrect"), }, // Incorrect (really just incomplete) - Rules: []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Rules: []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.dev"}, APIVersions: []string{"v1alpha1"}, Resources: []string{"innerdefaultresources/*"}, @@ -213,14 +213,14 @@ func TestReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + Object: &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fixed. @@ -243,14 +243,14 @@ func TestReconcile(t *testing.T) { InduceFailure("update", "validatingwebhookconfigurations"), }, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Incorrect @@ -260,9 +260,9 @@ func TestReconcile(t *testing.T) { CABundle: []byte("incorrect"), }, // Incorrect (really just incomplete) - Rules: []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{"CREATE", "UPDATE"}, - Rule: admissionregistrationv1beta1.Rule{ + Rules: []admissionregistrationv1.RuleWithOperations{{ + Operations: []admissionregistrationv1.OperationType{"CREATE", "UPDATE"}, + Rule: admissionregistrationv1.Rule{ APIGroups: []string{"pkg.knative.dev"}, APIVersions: []string{"v1alpha1"}, Resources: []string{"innerdefaultresources/*"}, @@ -272,14 +272,14 @@ func TestReconcile(t *testing.T) { }, }, WantUpdates: []clientgotesting.UpdateActionImpl{{ - Object: &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + Object: &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fixed. @@ -298,14 +298,14 @@ func TestReconcile(t *testing.T) { Name: ":fire: everything is fine :fire:", Key: key, Objects: []runtime.Object{secret, - &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: name, - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", // Path is fine. diff --git a/webhook/resourcesemantics/validation/validation_admit.go b/webhook/resourcesemantics/validation/validation_admit.go index c547359ff9..ad61de9974 100644 --- a/webhook/resourcesemantics/validation/validation_admit.go +++ b/webhook/resourcesemantics/validation/validation_admit.go @@ -24,7 +24,7 @@ import ( "fmt" "go.uber.org/zap" - admissionv1beta1 "k8s.io/api/admission/v1beta1" + admissionv1 "k8s.io/api/admission/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" @@ -61,7 +61,7 @@ func NewCallback(function func(context.Context, *unstructured.Unstructured) erro var _ webhook.AdmissionController = (*reconciler)(nil) // Admit implements AdmissionController -func (ac *reconciler) Admit(ctx context.Context, request *admissionv1beta1.AdmissionRequest) *admissionv1beta1.AdmissionResponse { +func (ac *reconciler) Admit(ctx context.Context, request *admissionv1.AdmissionRequest) *admissionv1.AdmissionResponse { if ac.withContext != nil { ctx = ac.withContext(ctx) } @@ -86,14 +86,14 @@ func (ac *reconciler) Admit(ctx context.Context, request *admissionv1beta1.Admis return webhook.MakeErrorStatus("validation callback failed: %v", err) } - return &admissionv1beta1.AdmissionResponse{Allowed: true} + return &admissionv1.AdmissionResponse{Allowed: true} } // decodeRequestAndPrepareContext deserializes the old and new GenericCrds from the incoming request and sets up the context. // nil oldObj or newObj denote absence of `old` (create) or `new` (delete) objects. func (ac *reconciler) decodeRequestAndPrepareContext( ctx context.Context, - req *admissionv1beta1.AdmissionRequest, + req *admissionv1.AdmissionRequest, gvk schema.GroupVersionKind) (context.Context, resourcesemantics.GenericCRD, error) { logger := logging.FromContext(ctx) @@ -142,11 +142,11 @@ func (ac *reconciler) decodeRequestAndPrepareContext( } switch req.Operation { - case admissionv1beta1.Update: + case admissionv1.Update: ctx = apis.WithinUpdate(ctx, oldObj) - case admissionv1beta1.Create: + case admissionv1.Create: ctx = apis.WithinCreate(ctx) - case admissionv1beta1.Delete: + case admissionv1.Delete: ctx = apis.WithinDelete(ctx) return ctx, oldObj, nil } @@ -154,14 +154,14 @@ func (ac *reconciler) decodeRequestAndPrepareContext( return ctx, newObj, nil } -func validate(ctx context.Context, resource resourcesemantics.GenericCRD, req *admissionv1beta1.AdmissionRequest) error { +func validate(ctx context.Context, resource resourcesemantics.GenericCRD, req *admissionv1.AdmissionRequest) error { logger := logging.FromContext(ctx) // Only run validation for supported create and update validaiton. switch req.Operation { - case admissionv1beta1.Create, admissionv1beta1.Update: + case admissionv1.Create, admissionv1.Update: // Supported verbs - case admissionv1beta1.Delete: + case admissionv1.Delete: return nil // Validation handled by optional Callback, but not validatable. default: logger.Infof("Unhandled webhook validation operation, letting it through %v", req.Operation) @@ -184,9 +184,9 @@ func validate(ctx context.Context, resource resourcesemantics.GenericCRD, req *a } // callback runs optional callbacks on admission -func (ac *reconciler) callback(ctx context.Context, req *admissionv1beta1.AdmissionRequest, gvk schema.GroupVersionKind) error { +func (ac *reconciler) callback(ctx context.Context, req *admissionv1.AdmissionRequest, gvk schema.GroupVersionKind) error { var toDecode []byte - if req.Operation == admissionv1beta1.Delete { + if req.Operation == admissionv1.Delete { toDecode = req.OldObject.Raw } else { toDecode = req.Object.Raw diff --git a/webhook/resourcesemantics/validation/validation_admit_test.go b/webhook/resourcesemantics/validation/validation_admit_test.go index f3e2ea3126..ad48ebce77 100644 --- a/webhook/resourcesemantics/validation/validation_admit_test.go +++ b/webhook/resourcesemantics/validation/validation_admit_test.go @@ -24,11 +24,11 @@ import ( // Injection stuff _ "knative.dev/pkg/client/injection/kube/client/fake" - _ "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1beta1/validatingwebhookconfiguration/fake" + _ "knative.dev/pkg/client/injection/kube/informers/admissionregistration/v1/validatingwebhookconfiguration/fake" _ "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret/fake" - admissionv1beta1 "k8s.io/api/admission/v1beta1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + admissionv1 "k8s.io/api/admission/v1" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1beta1" authenticationv1 "k8s.io/api/authentication/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -91,17 +91,17 @@ var ( Kind: "Resource", }: NewCallback(resourceCallback, webhook.Create, webhook.Update, webhook.Delete), } - initialResourceWebhook = &admissionregistrationv1beta1.ValidatingWebhookConfiguration{ + initialResourceWebhook = &admissionregistrationv1.ValidatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: "webhook.knative.dev", OwnerReferences: []metav1.OwnerReference{{ Name: "asdf", }}, }, - Webhooks: []admissionregistrationv1beta1.ValidatingWebhook{{ + Webhooks: []admissionregistrationv1.ValidatingWebhook{{ Name: "webhook.knative.dev", - ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ - Service: &admissionregistrationv1beta1.ServiceReference{ + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ Namespace: system.Namespace(), Name: "webhook", }, @@ -125,8 +125,8 @@ func newNonRunningTestResourceAdmissionController(t *testing.T) ( func TestDeleteAllowed(t *testing.T) { _, ac := newNonRunningTestResourceAdmissionController(t) - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Delete, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Delete, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -142,8 +142,8 @@ func TestDeleteAllowed(t *testing.T) { func TestConnectAllowed(t *testing.T) { _, ac := newNonRunningTestResourceAdmissionController(t) - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Connect, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Connect, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -160,8 +160,8 @@ func TestConnectAllowed(t *testing.T) { func TestUnknownKindFails(t *testing.T) { _, ac := newNonRunningTestResourceAdmissionController(t) - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -174,8 +174,8 @@ func TestUnknownKindFails(t *testing.T) { func TestUnknownVersionFails(t *testing.T) { _, ac := newNonRunningTestResourceAdmissionController(t) - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1beta2", @@ -187,8 +187,8 @@ func TestUnknownVersionFails(t *testing.T) { func TestUnknownFieldFails(t *testing.T) { _, ac := newNonRunningTestResourceAdmissionController(t) - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -395,10 +395,10 @@ func TestValidationDeleteCallback(t *testing.T) { } } -func createDeleteResource(ctx context.Context, t *testing.T, old *Resource) *admissionv1beta1.AdmissionRequest { +func createDeleteResource(ctx context.Context, t *testing.T, old *Resource) *admissionv1.AdmissionRequest { t.Helper() - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Delete, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Delete, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -415,10 +415,10 @@ func createDeleteResource(ctx context.Context, t *testing.T, old *Resource) *adm return req } -func createCreateResource(ctx context.Context, t *testing.T, r *Resource) *admissionv1beta1.AdmissionRequest { +func createCreateResource(ctx context.Context, t *testing.T, r *Resource) *admissionv1.AdmissionRequest { t.Helper() - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -501,10 +501,10 @@ func TestAdmitUpdates(t *testing.T) { } } -func createUpdateResource(ctx context.Context, t *testing.T, old, new *Resource) *admissionv1beta1.AdmissionRequest { +func createUpdateResource(ctx context.Context, t *testing.T, old, new *Resource) *admissionv1.AdmissionRequest { t.Helper() - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Update, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Update, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", diff --git a/webhook/resourcesemantics/validation/validation_deprecated_test.go b/webhook/resourcesemantics/validation/validation_deprecated_test.go index 832632264f..4be9036c59 100644 --- a/webhook/resourcesemantics/validation/validation_deprecated_test.go +++ b/webhook/resourcesemantics/validation/validation_deprecated_test.go @@ -19,7 +19,7 @@ package validation import ( "testing" - admissionv1beta1 "k8s.io/api/admission/v1beta1" + admissionv1 "k8s.io/api/admission/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" "knative.dev/pkg/ptr" @@ -32,9 +32,9 @@ import ( // In strict mode, you are not allowed to set a deprecated filed when doing a Create. func TestStrictValidation(t *testing.T) { - newCreateReq := func(new []byte) *admissionv1beta1.AdmissionRequest { - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + newCreateReq := func(new []byte) *admissionv1.AdmissionRequest { + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -45,9 +45,9 @@ func TestStrictValidation(t *testing.T) { return req } - newUpdateReq := func(old, new []byte) *admissionv1beta1.AdmissionRequest { - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + newUpdateReq := func(old, new []byte) *admissionv1.AdmissionRequest { + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", @@ -61,7 +61,7 @@ func TestStrictValidation(t *testing.T) { testCases := map[string]struct { strict bool - req *admissionv1beta1.AdmissionRequest + req *admissionv1.AdmissionRequest wantErrs []string }{ "create, strict": { @@ -511,8 +511,8 @@ func TestStrictValidation(t *testing.T) { // In strict mode, you are not allowed to set a deprecated filed when doing a Create. func TestStrictValidation_Spec_Create(t *testing.T) { - req := &admissionv1beta1.AdmissionRequest{ - Operation: admissionv1beta1.Create, + req := &admissionv1.AdmissionRequest{ + Operation: admissionv1.Create, Kind: metav1.GroupVersionKind{ Group: "pkg.knative.dev", Version: "v1alpha1", diff --git a/webhook/stats_reporter.go b/webhook/stats_reporter.go index 298bf499c9..13293200c0 100644 --- a/webhook/stats_reporter.go +++ b/webhook/stats_reporter.go @@ -24,7 +24,7 @@ import ( "go.opencensus.io/stats" "go.opencensus.io/stats/view" "go.opencensus.io/tag" - admissionv1beta1 "k8s.io/api/admission/v1beta1" + admissionv1 "k8s.io/api/admission/v1" "knative.dev/pkg/metrics" ) @@ -62,7 +62,7 @@ var ( // StatsReporter reports webhook metrics type StatsReporter interface { - ReportRequest(request *admissionv1beta1.AdmissionRequest, response *admissionv1beta1.AdmissionResponse, d time.Duration) error + ReportRequest(request *admissionv1.AdmissionRequest, response *admissionv1.AdmissionResponse, d time.Duration) error } // reporter implements StatsReporter interface @@ -83,7 +83,7 @@ func NewStatsReporter() (StatsReporter, error) { } // Captures req count metric, recording the count and the duration -func (r *reporter) ReportRequest(req *admissionv1beta1.AdmissionRequest, resp *admissionv1beta1.AdmissionResponse, d time.Duration) error { +func (r *reporter) ReportRequest(req *admissionv1.AdmissionRequest, resp *admissionv1.AdmissionResponse, d time.Duration) error { ctx, err := tag.New( r.ctx, tag.Insert(requestOperationKey, string(req.Operation)), diff --git a/webhook/stats_reporter_test.go b/webhook/stats_reporter_test.go index 72786b49ca..94b1cc47c5 100644 --- a/webhook/stats_reporter_test.go +++ b/webhook/stats_reporter_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - admissionv1beta1 "k8s.io/api/admission/v1beta1" + admissionv1 "k8s.io/api/admission/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/metrics/metricstest" _ "knative.dev/pkg/metrics/testing" @@ -29,16 +29,16 @@ import ( func TestWebhookStatsReporter(t *testing.T) { setup() - req := &admissionv1beta1.AdmissionRequest{ + req := &admissionv1.AdmissionRequest{ UID: "705ab4f5-6393-11e8-b7cc-42010a800002", Kind: metav1.GroupVersionKind{Group: "autoscaling", Version: "v1", Kind: "Scale"}, Resource: metav1.GroupVersionResource{Group: "apps", Version: "v1", Resource: "deployments"}, Name: "my-deployment", Namespace: "my-namespace", - Operation: admissionv1beta1.Update, + Operation: admissionv1.Update, } - resp := &admissionv1beta1.AdmissionResponse{ + resp := &admissionv1.AdmissionResponse{ UID: req.UID, Allowed: true, } diff --git a/webhook/testing/listers.go b/webhook/testing/listers.go index d3b8960785..68c41c0dab 100644 --- a/webhook/testing/listers.go +++ b/webhook/testing/listers.go @@ -17,15 +17,15 @@ limitations under the License. package testing import ( - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" appsv1 "k8s.io/api/apps/v1" autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1" corev1 "k8s.io/api/core/v1" - apixv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - apixlisters "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1" + apixv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + apixlisters "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1" "k8s.io/apimachinery/pkg/runtime" fakekubeclientset "k8s.io/client-go/kubernetes/fake" - admissionlisters "k8s.io/client-go/listers/admissionregistration/v1beta1" + admissionlisters "k8s.io/client-go/listers/admissionregistration/v1" fakeapix "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake" appsv1listers "k8s.io/client-go/listers/apps/v1" @@ -140,14 +140,14 @@ func (l *Listers) GetNamespaceLister() corev1listers.NamespaceLister { // GetMutatingWebhookConfigurationLister gets lister for K8s MutatingWebhookConfiguration resource. func (l *Listers) GetMutatingWebhookConfigurationLister() admissionlisters.MutatingWebhookConfigurationLister { - return admissionlisters.NewMutatingWebhookConfigurationLister(l.IndexerFor(&admissionregistrationv1beta1.MutatingWebhookConfiguration{})) + return admissionlisters.NewMutatingWebhookConfigurationLister(l.IndexerFor(&admissionregistrationv1.MutatingWebhookConfiguration{})) } // GetValidatingWebhookConfigurationLister gets lister for K8s ValidatingWebhookConfiguration resource. func (l *Listers) GetValidatingWebhookConfigurationLister() admissionlisters.ValidatingWebhookConfigurationLister { - return admissionlisters.NewValidatingWebhookConfigurationLister(l.IndexerFor(&admissionregistrationv1beta1.ValidatingWebhookConfiguration{})) + return admissionlisters.NewValidatingWebhookConfigurationLister(l.IndexerFor(&admissionregistrationv1.ValidatingWebhookConfiguration{})) } func (l *Listers) GetCustomResourceDefinitionLister() apixlisters.CustomResourceDefinitionLister { - return apixlisters.NewCustomResourceDefinitionLister(l.IndexerFor(&apixv1beta1.CustomResourceDefinition{})) + return apixlisters.NewCustomResourceDefinitionLister(l.IndexerFor(&apixv1.CustomResourceDefinition{})) } diff --git a/webhook/testing/testing.go b/webhook/testing/testing.go index 6c072fde12..3b0c1686ce 100644 --- a/webhook/testing/testing.go +++ b/webhook/testing/testing.go @@ -25,7 +25,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" jsonpatch "gomodules.xyz/jsonpatch/v2" - admissionv1beta1 "k8s.io/api/admission/v1beta1" + admissionv1 "k8s.io/api/admission/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/system" pkgtest "knative.dev/pkg/testing" @@ -52,7 +52,7 @@ func CreateResource(name string) *pkgtest.Resource { } // ExpectAllowed checks that a given admission response allows the initiating request through. -func ExpectAllowed(t *testing.T, resp *admissionv1beta1.AdmissionResponse) { +func ExpectAllowed(t *testing.T, resp *admissionv1.AdmissionResponse) { t.Helper() if !resp.Allowed { t.Errorf("Expected allowed, but failed with %+v", resp.Result) @@ -61,7 +61,7 @@ func ExpectAllowed(t *testing.T, resp *admissionv1beta1.AdmissionResponse) { // ExpectFailsWith checks that a given admission response disallows the initiating request // through and contains the provided string in its error message. -func ExpectFailsWith(t *testing.T, resp *admissionv1beta1.AdmissionResponse, contains string) { +func ExpectFailsWith(t *testing.T, resp *admissionv1.AdmissionResponse, contains string) { t.Helper() if resp.Allowed { t.Error("Expected denial, got allowed") diff --git a/webhook/webhook.go b/webhook/webhook.go index 869269b46d..1a2988c1c7 100644 --- a/webhook/webhook.go +++ b/webhook/webhook.go @@ -30,7 +30,7 @@ import ( "go.uber.org/zap" "golang.org/x/sync/errgroup" - admissionv1beta1 "k8s.io/api/admission/v1beta1" + admissionv1 "k8s.io/api/admission/v1" "k8s.io/client-go/kubernetes" corelisters "k8s.io/client-go/listers/core/v1" "knative.dev/pkg/logging" @@ -63,14 +63,14 @@ type Options struct { // Operation is the verb being operated on // it is aliasde in Validation from the k8s admission package -type Operation = admissionv1beta1.Operation +type Operation = admissionv1.Operation // Operation types const ( - Create Operation = admissionv1beta1.Create - Update Operation = admissionv1beta1.Update - Delete Operation = admissionv1beta1.Delete - Connect Operation = admissionv1beta1.Connect + Create Operation = admissionv1.Create + Update Operation = admissionv1.Update + Delete Operation = admissionv1.Delete + Connect Operation = admissionv1.Connect ) // Webhook implements the external webhook for validation of