From dc3ab72442fab19090f063a541b9561e9ec9a6c5 Mon Sep 17 00:00:00 2001 From: Quentin Barrand Date: Wed, 24 May 2023 09:49:23 +0200 Subject: [PATCH] Upgrade to controller-runtime v0.15.0 Remove the logger in the filter types as those functions now get a context. Reimplement the way we read the operator config since the controller-runtime library code for that is deprecated. Upgrade to Kubernetes v1.27.2. Bump other dependencies. --- .../v1beta1/managedclustermodule_webhook.go | 7 +- api/v1beta1/module_webhook.go | 17 +++-- api/v1beta1/module_webhook_test.go | 25 ++++--- cmd/manager-hub/main.go | 15 ++-- cmd/manager/main.go | 14 ++-- ...m.sigs.x-k8s.io_managedclustermodules.yaml | 8 +- .../crd/bases/kmm.sigs.x-k8s.io_modules.yaml | 7 +- .../controller_manager_config.yaml | 16 ++-- config/manager/controller_manager_config.yaml | 16 ++-- .../hub/managedclustermodule_reconciler.go | 14 ++-- controllers/module_reconciler.go | 3 +- controllers/node_kernel_clusterclaim.go | 12 +-- controllers/preflightvalidation_reconciler.go | 14 ++-- go.mod | 37 +++++----- go.sum | 74 +++++++++---------- internal/client/mock_client.go | 31 ++++++++ internal/config/config.go | 48 ++++++++++++ internal/config/config_test.go | 31 ++++++++ internal/config/suite_test.go | 13 ++++ internal/config/testdata/config.yaml | 7 ++ internal/filter/filter.go | 21 +++--- internal/filter/filter_test.go | 64 ++++++++-------- 22 files changed, 307 insertions(+), 187 deletions(-) create mode 100644 internal/config/config.go create mode 100644 internal/config/config_test.go create mode 100644 internal/config/suite_test.go create mode 100644 internal/config/testdata/config.yaml diff --git a/api-hub/v1beta1/managedclustermodule_webhook.go b/api-hub/v1beta1/managedclustermodule_webhook.go index aa69fa544..094430ccc 100644 --- a/api-hub/v1beta1/managedclustermodule_webhook.go +++ b/api-hub/v1beta1/managedclustermodule_webhook.go @@ -22,6 +22,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" ) var modulelog = logf.Log.WithName("managed-cluster-module-resource") @@ -39,7 +40,7 @@ func (mcm *ManagedClusterModule) SetupWebhookWithManager(mgr ctrl.Manager) error var _ webhook.Validator = &ManagedClusterModule{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type -func (mcm *ManagedClusterModule) ValidateCreate() error { +func (mcm *ManagedClusterModule) ValidateCreate() (admission.Warnings, error) { modulelog.Info("Validating ManagedClusterModule creation", "name", mcm.Name, "namespace", mcm.Namespace) module := &kmmv1beta1.Module{ @@ -49,7 +50,7 @@ func (mcm *ManagedClusterModule) ValidateCreate() error { } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type -func (mcm *ManagedClusterModule) ValidateUpdate(obj runtime.Object) error { +func (mcm *ManagedClusterModule) ValidateUpdate(obj runtime.Object) (admission.Warnings, error) { modulelog.Info("Validating ManagedClusterModule update", "name", mcm.Name, "namespace", mcm.Namespace) module := &kmmv1beta1.Module{ @@ -59,7 +60,7 @@ func (mcm *ManagedClusterModule) ValidateUpdate(obj runtime.Object) error { } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type -func (mcm *ManagedClusterModule) ValidateDelete() error { +func (mcm *ManagedClusterModule) ValidateDelete() (admission.Warnings, error) { modulelog.Info("Validating ManagedClusterModule delete", "name", mcm.Name, "namespace", mcm.Namespace) module := &kmmv1beta1.Module{ diff --git a/api/v1beta1/module_webhook.go b/api/v1beta1/module_webhook.go index 3a32577fb..4904bc1fc 100644 --- a/api/v1beta1/module_webhook.go +++ b/api/v1beta1/module_webhook.go @@ -26,6 +26,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. @@ -44,30 +45,30 @@ func (m *Module) SetupWebhookWithManager(mgr ctrl.Manager) error { var _ webhook.Validator = &Module{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type -func (m *Module) ValidateCreate() error { +func (m *Module) ValidateCreate() (admission.Warnings, error) { modulelog.Info("Validating Module creation", "name", m.Name, "namespace", m.Namespace) if err := m.validateKernelMapping(); err != nil { - return fmt.Errorf("failed to validate kernel mappings: %v", err) + return nil, fmt.Errorf("failed to validate kernel mappings: %v", err) } - return m.validateModprobe() + return nil, m.validateModprobe() } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type -func (m *Module) ValidateUpdate(_ runtime.Object) error { +func (m *Module) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { modulelog.Info("Validating Module update", "name", m.Name, "namespace", m.Namespace) if err := m.validateKernelMapping(); err != nil { - return fmt.Errorf("failed to validate kernel mappings: %v", err) + return nil, fmt.Errorf("failed to validate kernel mappings: %v", err) } - return m.validateModprobe() + return nil, m.validateModprobe() } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type -func (m *Module) ValidateDelete() error { - return nil +func (m *Module) ValidateDelete() (admission.Warnings, error) { + return nil, nil } func (m *Module) validateKernelMapping() error { diff --git a/api/v1beta1/module_webhook_test.go b/api/v1beta1/module_webhook_test.go index cab83131a..869144ead 100644 --- a/api/v1beta1/module_webhook_test.go +++ b/api/v1beta1/module_webhook_test.go @@ -373,8 +373,8 @@ var _ = Describe("ValidateCreate", func() { }, } - e := mod.ValidateCreate() - Expect(e).ToNot(HaveOccurred()) + _, err := mod.ValidateCreate() + Expect(err).ToNot(HaveOccurred()) }) It("should fail when validating kernel mappings regexps", func() { @@ -390,9 +390,9 @@ var _ = Describe("ValidateCreate", func() { }, } - e := mod.ValidateCreate() - Expect(e).To(HaveOccurred()) - Expect(e.Error()).To(ContainSubstring("failed to validate kernel mappings")) + _, err := mod.ValidateCreate() + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("failed to validate kernel mappings")) }) }) @@ -434,8 +434,11 @@ var _ = Describe("ValidateUpdate", func() { }, } - Expect(mod1.ValidateUpdate(nil)).ToNot(HaveOccurred()) - Expect(mod2.ValidateUpdate(nil)).ToNot(HaveOccurred()) + _, err1 := mod1.ValidateUpdate(nil) + Expect(err1).ToNot(HaveOccurred()) + + _, err2 := mod2.ValidateUpdate(nil) + Expect(err2).ToNot(HaveOccurred()) }) It("should fail when validating kernel mappings regexps", func() { @@ -451,15 +454,15 @@ var _ = Describe("ValidateUpdate", func() { }, } - e := mod.ValidateUpdate(nil) - Expect(e).To(HaveOccurred()) - Expect(e.Error()).To(ContainSubstring("failed to validate kernel mappings")) + _, err := mod.ValidateUpdate(nil) + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("failed to validate kernel mappings")) }) }) var _ = Describe("ValidateDelete", func() { It("should do nothing and return always nil", func() { module := &Module{} - Expect(module.ValidateDelete()).ToNot(HaveOccurred()) + Expect(module.ValidateDelete()).To(BeEmpty()) }) }) diff --git a/cmd/manager-hub/main.go b/cmd/manager-hub/main.go index e7d3bedaf..f1c73b878 100644 --- a/cmd/manager-hub/main.go +++ b/cmd/manager-hub/main.go @@ -20,6 +20,7 @@ import ( "flag" "time" + "github.com/kubernetes-sigs/kernel-module-management/internal/config" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" @@ -29,7 +30,6 @@ import ( workv1 "open-cluster-management.io/api/work/v1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/healthz" - // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) // to ensure that exec-entrypoint and run can make use of them. _ "k8s.io/client-go/plugin/pkg/client/auth" @@ -87,21 +87,22 @@ func main() { setupLogger.Info("Creating manager", "git commit", commit) - options := ctrl.Options{Scheme: scheme} - - options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) + cfg, err := config.ParseFile(configFile) if err != nil { - cmd.FatalError(setupLogger, err, "unable to load the config file") + cmd.FatalError(setupLogger, err, "could not parse the configuration file", "path", configFile) } - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) + options := cfg.ManagerOptions() + options.Scheme = scheme + + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), *options) if err != nil { cmd.FatalError(setupLogger, err, "unable to create manager") } client := mgr.GetClient() - filterAPI := filter.New(client, mgr.GetLogger()) + filterAPI := filter.New(client) metricsAPI := metrics.New() metricsAPI.Register() diff --git a/cmd/manager/main.go b/cmd/manager/main.go index 39a289719..be4613744 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -22,6 +22,7 @@ import ( "os" "strconv" + "github.com/kubernetes-sigs/kernel-module-management/internal/config" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" @@ -93,21 +94,22 @@ func main() { setupLogger.Info("Creating manager", "git commit", commit) - options := ctrl.Options{Scheme: scheme} - - options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) + cfg, err := config.ParseFile(configFile) if err != nil { - cmd.FatalError(setupLogger, err, "unable to load the config file") + cmd.FatalError(setupLogger, err, "could not parse the configuration file", "path", configFile) } - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) + options := cfg.ManagerOptions() + options.Scheme = scheme + + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), *options) if err != nil { cmd.FatalError(setupLogger, err, "unable to create manager") } client := mgr.GetClient() - filterAPI := filter.New(client, mgr.GetLogger()) + filterAPI := filter.New(client) metricsAPI := metrics.New() metricsAPI.Register() diff --git a/config/crd-hub/bases/hub.kmm.sigs.x-k8s.io_managedclustermodules.yaml b/config/crd-hub/bases/hub.kmm.sigs.x-k8s.io_managedclustermodules.yaml index 95ebf579c..1ff320eb6 100644 --- a/config/crd-hub/bases/hub.kmm.sigs.x-k8s.io_managedclustermodules.yaml +++ b/config/crd-hub/bases/hub.kmm.sigs.x-k8s.io_managedclustermodules.yaml @@ -255,7 +255,8 @@ spec: of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined - value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + value. Requests cannot exceed Limits. More info: + https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object volumeMounts: @@ -728,7 +729,7 @@ spec: be the minimum value between the SizeLimit specified here and the sum of memory limits of all containers in a pod. The default is nil which means that - the limit is undefined. More info: http://kubernetes.io/docs/user-guide/volumes#emptydir' + the limit is undefined. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir' pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true type: object @@ -967,7 +968,8 @@ spec: a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + Requests cannot exceed Limits. More + info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object selector: diff --git a/config/crd/bases/kmm.sigs.x-k8s.io_modules.yaml b/config/crd/bases/kmm.sigs.x-k8s.io_modules.yaml index f1c3dce4b..86a94cf51 100644 --- a/config/crd/bases/kmm.sigs.x-k8s.io_modules.yaml +++ b/config/crd/bases/kmm.sigs.x-k8s.io_modules.yaml @@ -245,7 +245,7 @@ spec: compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object volumeMounts: @@ -698,7 +698,7 @@ spec: value between the SizeLimit specified here and the sum of memory limits of all containers in a pod. The default is nil which means that the limit is undefined. - More info: http://kubernetes.io/docs/user-guide/volumes#emptydir' + More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir' pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true type: object @@ -925,7 +925,8 @@ spec: If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined - value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + value. Requests cannot exceed Limits. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object selector: diff --git a/config/manager-hub/controller_manager_config.yaml b/config/manager-hub/controller_manager_config.yaml index 260acc5be..92d02049b 100644 --- a/config/manager-hub/controller_manager_config.yaml +++ b/config/manager-hub/controller_manager_config.yaml @@ -1,12 +1,6 @@ -apiVersion: controller-runtime.sigs.k8s.io/v1alpha1 -kind: ControllerManagerConfig -health: - healthProbeBindAddress: :8081 -metrics: - bindAddress: 127.0.0.1:8080 -webhook: - port: 9443 +healthProbeBindAddress: :8081 +metricsBindAddress: 127.0.0.1:8080 +webhookPort: 9443 leaderElection: - leaderElect: true - resourceName: kmm-hub.sigs.x-k8s.io - + enabled: true + resourceID: kmm-hub.sigs.x-k8s.io diff --git a/config/manager/controller_manager_config.yaml b/config/manager/controller_manager_config.yaml index 548bfc8ba..c7faddea2 100644 --- a/config/manager/controller_manager_config.yaml +++ b/config/manager/controller_manager_config.yaml @@ -1,12 +1,6 @@ -apiVersion: controller-runtime.sigs.k8s.io/v1alpha1 -kind: ControllerManagerConfig -health: - healthProbeBindAddress: :8081 -metrics: - bindAddress: 127.0.0.1:8080 -webhook: - port: 9443 +healthProbeBindAddress: :8081 +metricsBindAddress: 127.0.0.1:8080 +webhookPort: 9443 leaderElection: - leaderElect: true - resourceName: kmm.sigs.x-k8s.io - + enabled: true + resourceID: kmm.sigs.x-k8s.io diff --git a/controllers/hub/managedclustermodule_reconciler.go b/controllers/hub/managedclustermodule_reconciler.go index c480dfb97..7dabc4ceb 100644 --- a/controllers/hub/managedclustermodule_reconciler.go +++ b/controllers/hub/managedclustermodule_reconciler.go @@ -20,6 +20,11 @@ import ( "context" "fmt" + hubv1beta1 "github.com/kubernetes-sigs/kernel-module-management/api-hub/v1beta1" + "github.com/kubernetes-sigs/kernel-module-management/internal/cluster" + "github.com/kubernetes-sigs/kernel-module-management/internal/filter" + "github.com/kubernetes-sigs/kernel-module-management/internal/manifestwork" + "github.com/kubernetes-sigs/kernel-module-management/internal/statusupdater" batchv1 "k8s.io/api/batch/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -31,13 +36,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/source" - - hubv1beta1 "github.com/kubernetes-sigs/kernel-module-management/api-hub/v1beta1" - "github.com/kubernetes-sigs/kernel-module-management/internal/cluster" - "github.com/kubernetes-sigs/kernel-module-management/internal/filter" - "github.com/kubernetes-sigs/kernel-module-management/internal/manifestwork" - "github.com/kubernetes-sigs/kernel-module-management/internal/statusupdater" ) const ManagedClusterModuleReconcilerName = "ManagedClusterModule" @@ -168,7 +166,7 @@ func (r *ManagedClusterModuleReconciler) SetupWithManager(mgr ctrl.Manager) erro Owns(&workv1.ManifestWork{}). Owns(&batchv1.Job{}). Watches( - &source.Kind{Type: &clusterv1.ManagedCluster{}}, + &clusterv1.ManagedCluster{}, handler.EnqueueRequestsFromMapFunc(r.filter.FindManagedClusterModulesForCluster), builder.WithPredicates( r.filter.ManagedClusterModuleReconcilerManagedClusterPredicate(), diff --git a/controllers/module_reconciler.go b/controllers/module_reconciler.go index 8fa9154a1..7ecfb7318 100644 --- a/controllers/module_reconciler.go +++ b/controllers/module_reconciler.go @@ -45,7 +45,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/source" ) const ModuleReconcilerName = "Module" @@ -490,7 +489,7 @@ func (r *ModuleReconciler) SetupWithManager(mgr ctrl.Manager, kernelLabel string Owns(&appsv1.DaemonSet{}). Owns(&batchv1.Job{}). Watches( - &source.Kind{Type: &v1.Node{}}, + &v1.Node{}, handler.EnqueueRequestsFromMapFunc(r.filter.FindModulesForNode), builder.WithPredicates( r.filter.ModuleReconcilerNodePredicate(kernelLabel), diff --git a/controllers/node_kernel_clusterclaim.go b/controllers/node_kernel_clusterclaim.go index 66aa00238..d7538f923 100644 --- a/controllers/node_kernel_clusterclaim.go +++ b/controllers/node_kernel_clusterclaim.go @@ -6,6 +6,8 @@ import ( "sort" "strings" + "github.com/kubernetes-sigs/kernel-module-management/internal/constants" + "github.com/kubernetes-sigs/kernel-module-management/internal/filter" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "open-cluster-management.io/api/cluster/v1alpha1" @@ -17,10 +19,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/controller-runtime/pkg/source" - - "github.com/kubernetes-sigs/kernel-module-management/internal/constants" - "github.com/kubernetes-sigs/kernel-module-management/internal/filter" ) //+kubebuilder:rbac:groups="core",resources=nodes,verbs=get;patch;list;watch @@ -101,10 +99,8 @@ func (r *NodeKernelClusterClaimReconciler) SetupWithManager(mgr ctrl.Manager) er // Each time our ClusterClaim is updated, enqueue an empty reconciliation request. // We list all nodes during reconciliation, so sending an empty request is OK. Watches( - &source.Kind{ - Type: &v1alpha1.ClusterClaim{}, - }, - handler.EnqueueRequestsFromMapFunc(func(_ client.Object) []reconcile.Request { + &v1alpha1.ClusterClaim{}, + handler.EnqueueRequestsFromMapFunc(func(_ context.Context, _ client.Object) []reconcile.Request { return []reconcile.Request{{}} }), builder.WithPredicates( diff --git a/controllers/preflightvalidation_reconciler.go b/controllers/preflightvalidation_reconciler.go index 78451efb0..3a04030a4 100644 --- a/controllers/preflightvalidation_reconciler.go +++ b/controllers/preflightvalidation_reconciler.go @@ -22,6 +22,11 @@ import ( "time" v1beta12 "github.com/kubernetes-sigs/kernel-module-management/api/v1beta1" + "github.com/kubernetes-sigs/kernel-module-management/internal/filter" + "github.com/kubernetes-sigs/kernel-module-management/internal/metrics" + "github.com/kubernetes-sigs/kernel-module-management/internal/preflight" + "github.com/kubernetes-sigs/kernel-module-management/internal/statusupdater" + "github.com/kubernetes-sigs/kernel-module-management/internal/utils" batchv1 "k8s.io/api/batch/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" @@ -31,13 +36,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" - "sigs.k8s.io/controller-runtime/pkg/source" - - "github.com/kubernetes-sigs/kernel-module-management/internal/filter" - "github.com/kubernetes-sigs/kernel-module-management/internal/metrics" - "github.com/kubernetes-sigs/kernel-module-management/internal/preflight" - "github.com/kubernetes-sigs/kernel-module-management/internal/statusupdater" - "github.com/kubernetes-sigs/kernel-module-management/internal/utils" ) const ( @@ -75,7 +73,7 @@ func (r *PreflightValidationReconciler) SetupWithManager(mgr ctrl.Manager) error For(&v1beta12.PreflightValidation{}, builder.WithPredicates(filter.PreflightReconcilerUpdatePredicate())). Owns(&batchv1.Job{}). Watches( - &source.Kind{Type: &v1beta12.Module{}}, + &v1beta12.Module{}, handler.EnqueueRequestsFromMapFunc(r.filter.EnqueueAllPreflightValidations), builder.WithPredicates(filter.PreflightReconcilerUpdatePredicate()), ). diff --git a/go.mod b/go.mod index 00c809450..cad0f01e4 100644 --- a/go.mod +++ b/go.mod @@ -9,20 +9,21 @@ require ( github.com/golang/mock v1.6.0 github.com/google/go-cmp v0.5.9 github.com/google/go-containerregistry v0.15.2 - github.com/google/go-containerregistry/pkg/authn/kubernetes v0.0.0-20230316013512-53189d3374b8 + github.com/google/go-containerregistry/pkg/authn/kubernetes v0.0.0-20230523181351-c3f8a49229d3 github.com/mitchellh/hashstructure/v2 v2.0.2 github.com/onsi/ginkgo/v2 v2.9.5 github.com/onsi/gomega v1.27.7 github.com/prometheus/client_golang v1.15.1 golang.org/x/exp v0.0.0-20220407100705-7b9b53b0aca4 - k8s.io/api v0.26.3 - k8s.io/apimachinery v0.27.1 - k8s.io/client-go v0.26.3 + gopkg.in/yaml.v3 v3.0.1 + k8s.io/api v0.27.2 + k8s.io/apimachinery v0.27.2 + k8s.io/client-go v0.27.2 k8s.io/klog/v2 v2.100.1 - k8s.io/kubectl v0.26.3 - k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 - open-cluster-management.io/api v0.10.1 - sigs.k8s.io/controller-runtime v0.14.6 + k8s.io/kubectl v0.27.2 + k8s.io/utils v0.0.0-20230505201702-9f6742963106 + open-cluster-management.io/api v0.11.0 + sigs.k8s.io/controller-runtime v0.15.0 ) require ( @@ -30,9 +31,9 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/docker/cli v23.0.5+incompatible // indirect + github.com/docker/cli v24.0.0+incompatible // indirect github.com/docker/distribution v2.8.1+incompatible // indirect - github.com/docker/docker v23.0.5+incompatible // indirect + github.com/docker/docker v24.0.0+incompatible // indirect github.com/docker/docker-credential-helpers v0.7.0 // indirect github.com/emicklei/go-restful/v3 v3.10.2 // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect @@ -60,30 +61,28 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc3 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_model v0.3.0 // indirect + github.com/prometheus/client_model v0.4.0 // indirect github.com/prometheus/common v0.42.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect - github.com/rogpeppe/go-internal v1.10.0 // indirect - github.com/sirupsen/logrus v1.9.0 // indirect + github.com/sirupsen/logrus v1.9.1 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/vbatts/tar-split v0.11.3 // indirect golang.org/x/net v0.10.0 // indirect - golang.org/x/oauth2 v0.7.0 // indirect + golang.org/x/oauth2 v0.8.0 // indirect golang.org/x/sync v0.2.0 // indirect golang.org/x/sys v0.8.0 // indirect golang.org/x/term v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.9.1 // indirect - gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect + gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.26.1 // indirect - k8s.io/component-base v0.26.3 // indirect - k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a // indirect + k8s.io/apiextensions-apiserver v0.27.2 // indirect + k8s.io/component-base v0.27.2 // indirect + k8s.io/kube-openapi v0.0.0-20230515203736-54b630e78af5 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect diff --git a/go.sum b/go.sum index fd8826e13..8cf4981e0 100644 --- a/go.sum +++ b/go.sum @@ -27,12 +27,12 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docker/cli v23.0.5+incompatible h1:ufWmAOuD3Vmr7JP2G5K3cyuNC4YZWiAsuDEvFVVDafE= -github.com/docker/cli v23.0.5+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v24.0.0+incompatible h1:0+1VshNwBQzQAx9lOl+OYCTCEAD8fKs/qeXMx3O0wqM= +github.com/docker/cli v24.0.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v23.0.5+incompatible h1:DaxtlTJjFSnLOXVNUBU1+6kXGz2lpDoEAH6QoxaSg8k= -github.com/docker/docker v23.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v24.0.0+incompatible h1:z4bf8HvONXX9Tde5lGBMQ7yCJgNahmJumdrStZAbeY4= +github.com/docker/docker v24.0.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= @@ -44,7 +44,6 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ= github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= @@ -55,7 +54,7 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A= +github.com/go-logr/zapr v1.2.4 h1:QHVo+6stLbfJmYGkQ7uGHUCu5hnAFAj6mDe6Ea0SeOo= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= @@ -76,7 +75,6 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -101,8 +99,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-containerregistry v0.15.2 h1:MMkSh+tjSdnmJZO7ljvEqV1DjfekB6VUEAZgy3a+TQE= github.com/google/go-containerregistry v0.15.2/go.mod h1:wWK+LnOv4jXMM23IT/F1wdYftGWGr47Is8CG+pmHK1Q= -github.com/google/go-containerregistry/pkg/authn/kubernetes v0.0.0-20230316013512-53189d3374b8 h1:5BG1Kx3sezOWZT3G51FQVjh71GWGXklmP0slNSfHaNI= -github.com/google/go-containerregistry/pkg/authn/kubernetes v0.0.0-20230316013512-53189d3374b8/go.mod h1:CSeefFZsOfyNrYGXDafpWNkf3tUz17nKReR5INPRaMI= +github.com/google/go-containerregistry/pkg/authn/kubernetes v0.0.0-20230523181351-c3f8a49229d3 h1:nIN5bfu2AcxNOPIO5tDJALXLpK7j5kr6IkCIHZH48no= +github.com/google/go-containerregistry/pkg/authn/kubernetes v0.0.0-20230523181351-c3f8a49229d3/go.mod h1:5sSbf/SbGGvjWIlMlt2bkEqOq+ufOIBYrBevLuxbfSs= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -162,18 +160,18 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_golang v1.15.1 h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI= github.com/prometheus/client_golang v1.15.1/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/sirupsen/logrus v1.9.1 h1:Ou41VVR3nMWWmTiEUnj0OlsgOSCUFgsPAOl6jRIcVtQ= +github.com/sirupsen/logrus v1.9.1/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= @@ -200,7 +198,7 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -233,8 +231,8 @@ golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= -golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= +golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= +golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -286,8 +284,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gomodules.xyz/jsonpatch/v2 v2.2.0 h1:4pT439QV83L+G9FkcCriY6EkpcK6r6bK+A5FBUMI7qY= -gomodules.xyz/jsonpatch/v2 v2.2.0/go.mod h1:WXp+iVDkoLQqPudfQ9GBlwB2eZ5DKOnjQZCYdOS8GPY= +gomodules.xyz/jsonpatch/v2 v2.3.0 h1:8NFhfS6gzxNqjLIYnZxg319wZ5Qjnx4m/CcX+Klzazc= +gomodules.xyz/jsonpatch/v2 v2.3.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= @@ -337,28 +335,28 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.1.0 h1:rVV8Tcg/8jHUkPUorwjaMTtemIMVXfIPKiOqnhEhakk= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -k8s.io/api v0.26.3 h1:emf74GIQMTik01Aum9dPP0gAypL8JTLl/lHa4V9RFSU= -k8s.io/api v0.26.3/go.mod h1:PXsqwPMXBSBcL1lJ9CYDKy7kIReUydukS5JiRlxC3qE= -k8s.io/apiextensions-apiserver v0.26.1 h1:cB8h1SRk6e/+i3NOrQgSFij1B2S0Y0wDoNl66bn8RMI= -k8s.io/apiextensions-apiserver v0.26.1/go.mod h1:AptjOSXDGuE0JICx/Em15PaoO7buLwTs0dGleIHixSM= -k8s.io/apimachinery v0.27.1 h1:EGuZiLI95UQQcClhanryclaQE6xjg1Bts6/L3cD7zyc= -k8s.io/apimachinery v0.27.1/go.mod h1:5ikh59fK3AJ287GUvpUsryoMFtH9zj/ARfWCo3AyXTM= -k8s.io/client-go v0.26.3 h1:k1UY+KXfkxV2ScEL3gilKcF7761xkYsSD6BC9szIu8s= -k8s.io/client-go v0.26.3/go.mod h1:ZPNu9lm8/dbRIPAgteN30RSXea6vrCpFvq+MateTUuQ= -k8s.io/component-base v0.26.3 h1:oC0WMK/ggcbGDTkdcqefI4wIZRYdK3JySx9/HADpV0g= -k8s.io/component-base v0.26.3/go.mod h1:5kj1kZYwSC6ZstHJN7oHBqcJC6yyn41eR+Sqa/mQc8E= +k8s.io/api v0.27.2 h1:+H17AJpUMvl+clT+BPnKf0E3ksMAzoBBg7CntpSuADo= +k8s.io/api v0.27.2/go.mod h1:ENmbocXfBT2ADujUXcBhHV55RIT31IIEvkntP6vZKS4= +k8s.io/apiextensions-apiserver v0.27.2 h1:iwhyoeS4xj9Y7v8YExhUwbVuBhMr3Q4bd/laClBV6Bo= +k8s.io/apiextensions-apiserver v0.27.2/go.mod h1:Oz9UdvGguL3ULgRdY9QMUzL2RZImotgxvGjdWRq6ZXQ= +k8s.io/apimachinery v0.27.2 h1:vBjGaKKieaIreI+oQwELalVG4d8f3YAMNpWLzDXkxeg= +k8s.io/apimachinery v0.27.2/go.mod h1:XNfZ6xklnMCOGGFNqXG7bUrQCoR04dh/E7FprV6pb+E= +k8s.io/client-go v0.27.2 h1:vDLSeuYvCHKeoQRhCXjxXO45nHVv2Ip4Fe0MfioMrhE= +k8s.io/client-go v0.27.2/go.mod h1:tY0gVmUsHrAmjzHX9zs7eCjxcBsf8IiNe7KQ52biTcQ= +k8s.io/component-base v0.27.2 h1:neju+7s/r5O4x4/txeUONNTS9r1HsPbyoPBAtHsDCpo= +k8s.io/component-base v0.27.2/go.mod h1:5UPk7EjfgrfgRIuDBFtsEFAe4DAvP3U+M8RTzoSJkpo= k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a h1:gmovKNur38vgoWfGtP5QOGNOA7ki4n6qNYoFAgMlNvg= -k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a/go.mod h1:y5VtZWM9sHHc2ZodIH/6SHzXj+TPU5USoA8lcIeKEKY= -k8s.io/kubectl v0.26.3 h1:bZ5SgFyeEXw6XTc1Qji0iNdtqAC76lmeIIQULg2wNXM= -k8s.io/kubectl v0.26.3/go.mod h1:02+gv7Qn4dupzN3fi/9OvqqdW+uG/4Zi56vc4Zmsp1g= -k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 h1:xMMXJlJbsU8w3V5N2FLDQ8YgU8s1EoULdbQBcAeNJkY= -k8s.io/utils v0.0.0-20230313181309-38a27ef9d749/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -open-cluster-management.io/api v0.10.1 h1:/qv1qfIkAVSz6RQmKGehSv6zYI34Xmb8hK7sIUVmduM= -open-cluster-management.io/api v0.10.1/go.mod h1:6BB/Y6r3hXlPjpJgDwIs6Ubxyx/kXXOg6D9Cntg1I9E= -sigs.k8s.io/controller-runtime v0.14.6 h1:oxstGVvXGNnMvY7TAESYk+lzr6S3V5VFxQ6d92KcwQA= -sigs.k8s.io/controller-runtime v0.14.6/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= +k8s.io/kube-openapi v0.0.0-20230515203736-54b630e78af5 h1:azYPdzztXxPSa8wb+hksEKayiz0o+PPisO/d+QhWnoo= +k8s.io/kube-openapi v0.0.0-20230515203736-54b630e78af5/go.mod h1:kzo02I3kQ4BTtEfVLaPbjvCkX97YqGve33wzlb3fofQ= +k8s.io/kubectl v0.27.2 h1:sSBM2j94MHBFRWfHIWtEXWCicViQzZsb177rNsKBhZg= +k8s.io/kubectl v0.27.2/go.mod h1:GCOODtxPcrjh+EC611MqREkU8RjYBh10ldQCQ6zpFKw= +k8s.io/utils v0.0.0-20230505201702-9f6742963106 h1:EObNQ3TW2D+WptiYXlApGNLVy0zm/JIBVY9i+M4wpAU= +k8s.io/utils v0.0.0-20230505201702-9f6742963106/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +open-cluster-management.io/api v0.11.0 h1:zBxa33Co3wseLBF4HEJobhl0P6ygj+Drhe7Wrfo0/h8= +open-cluster-management.io/api v0.11.0/go.mod h1:WgKUCJ7+Bf40DsOmH1Gdkpyj3joco+QLzrlM6Ak39zE= +sigs.k8s.io/controller-runtime v0.15.0 h1:ML+5Adt3qZnMSYxZ7gAverBLNPSMQEibtzAgp0UPojU= +sigs.k8s.io/controller-runtime v0.15.0/go.mod h1:7ngYvp1MLT+9GeZ+6lH3LOlcHkp/+tzA/fmHa4iq9kk= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= diff --git a/internal/client/mock_client.go b/internal/client/mock_client.go index 52273c9b3..ca87c1e36 100644 --- a/internal/client/mock_client.go +++ b/internal/client/mock_client.go @@ -11,6 +11,7 @@ import ( gomock "github.com/golang/mock/gomock" meta "k8s.io/apimachinery/pkg/api/meta" runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" client "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -114,6 +115,36 @@ func (mr *MockClientMockRecorder) Get(arg0, arg1, arg2 interface{}, arg3 ...inte return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockClient)(nil).Get), varargs...) } +// GroupVersionKindFor mocks base method. +func (m *MockClient) GroupVersionKindFor(arg0 runtime.Object) (schema.GroupVersionKind, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GroupVersionKindFor", arg0) + ret0, _ := ret[0].(schema.GroupVersionKind) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GroupVersionKindFor indicates an expected call of GroupVersionKindFor. +func (mr *MockClientMockRecorder) GroupVersionKindFor(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GroupVersionKindFor", reflect.TypeOf((*MockClient)(nil).GroupVersionKindFor), arg0) +} + +// IsObjectNamespaced mocks base method. +func (m *MockClient) IsObjectNamespaced(arg0 runtime.Object) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsObjectNamespaced", arg0) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsObjectNamespaced indicates an expected call of IsObjectNamespaced. +func (mr *MockClientMockRecorder) IsObjectNamespaced(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsObjectNamespaced", reflect.TypeOf((*MockClient)(nil).IsObjectNamespaced), arg0) +} + // List mocks base method. func (m *MockClient) List(arg0 context.Context, arg1 client.ObjectList, arg2 ...client.ListOption) error { m.ctrl.T.Helper() diff --git a/internal/config/config.go b/internal/config/config.go new file mode 100644 index 000000000..836cb59e2 --- /dev/null +++ b/internal/config/config.go @@ -0,0 +1,48 @@ +package config + +import ( + "fmt" + "os" + + "gopkg.in/yaml.v3" + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/webhook" +) + +type LeaderElection struct { + Enabled bool `yaml:"enabled"` + ResourceID string `yaml:"resourceID"` +} + +type Config struct { + HealthProbeBindAddress string `yaml:"healthProbeBindAddress"` + MetricsBindAddress string `yaml:"metricsBindAddress"` + LeaderElection LeaderElection `yaml:"leaderElection"` + WebhookPort int `yaml:"webhookPort"` +} + +func ParseFile(path string) (*Config, error) { + fd, err := os.Open(path) + if err != nil { + return nil, fmt.Errorf("could not open the configuration file: %v", err) + } + defer fd.Close() + + cfg := Config{} + + if err = yaml.NewDecoder(fd).Decode(&cfg); err != nil { + return nil, fmt.Errorf("could not decode configuration file: %v", err) + } + + return &cfg, nil +} + +func (c *Config) ManagerOptions() *manager.Options { + return &manager.Options{ + HealthProbeBindAddress: c.HealthProbeBindAddress, + LeaderElection: c.LeaderElection.Enabled, + LeaderElectionID: c.LeaderElection.ResourceID, + MetricsBindAddress: c.MetricsBindAddress, + WebhookServer: webhook.NewServer(webhook.Options{Port: c.WebhookPort}), + } +} diff --git a/internal/config/config_test.go b/internal/config/config_test.go new file mode 100644 index 000000000..732a4d1ea --- /dev/null +++ b/internal/config/config_test.go @@ -0,0 +1,31 @@ +package config + +import ( + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("ParseFile", func() { + It("should return an error if the file does not exist", func() { + _, err := ParseFile("/non/existent/path") + Expect(err).To(HaveOccurred()) + }) + + It("should parse the file correctly", func() { + expected := &Config{ + HealthProbeBindAddress: ":8081", + MetricsBindAddress: "127.0.0.1:8080", + LeaderElection: LeaderElection{ + Enabled: true, + ResourceID: "some-resource-id", + }, + WebhookPort: 9443, + } + + Expect( + ParseFile("testdata/config.yaml"), + ).To( + Equal(expected), + ) + }) +}) diff --git a/internal/config/suite_test.go b/internal/config/suite_test.go new file mode 100644 index 000000000..23aa89c23 --- /dev/null +++ b/internal/config/suite_test.go @@ -0,0 +1,13 @@ +package config + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestAPIs(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Config Suite") +} diff --git a/internal/config/testdata/config.yaml b/internal/config/testdata/config.yaml new file mode 100644 index 000000000..4a31d9f7f --- /dev/null +++ b/internal/config/testdata/config.yaml @@ -0,0 +1,7 @@ +healthProbeBindAddress: :8081 +metricsBindAddress: 127.0.0.1:8080 +webhookPort: 9443 +leaderElection: + enabled: true + resourceID: some-resource-id + diff --git a/internal/filter/filter.go b/internal/filter/filter.go index d1a8fb07a..0cde7affb 100644 --- a/internal/filter/filter.go +++ b/internal/filter/filter.go @@ -11,6 +11,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/kubectl/pkg/util/podutils" clusterv1 "open-cluster-management.io/api/cluster/v1" + ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" @@ -65,14 +66,10 @@ func clusterClaim(name string, clusterClaims []clusterv1.ManagedClusterClaim) *c type Filter struct { client client.Client - logger logr.Logger } -func New(client client.Client, logger logr.Logger) *Filter { - return &Filter{ - client: client, - logger: logger, - } +func New(client client.Client) *Filter { + return &Filter{client: client} } func (f *Filter) ModuleReconcilerNodePredicate(kernelLabel string) predicate.Predicate { @@ -109,8 +106,8 @@ func NodeUpdateKernelChangedPredicate() predicate.Predicate { } } -func (f *Filter) FindModulesForNode(node client.Object) []reconcile.Request { - logger := f.logger.WithValues("node", node.GetName()) +func (f *Filter) FindModulesForNode(ctx context.Context, node client.Object) []reconcile.Request { + logger := ctrl.LoggerFrom(ctx).WithValues("node", node.GetName()) reqs := make([]reconcile.Request, 0) @@ -162,8 +159,8 @@ func (f *Filter) FindModulesForNode(node client.Object) []reconcile.Request { return reqs } -func (f *Filter) FindManagedClusterModulesForCluster(cluster client.Object) []reconcile.Request { - logger := f.logger.WithValues("managedcluster", cluster.GetName()) +func (f *Filter) FindManagedClusterModulesForCluster(ctx context.Context, cluster client.Object) []reconcile.Request { + logger := ctrl.LoggerFrom(ctx).WithValues("managedcluster", cluster.GetName()) reqs := make([]reconcile.Request, 0) @@ -222,10 +219,10 @@ func (f *Filter) ManagedClusterModuleReconcilerManagedClusterPredicate() predica ) } -func (f *Filter) EnqueueAllPreflightValidations(mod client.Object) []reconcile.Request { +func (f *Filter) EnqueueAllPreflightValidations(ctx context.Context, mod client.Object) []reconcile.Request { reqs := make([]reconcile.Request, 0) - logger := f.logger.WithValues("module", mod.GetName()) + logger := ctrl.LoggerFrom(ctx).WithValues("module", mod.GetName()) logger.Info("Listing all preflights") preflights := kmmv1beta1.PreflightValidationList{} if err := f.client.List(context.Background(), &preflights); err != nil { diff --git a/internal/filter/filter_test.go b/internal/filter/filter_test.go index fb32db6c9..34a327fbe 100644 --- a/internal/filter/filter_test.go +++ b/internal/filter/filter_test.go @@ -3,10 +3,10 @@ package filter import ( "context" + "github.com/go-logr/logr" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/go-logr/logr" "github.com/golang/mock/gomock" appsv1 "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" @@ -25,8 +25,8 @@ import ( ) var ( - ctrl *gomock.Controller - clnt *mockClient.MockClient + mockCtrl *gomock.Controller + clnt *mockClient.MockClient ) var _ = Describe("HasLabel", func() { @@ -114,7 +114,7 @@ var _ = Describe("ModuleReconcilerNodePredicate", func() { var p predicate.Predicate BeforeEach(func() { - p = New(nil, logr.Discard()).ModuleReconcilerNodePredicate(kernelLabel) + p = New(nil).ModuleReconcilerNodePredicate(kernelLabel) }) It("should return true for creations", func() { @@ -196,8 +196,8 @@ var _ = Describe("NodeKernelReconcilerPredicate", func() { var p predicate.Predicate BeforeEach(func() { - ctrl = gomock.NewController(GinkgoT()) - p = New(nil, logr.Discard()).NodeKernelReconcilerPredicate(labelName) + mockCtrl = gomock.NewController(GinkgoT()) + p = New(nil).NodeKernelReconcilerPredicate(labelName) }) It("should return true if the node has no labels", func() { @@ -308,16 +308,18 @@ var _ = Describe("NodeUpdateKernelChangedPredicate", func() { var _ = Describe("FindModulesForNode", func() { BeforeEach(func() { - ctrl = gomock.NewController(GinkgoT()) - clnt = mockClient.NewMockClient(ctrl) + mockCtrl = gomock.NewController(GinkgoT()) + clnt = mockClient.NewMockClient(mockCtrl) }) + ctx := context.Background() + It("should return nothing if there are no modules", func() { clnt.EXPECT().List(context.Background(), gomock.Any(), gomock.Any()) - p := New(clnt, logr.Discard()) + p := New(clnt) Expect( - p.FindModulesForNode(&v1.Node{}), + p.FindModulesForNode(ctx, &v1.Node{}), ).To( BeEmpty(), ) @@ -337,10 +339,10 @@ var _ = Describe("FindModulesForNode", func() { }, ) - p := New(clnt, logr.Discard()) + p := New(clnt) Expect( - p.FindModulesForNode(&v1.Node{}), + p.FindModulesForNode(ctx, &v1.Node{}), ).To( BeEmpty(), ) @@ -373,29 +375,31 @@ var _ = Describe("FindModulesForNode", func() { }, ) - p := New(clnt, logr.Discard()) + p := New(clnt) expectedReq := reconcile.Request{ NamespacedName: types.NamespacedName{Name: mod1Name}, } - reqs := p.FindModulesForNode(&node) + reqs := p.FindModulesForNode(ctx, &node) Expect(reqs).To(Equal([]reconcile.Request{expectedReq})) }) }) var _ = Describe("FindManagedClusterModulesForCluster", func() { BeforeEach(func() { - ctrl = gomock.NewController(GinkgoT()) - clnt = mockClient.NewMockClient(ctrl) + mockCtrl = gomock.NewController(GinkgoT()) + clnt = mockClient.NewMockClient(mockCtrl) }) + ctx := context.Background() + It("should return nothing if there are no ManagedClusterModules", func() { clnt.EXPECT().List(context.Background(), gomock.Any(), gomock.Any()) - p := New(clnt, logr.Discard()) + p := New(clnt) Expect( - p.FindManagedClusterModulesForCluster(&clusterv1.ManagedCluster{}), + p.FindManagedClusterModulesForCluster(ctx, &clusterv1.ManagedCluster{}), ).To( BeEmpty(), ) @@ -415,10 +419,10 @@ var _ = Describe("FindManagedClusterModulesForCluster", func() { }, ) - p := New(clnt, logr.Discard()) + p := New(clnt) Expect( - p.FindManagedClusterModulesForCluster(&clusterv1.ManagedCluster{}), + p.FindManagedClusterModulesForCluster(ctx, &clusterv1.ManagedCluster{}), ).To( BeEmpty(), ) @@ -454,13 +458,13 @@ var _ = Describe("FindManagedClusterModulesForCluster", func() { }, ) - p := New(clnt, logr.Discard()) + p := New(clnt) expectedReq := reconcile.Request{ NamespacedName: types.NamespacedName{Name: matchingMod.Name}, } - reqs := p.FindManagedClusterModulesForCluster(&cluster) + reqs := p.FindManagedClusterModulesForCluster(ctx, &cluster) Expect(reqs).To(Equal([]reconcile.Request{expectedReq})) }) }) @@ -469,7 +473,7 @@ var _ = Describe("ManagedClusterModuleReconcilerManagedClusterPredicate", func() var p predicate.Predicate BeforeEach(func() { - p = New(nil, logr.Discard()).ManagedClusterModuleReconcilerManagedClusterPredicate() + p = New(nil).ManagedClusterModuleReconcilerManagedClusterPredicate() }) It("should return true for creations", func() { @@ -619,16 +623,18 @@ var _ = Describe("PodReadinessChangedPredicate", func() { var _ = Describe("FindPreflightsForModule", func() { BeforeEach(func() { - ctrl = gomock.NewController(GinkgoT()) - clnt = mockClient.NewMockClient(ctrl) + mockCtrl = gomock.NewController(GinkgoT()) + clnt = mockClient.NewMockClient(mockCtrl) }) + ctx := context.Background() + It("no preflight exists", func() { clnt.EXPECT().List(context.Background(), gomock.Any(), gomock.Any()) - p := New(clnt, logr.Discard()) + p := New(clnt) - res := p.EnqueueAllPreflightValidations(&kmmv1beta1.Module{}) + res := p.EnqueueAllPreflightValidations(ctx, &kmmv1beta1.Module{}) Expect(res).To(BeEmpty()) }) @@ -653,8 +659,8 @@ var _ = Describe("FindPreflightsForModule", func() { }, } - p := New(clnt, logr.Discard()) - res := p.EnqueueAllPreflightValidations(&kmmv1beta1.Module{}) + p := New(clnt) + res := p.EnqueueAllPreflightValidations(ctx, &kmmv1beta1.Module{}) Expect(res).To(Equal(expectedRes)) })