Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update controller-runtime from 0.14 to 0.15 #6465

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 95 additions & 87 deletions go.mod

Large diffs are not rendered by default.

892 changes: 200 additions & 692 deletions go.sum

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1455,24 +1455,24 @@ const webhooksFragment = `
var _ webhook.Validator = &Memcached{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *Memcached) ValidateCreate() error {
func (r *Memcached) ValidateCreate() (warnings admission.Warnings, err error) {
memcachedlog.Info("validate create", "name", r.Name)

return validateOdd(r.Spec.Size)
return nil, validateOdd(r.Spec.Size)
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *Memcached) ValidateUpdate(old runtime.Object) error {
func (r *Memcached) ValidateUpdate(old runtime.Object) (warnings admission.Warnings, err error) {
memcachedlog.Info("validate update", "name", r.Name)

return validateOdd(r.Spec.Size)
return nil, validateOdd(r.Spec.Size)
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *Memcached) ValidateDelete() error {
func (r *Memcached) ValidateDelete() (warnings admission.Warnings, err error) {
memcachedlog.Info("validate delete", "name", r.Name)

return nil
return nil, nil
}
func validateOdd(n int32) error {
if n%2 == 0 {
Expand Down
17 changes: 9 additions & 8 deletions internal/ansible/handler/logging_enqueue_annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package handler

import (
"context"
"strings"

"github.com/operator-framework/operator-lib/handler"
Expand All @@ -34,27 +35,27 @@ type LoggingEnqueueRequestForAnnotation struct {
}

// Create implements EventHandler, and emits a log message.
func (h LoggingEnqueueRequestForAnnotation) Create(e event.CreateEvent, q workqueue.RateLimitingInterface) {
func (h LoggingEnqueueRequestForAnnotation) Create(c context.Context, e event.CreateEvent, q workqueue.RateLimitingInterface) {
h.logEvent("Create", e.Object, nil)
h.EnqueueRequestForAnnotation.Create(e, q)
h.EnqueueRequestForAnnotation.Create(c, e, q)
}

// Update implements EventHandler, and emits a log message.
func (h LoggingEnqueueRequestForAnnotation) Update(e event.UpdateEvent, q workqueue.RateLimitingInterface) {
func (h LoggingEnqueueRequestForAnnotation) Update(c context.Context, e event.UpdateEvent, q workqueue.RateLimitingInterface) {
h.logEvent("Update", e.ObjectOld, e.ObjectNew)
h.EnqueueRequestForAnnotation.Update(e, q)
h.EnqueueRequestForAnnotation.Update(c, e, q)
}

// Delete implements EventHandler, and emits a log message.
func (h LoggingEnqueueRequestForAnnotation) Delete(e event.DeleteEvent, q workqueue.RateLimitingInterface) {
func (h LoggingEnqueueRequestForAnnotation) Delete(c context.Context, e event.DeleteEvent, q workqueue.RateLimitingInterface) {
h.logEvent("Delete", e.Object, nil)
h.EnqueueRequestForAnnotation.Delete(e, q)
h.EnqueueRequestForAnnotation.Delete(c, e, q)
}

// Generic implements EventHandler, and emits a log message.
func (h LoggingEnqueueRequestForAnnotation) Generic(e event.GenericEvent, q workqueue.RateLimitingInterface) {
func (h LoggingEnqueueRequestForAnnotation) Generic(c context.Context, e event.GenericEvent, q workqueue.RateLimitingInterface) {
h.logEvent("Generic", e.Object, nil)
h.EnqueueRequestForAnnotation.Generic(e, q)
h.EnqueueRequestForAnnotation.Generic(c, e, q)
}

func (h LoggingEnqueueRequestForAnnotation) logEvent(eventType string, object, newObject client.Object) {
Expand Down
18 changes: 10 additions & 8 deletions internal/ansible/handler/logging_enqueue_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
package handler

import (
"context"

"github.com/operator-framework/operator-lib/handler"
"k8s.io/client-go/util/workqueue"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -32,27 +34,27 @@ type LoggingEnqueueRequestForObject struct {
}

// Create implements EventHandler, and emits a log message.
func (h LoggingEnqueueRequestForObject) Create(e event.CreateEvent, q workqueue.RateLimitingInterface) {
func (h LoggingEnqueueRequestForObject) Create(c context.Context, e event.CreateEvent, q workqueue.RateLimitingInterface) {
h.logEvent("Create", e.Object)
h.InstrumentedEnqueueRequestForObject.Create(e, q)
h.InstrumentedEnqueueRequestForObject.Create(c, e, q)
}

// Update implements EventHandler, and emits a log message.
func (h LoggingEnqueueRequestForObject) Update(e event.UpdateEvent, q workqueue.RateLimitingInterface) {
func (h LoggingEnqueueRequestForObject) Update(c context.Context, e event.UpdateEvent, q workqueue.RateLimitingInterface) {
h.logEvent("Update", e.ObjectOld)
h.InstrumentedEnqueueRequestForObject.Update(e, q)
h.InstrumentedEnqueueRequestForObject.Update(c, e, q)
}

// Delete implements EventHandler, and emits a log message.
func (h LoggingEnqueueRequestForObject) Delete(e event.DeleteEvent, q workqueue.RateLimitingInterface) {
func (h LoggingEnqueueRequestForObject) Delete(c context.Context, e event.DeleteEvent, q workqueue.RateLimitingInterface) {
h.logEvent("Delete", e.Object)
h.InstrumentedEnqueueRequestForObject.Delete(e, q)
h.InstrumentedEnqueueRequestForObject.Delete(c, e, q)
}

// Generic implements EventHandler, and emits a log message.
func (h LoggingEnqueueRequestForObject) Generic(e event.GenericEvent, q workqueue.RateLimitingInterface) {
func (h LoggingEnqueueRequestForObject) Generic(c context.Context, e event.GenericEvent, q workqueue.RateLimitingInterface) {
h.logEvent("Generic", e.Object)
h.EnqueueRequestForObject.Generic(e, q)
h.EnqueueRequestForObject.Generic(c, e, q)
}

func (h LoggingEnqueueRequestForObject) logEvent(eventType string, object client.Object) {
Expand Down
10 changes: 6 additions & 4 deletions internal/ansible/handler/logging_enqueue_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
package handler

import (
"context"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/util/workqueue"
Expand All @@ -31,25 +33,25 @@ type LoggingEnqueueRequestForOwner struct {
}

// Create implements EventHandler, and emits a log message.
func (h LoggingEnqueueRequestForOwner) Create(e event.CreateEvent, q workqueue.RateLimitingInterface) {
func (h LoggingEnqueueRequestForOwner) Create(c context.Context, e event.CreateEvent, q workqueue.RateLimitingInterface) {
h.logEvent("Create", e.Object, nil)
h.EnqueueRequestForOwner.Create(e, q)
}

// Update implements EventHandler, and emits a log message.
func (h LoggingEnqueueRequestForOwner) Update(e event.UpdateEvent, q workqueue.RateLimitingInterface) {
func (h LoggingEnqueueRequestForOwner) Update(c context.Context, e event.UpdateEvent, q workqueue.RateLimitingInterface) {
h.logEvent("Update", e.ObjectOld, e.ObjectNew)
h.EnqueueRequestForOwner.Update(e, q)
}

// Delete implements EventHandler, and emits a log message.
func (h LoggingEnqueueRequestForOwner) Delete(e event.DeleteEvent, q workqueue.RateLimitingInterface) {
func (h LoggingEnqueueRequestForOwner) Delete(c context.Context, e event.DeleteEvent, q workqueue.RateLimitingInterface) {
h.logEvent("Delete", e.Object, nil)
h.EnqueueRequestForOwner.Delete(e, q)
}

// Generic implements EventHandler, and emits a log message.
func (h LoggingEnqueueRequestForOwner) Generic(e event.GenericEvent, q workqueue.RateLimitingInterface) {
func (h LoggingEnqueueRequestForOwner) Generic(c context.Context, e event.GenericEvent, q workqueue.RateLimitingInterface) {
h.logEvent("Generic", e.Object, nil)
h.EnqueueRequestForOwner.Generic(e, q)
}
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/operator-sdk/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"sigs.k8s.io/kubebuilder/v3/pkg/model/stage"
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
kustomizev1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v1"
kustomizev2Alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha"
kustomizev2 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2"
"sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
declarativev1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/declarative/v1"
deployimagev1alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/deploy-image/v1alpha1"
Expand Down Expand Up @@ -90,27 +90,27 @@ func GetPluginsCLIAndRoot() (*cli.CLI, *cobra.Command) {
scorecardv2.Plugin{},
)
gov4AlphaBundle, _ := plugin.NewBundle(golang.DefaultNameQualifier, plugin.Version{Number: 4, Stage: stage.Alpha},
kustomizev2Alpha.Plugin{},
kustomizev2.Plugin{},
// # TODO(rashmigottipati): make v4 stable with the next release of KB
// as `go/v3` is getting deprecated by KB hence Operator SDK would also be migrating to v4 soon.
golangv4.Plugin{},
manifestsv2.Plugin{},
scorecardv2.Plugin{},
)
ansibleBundle, _ := plugin.NewBundle("ansible"+plugins.DefaultNameQualifier, plugin.Version{Number: 1},
kustomizev2Alpha.Plugin{},
kustomizev2.Plugin{},
ansiblev1.Plugin{},
manifestsv2.Plugin{},
scorecardv2.Plugin{},
)
helmBundle, _ := plugin.NewBundle("helm"+plugins.DefaultNameQualifier, plugin.Version{Number: 1},
kustomizev2Alpha.Plugin{},
kustomizev2.Plugin{},
helmv1.Plugin{},
manifestsv2.Plugin{},
scorecardv2.Plugin{},
)
hybridBundle, _ := plugin.NewBundle("hybrid.helm"+plugins.DefaultNameQualifier, plugin.Version{Number: 1, Stage: stage.Alpha},
kustomizev2Alpha.Plugin{},
kustomizev2.Plugin{},
hybrid.Plugin{},
manifestsv2.Plugin{},
scorecardv2.Plugin{},
Expand Down
4 changes: 2 additions & 2 deletions internal/plugins/ansible/v1/scaffolds/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"sigs.k8s.io/kubebuilder/v3/pkg/config"
"sigs.k8s.io/kubebuilder/v3/pkg/machinery"
"sigs.k8s.io/kubebuilder/v3/pkg/plugins"
kustomizev2Alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha"
kustomizev2 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2"

"github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates"
"github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac"
Expand Down Expand Up @@ -73,7 +73,7 @@ func (s *initScaffolder) Scaffold() error {
&templates.Dockerfile{AnsibleOperatorVersion: ansibleOperatorVersion},
&templates.Makefile{
Image: imageName,
KustomizeVersion: kustomizev2Alpha.KustomizeVersion,
KustomizeVersion: kustomizev2.KustomizeVersion,
AnsibleOperatorVersion: ansibleOperatorVersion,
},
&templates.GitIgnore{},
Expand Down
2 changes: 1 addition & 1 deletion internal/plugins/helm/v1/scaffolds/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package scaffolds
import (
"os"

kustomizev2Alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha"
kustomizev2Alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2"

"sigs.k8s.io/kubebuilder/v3/pkg/config"
"sigs.k8s.io/kubebuilder/v3/pkg/machinery"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand Down Expand Up @@ -55,24 +56,24 @@ func (r *Memcached) Default() {
var _ webhook.Validator = &Memcached{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *Memcached) ValidateCreate() error {
func (r *Memcached) ValidateCreate() (warnings admission.Warnings, err error) {
memcachedlog.Info("validate create", "name", r.Name)

return validateOdd(r.Spec.Size)
return nil, validateOdd(r.Spec.Size)
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *Memcached) ValidateUpdate(old runtime.Object) error {
func (r *Memcached) ValidateUpdate(old runtime.Object) (warnings admission.Warnings, err error) {
memcachedlog.Info("validate update", "name", r.Name)

return validateOdd(r.Spec.Size)
return nil, validateOdd(r.Spec.Size)
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *Memcached) ValidateDelete() error {
func (r *Memcached) ValidateDelete() (warnings admission.Warnings, err error) {
memcachedlog.Info("validate delete", "name", r.Name)

return nil
return nil, nil
}
func validateOdd(n int32) error {
if n%2 == 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand Down Expand Up @@ -55,24 +56,24 @@ func (r *Memcached) Default() {
var _ webhook.Validator = &Memcached{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *Memcached) ValidateCreate() error {
func (r *Memcached) ValidateCreate() (warnings admission.Warnings, err error) {
memcachedlog.Info("validate create", "name", r.Name)

return validateOdd(r.Spec.Size)
return nil, validateOdd(r.Spec.Size)
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *Memcached) ValidateUpdate(old runtime.Object) error {
func (r *Memcached) ValidateUpdate(old runtime.Object) (warnings admission.Warnings, err error) {
memcachedlog.Info("validate update", "name", r.Name)

return validateOdd(r.Spec.Size)
return nil, validateOdd(r.Spec.Size)
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *Memcached) ValidateDelete() error {
func (r *Memcached) ValidateDelete() (warnings admission.Warnings, err error) {
memcachedlog.Info("validate delete", "name", r.Name)

return nil
return nil, nil
}
func validateOdd(n int32) error {
if n%2 == 0 {
Expand Down
Loading