diff --git a/Makefile b/Makefile index ca2dfc76e6f..8b1b863a41b 100644 --- a/Makefile +++ b/Makefile @@ -157,7 +157,7 @@ CRD_ROOT ?= $(MANIFEST_ROOT)/crd/bases WEBHOOK_ROOT ?= $(MANIFEST_ROOT)/webhook RBAC_ROOT ?= $(MANIFEST_ROOT)/rbac ASO_CRDS_PATH := $(MANIFEST_ROOT)/aso/crds.yaml -ASO_VERSION := v2.1.0 +ASO_VERSION := v2.2.0 ASO_CRDS := resourcegroups.resources.azure.com # Allow overriding the imagePullPolicy @@ -301,7 +301,7 @@ create-management-cluster: $(KUSTOMIZE) $(ENVSUBST) $(KUBECTL) $(KIND) ## Create ./hack/create-custom-cloud-provider-config.sh # Deploy CAPI - curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.4.5/cluster-api-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f - + curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.5.0/cluster-api-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f - # Deploy CAPZ $(KIND) load docker-image $(CONTROLLER_IMG)-$(ARCH):$(TAG) --name=$(KIND_CLUSTER_NAME) diff --git a/Tiltfile b/Tiltfile index fd5a60273aa..9842d82eac2 100644 --- a/Tiltfile +++ b/Tiltfile @@ -19,7 +19,7 @@ settings = { "deploy_cert_manager": True, "preload_images_for_kind": True, "kind_cluster_name": "capz", - "capi_version": "v1.4.5", + "capi_version": "v1.5.0", "cert_manager_version": "v1.12.2", "kubernetes_version": "v1.27.2", "aks_kubernetes_version": "v1.26.3", diff --git a/api/v1beta1/azurecluster_validation.go b/api/v1beta1/azurecluster_validation.go index 7fcb91396ab..f1f32aa0d33 100644 --- a/api/v1beta1/azurecluster_validation.go +++ b/api/v1beta1/azurecluster_validation.go @@ -28,6 +28,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/utils/ptr" "sigs.k8s.io/cluster-api-provider-azure/feature" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) const ( @@ -68,15 +69,15 @@ var ( ) // validateCluster validates a cluster. -func (c *AzureCluster) validateCluster(old *AzureCluster) error { +func (c *AzureCluster) validateCluster(old *AzureCluster) (admission.Warnings, error) { var allErrs field.ErrorList allErrs = append(allErrs, c.validateClusterName()...) allErrs = append(allErrs, c.validateClusterSpec(old)...) if len(allErrs) == 0 { - return nil + return nil, nil } - return apierrors.NewInvalid( + return nil, apierrors.NewInvalid( schema.GroupKind{Group: "infrastructure.cluster.x-k8s.io", Kind: "AzureCluster"}, c.Name, allErrs) } diff --git a/api/v1beta1/azurecluster_validation_test.go b/api/v1beta1/azurecluster_validation_test.go index aaeb94ad7e5..337dd1d1689 100644 --- a/api/v1beta1/azurecluster_validation_test.go +++ b/api/v1beta1/azurecluster_validation_test.go @@ -115,7 +115,7 @@ func TestClusterWithPreexistingVnetValid(t *testing.T) { } t.Run(testCase.name, func(t *testing.T) { - err := testCase.cluster.validateCluster(nil) + _, err := testCase.cluster.validateCluster(nil) g.Expect(err).To(BeNil()) }) } @@ -142,7 +142,7 @@ func TestClusterWithPreexistingVnetInvalid(t *testing.T) { } t.Run(testCase.name, func(t *testing.T) { - err := testCase.cluster.validateCluster(nil) + _, err := testCase.cluster.validateCluster(nil) g.Expect(err).NotTo(BeNil()) }) } @@ -165,7 +165,7 @@ func TestClusterWithoutPreexistingVnetValid(t *testing.T) { testCase.cluster.Spec.NetworkSpec.Vnet.ResourceGroup = "" t.Run(testCase.name, func(t *testing.T) { - err := testCase.cluster.validateCluster(nil) + _, err := testCase.cluster.validateCluster(nil) g.Expect(err).To(BeNil()) }) } diff --git a/api/v1beta1/azurecluster_webhook.go b/api/v1beta1/azurecluster_webhook.go index f218290643c..8c25f4bf371 100644 --- a/api/v1beta1/azurecluster_webhook.go +++ b/api/v1beta1/azurecluster_webhook.go @@ -25,6 +25,7 @@ import ( webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) // SetupWebhookWithManager sets up and registers the webhook with the manager. @@ -46,12 +47,12 @@ func (c *AzureCluster) Default() { } // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (c *AzureCluster) ValidateCreate() error { +func (c *AzureCluster) ValidateCreate() (admission.Warnings, error) { return c.validateCluster(nil) } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (c *AzureCluster) ValidateUpdate(oldRaw runtime.Object) error { +func (c *AzureCluster) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) { var allErrs field.ErrorList old := oldRaw.(*AzureCluster) @@ -135,7 +136,7 @@ func (c *AzureCluster) ValidateUpdate(oldRaw runtime.Object) error { return c.validateCluster(old) } - return apierrors.NewInvalid(GroupVersion.WithKind("AzureCluster").GroupKind(), c.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureCluster").GroupKind(), c.Name, allErrs) } // validateSubnetUpdate validates a ClusterSpec.NetworkSpec.Subnets for immutability. @@ -187,6 +188,6 @@ func (c *AzureCluster) validateSubnetUpdate(old *AzureCluster) field.ErrorList { } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (c *AzureCluster) ValidateDelete() error { - return nil +func (c *AzureCluster) ValidateDelete() (admission.Warnings, error) { + return nil, nil } diff --git a/api/v1beta1/azurecluster_webhook_test.go b/api/v1beta1/azurecluster_webhook_test.go index d226c43a36d..27ce0534620 100644 --- a/api/v1beta1/azurecluster_webhook_test.go +++ b/api/v1beta1/azurecluster_webhook_test.go @@ -109,7 +109,7 @@ func TestAzureCluster_ValidateCreate(t *testing.T) { } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - err := tc.cluster.ValidateCreate() + _, err := tc.cluster.ValidateCreate() if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -347,7 +347,7 @@ func TestAzureCluster_ValidateUpdate(t *testing.T) { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() - err := tc.cluster.ValidateUpdate(tc.oldCluster) + _, err := tc.cluster.ValidateUpdate(tc.oldCluster) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { diff --git a/api/v1beta1/azureclusteridentity_validation.go b/api/v1beta1/azureclusteridentity_validation.go index 675ad1e5372..508be3ae852 100644 --- a/api/v1beta1/azureclusteridentity_validation.go +++ b/api/v1beta1/azureclusteridentity_validation.go @@ -19,9 +19,10 @@ package v1beta1 import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/util/validation/field" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) -func (c *AzureClusterIdentity) validateClusterIdentity() error { +func (c *AzureClusterIdentity) validateClusterIdentity() (admission.Warnings, error) { var allErrs field.ErrorList if c.Spec.Type == UserAssignedMSI && c.Spec.ResourceID == "" { allErrs = append(allErrs, field.Required(field.NewPath("spec", "resourceID"), c.Spec.ResourceID)) @@ -29,7 +30,7 @@ func (c *AzureClusterIdentity) validateClusterIdentity() error { allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "resourceID"), c.Spec.ResourceID)) } if len(allErrs) == 0 { - return nil + return nil, nil } - return apierrors.NewInvalid(GroupVersion.WithKind("AzureClusterIdentity").GroupKind(), c.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureClusterIdentity").GroupKind(), c.Name, allErrs) } diff --git a/api/v1beta1/azureclusteridentity_webhook.go b/api/v1beta1/azureclusteridentity_webhook.go index 622b4f20d84..45f204b0e6c 100644 --- a/api/v1beta1/azureclusteridentity_webhook.go +++ b/api/v1beta1/azureclusteridentity_webhook.go @@ -23,6 +23,7 @@ import ( webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) // SetupWebhookWithManager sets up and registers the webhook with the manager. @@ -37,12 +38,12 @@ func (c *AzureClusterIdentity) SetupWebhookWithManager(mgr ctrl.Manager) error { var _ webhook.Validator = &AzureClusterIdentity{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (c *AzureClusterIdentity) ValidateCreate() error { +func (c *AzureClusterIdentity) ValidateCreate() (admission.Warnings, error) { return c.validateClusterIdentity() } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (c *AzureClusterIdentity) ValidateUpdate(oldRaw runtime.Object) error { +func (c *AzureClusterIdentity) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) { var allErrs field.ErrorList old := oldRaw.(*AzureClusterIdentity) if err := webhookutils.ValidateImmutable( @@ -54,10 +55,10 @@ func (c *AzureClusterIdentity) ValidateUpdate(oldRaw runtime.Object) error { if len(allErrs) == 0 { return c.validateClusterIdentity() } - return apierrors.NewInvalid(GroupVersion.WithKind("AzureClusterIdentity").GroupKind(), c.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureClusterIdentity").GroupKind(), c.Name, allErrs) } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (c *AzureClusterIdentity) ValidateDelete() error { - return nil +func (c *AzureClusterIdentity) ValidateDelete() (admission.Warnings, error) { + return nil, nil } diff --git a/api/v1beta1/azureclusteridentity_webhook_test.go b/api/v1beta1/azureclusteridentity_webhook_test.go index b4dcae1d494..27cdf9f98db 100644 --- a/api/v1beta1/azureclusteridentity_webhook_test.go +++ b/api/v1beta1/azureclusteridentity_webhook_test.go @@ -84,7 +84,7 @@ func TestAzureClusterIdentity_ValidateCreate(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - err := tc.clusterIdentity.ValidateCreate() + _, err := tc.clusterIdentity.ValidateCreate() if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -165,7 +165,7 @@ func TestAzureClusterIdentity_ValidateUpdate(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - err := tc.clusterIdentity.ValidateUpdate(tc.oldClusterIdentity) + _, err := tc.clusterIdentity.ValidateUpdate(tc.oldClusterIdentity) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { diff --git a/api/v1beta1/azureclustertemplate_validation.go b/api/v1beta1/azureclustertemplate_validation.go index 132eeabcae6..acf8d52dc03 100644 --- a/api/v1beta1/azureclustertemplate_validation.go +++ b/api/v1beta1/azureclustertemplate_validation.go @@ -22,17 +22,18 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/validation/field" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) -func (c *AzureClusterTemplate) validateClusterTemplate() error { +func (c *AzureClusterTemplate) validateClusterTemplate() (admission.Warnings, error) { var allErrs field.ErrorList allErrs = append(allErrs, c.validateClusterTemplateSpec()...) if len(allErrs) == 0 { - return nil + return nil, nil } - return apierrors.NewInvalid( + return nil, apierrors.NewInvalid( schema.GroupKind{Group: "infrastructure.cluster.x-k8s.io", Kind: "AzureClusterTemplate"}, c.Name, allErrs) } diff --git a/api/v1beta1/azureclustertemplate_webhook.go b/api/v1beta1/azureclustertemplate_webhook.go index 61f2b5ac363..a27ec3d35dd 100644 --- a/api/v1beta1/azureclustertemplate_webhook.go +++ b/api/v1beta1/azureclustertemplate_webhook.go @@ -24,6 +24,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) // AzureClusterTemplateImmutableMsg is the message used for errors on fields that are immutable. @@ -49,12 +50,12 @@ func (c *AzureClusterTemplate) Default() { var _ webhook.Validator = &AzureClusterTemplate{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (c *AzureClusterTemplate) ValidateCreate() error { +func (c *AzureClusterTemplate) ValidateCreate() (admission.Warnings, error) { return c.validateClusterTemplate() } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (c *AzureClusterTemplate) ValidateUpdate(oldRaw runtime.Object) error { +func (c *AzureClusterTemplate) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) { var allErrs field.ErrorList old := oldRaw.(*AzureClusterTemplate) if !reflect.DeepEqual(c.Spec.Template.Spec, old.Spec.Template.Spec) { @@ -64,12 +65,12 @@ func (c *AzureClusterTemplate) ValidateUpdate(oldRaw runtime.Object) error { } if len(allErrs) == 0 { - return nil + return nil, nil } - return apierrors.NewInvalid(GroupVersion.WithKind("AzureClusterTemplate").GroupKind(), c.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureClusterTemplate").GroupKind(), c.Name, allErrs) } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (c *AzureClusterTemplate) ValidateDelete() error { - return nil +func (c *AzureClusterTemplate) ValidateDelete() (admission.Warnings, error) { + return nil, nil } diff --git a/api/v1beta1/azureclustertemplate_webhook_test.go b/api/v1beta1/azureclustertemplate_webhook_test.go index dddc479c1d0..4358c1d1cdc 100644 --- a/api/v1beta1/azureclustertemplate_webhook_test.go +++ b/api/v1beta1/azureclustertemplate_webhook_test.go @@ -57,6 +57,7 @@ func TestValidateUpdate(t *testing.T) { t.Run("template is immutable", func(t *testing.T) { g := NewWithT(t) - g.Expect(newClusterTemplate.ValidateUpdate(oldClusterTemplate)).NotTo(Succeed()) + _, err := newClusterTemplate.ValidateUpdate(oldClusterTemplate) + g.Expect(err).To(HaveOccurred()) }) } diff --git a/api/v1beta1/azuremachine_webhook.go b/api/v1beta1/azuremachine_webhook.go index 8082ddec352..aa16fed2d09 100644 --- a/api/v1beta1/azuremachine_webhook.go +++ b/api/v1beta1/azuremachine_webhook.go @@ -26,6 +26,7 @@ import ( webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) // SetupAzureMachineWebhookWithManager sets up and registers the webhook with the manager. @@ -47,10 +48,10 @@ type azureMachineWebhook struct { } // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureMachineWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) error { +func (mw *azureMachineWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { m, ok := obj.(*AzureMachine) if !ok { - return apierrors.NewBadRequest("expected an AzureMachine resource") + return nil, apierrors.NewBadRequest("expected an AzureMachine resource") } spec := m.Spec @@ -66,22 +67,22 @@ func (mw *azureMachineWebhook) ValidateCreate(ctx context.Context, obj runtime.O } if len(allErrs) == 0 { - return nil + return nil, nil } - return apierrors.NewInvalid(GroupVersion.WithKind("AzureMachine").GroupKind(), m.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureMachine").GroupKind(), m.Name, allErrs) } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureMachineWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) error { +func (mw *azureMachineWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { var allErrs field.ErrorList old, ok := oldObj.(*AzureMachine) if !ok { - return apierrors.NewBadRequest("expected an AzureMachine resource") + return nil, apierrors.NewBadRequest("expected an AzureMachine resource") } m, ok := newObj.(*AzureMachine) if !ok { - return apierrors.NewBadRequest("expected an AzureMachine resource") + return nil, apierrors.NewBadRequest("expected an AzureMachine resource") } if err := webhookutils.ValidateImmutable( @@ -206,14 +207,14 @@ func (mw *azureMachineWebhook) ValidateUpdate(ctx context.Context, oldObj, newOb } if len(allErrs) == 0 { - return nil + return nil, nil } - return apierrors.NewInvalid(GroupVersion.WithKind("AzureMachine").GroupKind(), m.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureMachine").GroupKind(), m.Name, allErrs) } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureMachineWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) error { - return nil +func (mw *azureMachineWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { + return nil, nil } // Default implements webhook.Defaulter so a webhook will be registered for the type. diff --git a/api/v1beta1/azuremachine_webhook_test.go b/api/v1beta1/azuremachine_webhook_test.go index a8dcdb02470..db1471c885d 100644 --- a/api/v1beta1/azuremachine_webhook_test.go +++ b/api/v1beta1/azuremachine_webhook_test.go @@ -221,7 +221,7 @@ func TestAzureMachine_ValidateCreate(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { mw := &azureMachineWebhook{} - err := mw.ValidateCreate(context.Background(), tc.machine) + _, err := mw.ValidateCreate(context.Background(), tc.machine) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -798,7 +798,7 @@ func TestAzureMachine_ValidateUpdate(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { mw := &azureMachineWebhook{} - err := mw.ValidateUpdate(context.Background(), tc.oldMachine, tc.newMachine) + _, err := mw.ValidateUpdate(context.Background(), tc.oldMachine, tc.newMachine) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { diff --git a/api/v1beta1/azuremachinetemplate_webhook.go b/api/v1beta1/azuremachinetemplate_webhook.go index f69c28c45bd..bb0bcd5872f 100644 --- a/api/v1beta1/azuremachinetemplate_webhook.go +++ b/api/v1beta1/azuremachinetemplate_webhook.go @@ -53,7 +53,7 @@ var _ webhook.CustomDefaulter = &AzureMachineTemplate{} var _ webhook.CustomValidator = &AzureMachineTemplate{} // ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type. -func (r *AzureMachineTemplate) ValidateCreate(ctx context.Context, obj runtime.Object) error { +func (r *AzureMachineTemplate) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { t := obj.(*AzureMachineTemplate) spec := t.Spec.Template.Spec @@ -86,21 +86,21 @@ func (r *AzureMachineTemplate) ValidateCreate(ctx context.Context, obj runtime.O } if len(allErrs) == 0 { - return nil + return nil, nil } - return apierrors.NewInvalid(GroupVersion.WithKind("AzureMachineTemplate").GroupKind(), t.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureMachineTemplate").GroupKind(), t.Name, allErrs) } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (r *AzureMachineTemplate) ValidateUpdate(ctx context.Context, oldRaw runtime.Object, newRaw runtime.Object) error { +func (r *AzureMachineTemplate) ValidateUpdate(ctx context.Context, oldRaw runtime.Object, newRaw runtime.Object) (admission.Warnings, error) { var allErrs field.ErrorList old := oldRaw.(*AzureMachineTemplate) t := newRaw.(*AzureMachineTemplate) req, err := admission.RequestFromContext(ctx) if err != nil { - return apierrors.NewBadRequest(fmt.Sprintf("expected a admission.Request inside context: %v", err)) + return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a admission.Request inside context: %v", err)) } if !topology.ShouldSkipImmutabilityChecks(req, t) && @@ -131,14 +131,14 @@ func (r *AzureMachineTemplate) ValidateUpdate(ctx context.Context, oldRaw runtim } if len(allErrs) == 0 { - return nil + return nil, nil } - return apierrors.NewInvalid(GroupVersion.WithKind("AzureMachineTemplate").GroupKind(), t.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureMachineTemplate").GroupKind(), t.Name, allErrs) } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (r *AzureMachineTemplate) ValidateDelete(ctx context.Context, obj runtime.Object) error { - return nil +func (r *AzureMachineTemplate) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { + return nil, nil } // Default implements webhookutil.defaulter so a webhook will be registered for the type. diff --git a/api/v1beta1/azuremachinetemplate_webhook_test.go b/api/v1beta1/azuremachinetemplate_webhook_test.go index fdd73c95f85..258ea549776 100644 --- a/api/v1beta1/azuremachinetemplate_webhook_test.go +++ b/api/v1beta1/azuremachinetemplate_webhook_test.go @@ -241,7 +241,7 @@ func TestAzureMachineTemplate_ValidateCreate(t *testing.T) { t.Run(test.name, func(t *testing.T) { t.Parallel() ctx := context.Background() - err := test.machineTemplate.ValidateCreate(ctx, test.machineTemplate) + _, err := test.machineTemplate.ValidateCreate(ctx, test.machineTemplate) if test.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -588,7 +588,7 @@ func TestAzureMachineTemplate_ValidateUpdate(t *testing.T) { amt := amt t.Run(amt.name, func(t *testing.T) { ctx := admission.NewContextWithRequest(context.Background(), admission.Request{AdmissionRequest: admissionv1.AdmissionRequest{DryRun: ptr.To(true)}}) - err := amt.template.ValidateUpdate(ctx, amt.oldTemplate, amt.template) + _, err := amt.template.ValidateUpdate(ctx, amt.oldTemplate, amt.template) if amt.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -602,7 +602,7 @@ func TestAzureMachineTemplate_ValidateUpdate(t *testing.T) { t.Run(amt.name, func(t *testing.T) { t.Parallel() ctx := admission.NewContextWithRequest(context.Background(), admission.Request{AdmissionRequest: admissionv1.AdmissionRequest{DryRun: ptr.To(false)}}) - err := amt.template.ValidateUpdate(ctx, amt.oldTemplate, amt.template) + _, err := amt.template.ValidateUpdate(ctx, amt.oldTemplate, amt.template) if amt.wantErr { g.Expect(err).To(HaveOccurred()) } else { diff --git a/api/v1beta1/azuremanagedcluster_webhook.go b/api/v1beta1/azuremanagedcluster_webhook.go index a6d51588cbb..bad6c24d4cd 100644 --- a/api/v1beta1/azuremanagedcluster_webhook.go +++ b/api/v1beta1/azuremanagedcluster_webhook.go @@ -28,6 +28,7 @@ import ( capifeature "sigs.k8s.io/cluster-api/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) // SetupWebhookWithManager sets up and registers the webhook with the manager. @@ -42,20 +43,20 @@ func (r *AzureManagedCluster) SetupWebhookWithManager(mgr ctrl.Manager) error { var _ webhook.Validator = &AzureManagedCluster{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (r *AzureManagedCluster) ValidateCreate() error { +func (r *AzureManagedCluster) ValidateCreate() (admission.Warnings, error) { // NOTE: AzureManagedCluster relies upon MachinePools, which is behind a feature gate flag. // The webhook must prevent creating new objects in case the feature flag is disabled. if !feature.Gates.Enabled(capifeature.MachinePool) { - return field.Forbidden( + return nil, field.Forbidden( field.NewPath("spec"), "can be set only if the Cluster API 'MachinePool' feature flag is enabled", ) } - return nil + return nil, nil } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (r *AzureManagedCluster) ValidateUpdate(oldRaw runtime.Object) error { +func (r *AzureManagedCluster) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) { old := oldRaw.(*AzureManagedCluster) var allErrs field.ErrorList @@ -71,13 +72,13 @@ func (r *AzureManagedCluster) ValidateUpdate(oldRaw runtime.Object) error { } if len(allErrs) != 0 { - return apierrors.NewInvalid(GroupVersion.WithKind("AzureManagedCluster").GroupKind(), r.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureManagedCluster").GroupKind(), r.Name, allErrs) } - return nil + return nil, nil } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (r *AzureManagedCluster) ValidateDelete() error { - return nil +func (r *AzureManagedCluster) ValidateDelete() (admission.Warnings, error) { + return nil, nil } diff --git a/api/v1beta1/azuremanagedcluster_webhook_test.go b/api/v1beta1/azuremanagedcluster_webhook_test.go index 1298bf8f18a..c9233ff4859 100644 --- a/api/v1beta1/azuremanagedcluster_webhook_test.go +++ b/api/v1beta1/azuremanagedcluster_webhook_test.go @@ -166,7 +166,7 @@ func TestAzureManagedCluster_ValidateUpdate(t *testing.T) { } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - err := tc.amc.ValidateUpdate(tc.oldAMC) + _, err := tc.amc.ValidateUpdate(tc.oldAMC) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -214,7 +214,7 @@ func TestAzureManagedCluster_ValidateCreate(t *testing.T) { } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - err := tc.amc.ValidateCreate() + _, err := tc.amc.ValidateCreate() if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -246,7 +246,7 @@ func TestAzureManagedCluster_ValidateCreateFailure(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { defer tc.deferFunc() - err := tc.amc.ValidateCreate() + _, err := tc.amc.ValidateCreate() g.Expect(err).To(HaveOccurred()) }) } diff --git a/api/v1beta1/azuremanagedcontrolplane_webhook.go b/api/v1beta1/azuremanagedcontrolplane_webhook.go index 0006dc70084..414abffd252 100644 --- a/api/v1beta1/azuremanagedcontrolplane_webhook.go +++ b/api/v1beta1/azuremanagedcontrolplane_webhook.go @@ -38,6 +38,7 @@ import ( capifeature "sigs.k8s.io/cluster-api/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) var ( @@ -107,33 +108,33 @@ func (mw *azureManagedControlPlaneWebhook) Default(ctx context.Context, obj runt // +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azuremanagedcontrolplane,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azuremanagedcontrolplanes,versions=v1beta1,name=validation.azuremanagedcontrolplanes.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureManagedControlPlaneWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) error { +func (mw *azureManagedControlPlaneWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { m, ok := obj.(*AzureManagedControlPlane) if !ok { - return apierrors.NewBadRequest("expected an AzureManagedControlPlane") + return nil, apierrors.NewBadRequest("expected an AzureManagedControlPlane") } // NOTE: AzureManagedControlPlane relies upon MachinePools, which is behind a feature gate flag. // The webhook must prevent creating new objects in case the feature flag is disabled. if !feature.Gates.Enabled(capifeature.MachinePool) { - return field.Forbidden( + return nil, field.Forbidden( field.NewPath("spec"), "can be set only if the Cluster API 'MachinePool' feature flag is enabled", ) } - return m.Validate(mw.Client) + return nil, m.Validate(mw.Client) } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureManagedControlPlaneWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) error { +func (mw *azureManagedControlPlaneWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { var allErrs field.ErrorList old, ok := oldObj.(*AzureManagedControlPlane) if !ok { - return apierrors.NewBadRequest("expected an AzureManagedControlPlane") + return nil, apierrors.NewBadRequest("expected an AzureManagedControlPlane") } m, ok := newObj.(*AzureManagedControlPlane) if !ok { - return apierrors.NewBadRequest("expected an AzureManagedControlPlane") + return nil, apierrors.NewBadRequest("expected an AzureManagedControlPlane") } if err := webhookutils.ValidateImmutable( @@ -250,15 +251,15 @@ func (mw *azureManagedControlPlaneWebhook) ValidateUpdate(ctx context.Context, o } if len(allErrs) == 0 { - return m.Validate(mw.Client) + return nil, m.Validate(mw.Client) } - return apierrors.NewInvalid(GroupVersion.WithKind("AzureManagedControlPlane").GroupKind(), m.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureManagedControlPlane").GroupKind(), m.Name, allErrs) } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureManagedControlPlaneWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) error { - return nil +func (mw *azureManagedControlPlaneWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { + return nil, nil } // Validate the Azure Managed Control Plane and return an aggregate error. diff --git a/api/v1beta1/azuremanagedcontrolplane_webhook_test.go b/api/v1beta1/azuremanagedcontrolplane_webhook_test.go index 1d1bae9e1ee..66a134bf0fc 100644 --- a/api/v1beta1/azuremanagedcontrolplane_webhook_test.go +++ b/api/v1beta1/azuremanagedcontrolplane_webhook_test.go @@ -672,10 +672,11 @@ func TestValidatingWebhook(t *testing.T) { mcpw := &azureManagedControlPlaneWebhook{ Client: client, } + _, err := mcpw.ValidateCreate(context.Background(), &tt.amcp) if tt.expectErr { - g.Expect(mcpw.ValidateCreate(context.Background(), &tt.amcp)).NotTo(Succeed()) + g.Expect(err).To(HaveOccurred()) } else { - g.Expect(mcpw.ValidateCreate(context.Background(), &tt.amcp)).To(Succeed()) + g.Expect(err).NotTo(HaveOccurred()) } }) } @@ -805,7 +806,7 @@ func TestAzureManagedControlPlane_ValidateCreate(t *testing.T) { mcpw := &azureManagedControlPlaneWebhook{ Client: client, } - err := mcpw.ValidateCreate(context.Background(), tc.amcp) + _, err := mcpw.ValidateCreate(context.Background(), tc.amcp) if tc.wantErr { g.Expect(err).To(HaveOccurred()) if tc.errorLen > 0 { @@ -844,7 +845,7 @@ func TestAzureManagedControlPlane_ValidateCreateFailure(t *testing.T) { mcpw := &azureManagedControlPlaneWebhook{ Client: client, } - err := mcpw.ValidateCreate(context.Background(), tc.amcp) + _, err := mcpw.ValidateCreate(context.Background(), tc.amcp) g.Expect(err).To(HaveOccurred()) }) } @@ -1393,7 +1394,7 @@ func TestAzureManagedControlPlane_ValidateUpdate(t *testing.T) { mcpw := &azureManagedControlPlaneWebhook{ Client: client, } - err := mcpw.ValidateUpdate(context.Background(), tc.oldAMCP, tc.amcp) + _, err := mcpw.ValidateUpdate(context.Background(), tc.oldAMCP, tc.amcp) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { diff --git a/api/v1beta1/azuremanagedmachinepool_webhook.go b/api/v1beta1/azuremanagedmachinepool_webhook.go index a39a818bddc..86be164f2aa 100644 --- a/api/v1beta1/azuremanagedmachinepool_webhook.go +++ b/api/v1beta1/azuremanagedmachinepool_webhook.go @@ -38,6 +38,7 @@ import ( capifeature "sigs.k8s.io/cluster-api/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) var validNodePublicPrefixID = regexp.MustCompile(`(?i)^/?subscriptions/[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}/resourcegroups/[^/]+/providers/microsoft\.network/publicipprefixes/[^/]+$`) @@ -84,15 +85,15 @@ func (mw *azureManagedMachinePoolWebhook) Default(ctx context.Context, obj runti //+kubebuilder:webhook:verbs=create;update;delete,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azuremanagedmachinepool,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=azuremanagedmachinepools,versions=v1beta1,name=validation.azuremanagedmachinepools.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureManagedMachinePoolWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) error { +func (mw *azureManagedMachinePoolWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { m, ok := obj.(*AzureManagedMachinePool) if !ok { - return apierrors.NewBadRequest("expected an AzureManagedMachinePool") + return nil, apierrors.NewBadRequest("expected an AzureManagedMachinePool") } // NOTE: AzureManagedMachinePool relies upon MachinePools, which is behind a feature gate flag. // The webhook must prevent creating new objects in case the feature flag is disabled. if !feature.Gates.Enabled(capifeature.MachinePool) { - return field.Forbidden( + return nil, field.Forbidden( field.NewPath("spec"), "can be set only if the Cluster API 'MachinePool' feature flag is enabled", ) @@ -116,18 +117,18 @@ func (mw *azureManagedMachinePoolWebhook) ValidateCreate(ctx context.Context, ob } } - return kerrors.NewAggregate(errs) + return nil, kerrors.NewAggregate(errs) } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureManagedMachinePoolWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) error { +func (mw *azureManagedMachinePoolWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { old, ok := oldObj.(*AzureManagedMachinePool) if !ok { - return apierrors.NewBadRequest("expected an AzureManagedMachinePool") + return nil, apierrors.NewBadRequest("expected an AzureManagedMachinePool") } m, ok := newObj.(*AzureManagedMachinePool) if !ok { - return apierrors.NewBadRequest("expected an AzureManagedMachinePool") + return nil, apierrors.NewBadRequest("expected an AzureManagedMachinePool") } var allErrs field.ErrorList @@ -271,23 +272,23 @@ func (mw *azureManagedMachinePoolWebhook) ValidateUpdate(ctx context.Context, ol } if len(allErrs) != 0 { - return apierrors.NewInvalid(GroupVersion.WithKind("AzureManagedMachinePool").GroupKind(), m.Name, allErrs) + return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureManagedMachinePool").GroupKind(), m.Name, allErrs) } - return nil + return nil, nil } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureManagedMachinePoolWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) error { +func (mw *azureManagedMachinePoolWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { m, ok := obj.(*AzureManagedMachinePool) if !ok { - return apierrors.NewBadRequest("expected an AzureManagedMachinePool") + return nil, apierrors.NewBadRequest("expected an AzureManagedMachinePool") } if m.Spec.Mode != string(NodePoolModeSystem) { - return nil + return nil, nil } - return errors.Wrapf(m.validateLastSystemNodePool(mw.Client), "if the delete is triggered via owner MachinePool please refer to trouble shooting section in https://capz.sigs.k8s.io/topics/managedcluster.html") + return nil, errors.Wrapf(m.validateLastSystemNodePool(mw.Client), "if the delete is triggered via owner MachinePool please refer to trouble shooting section in https://capz.sigs.k8s.io/topics/managedcluster.html") } // validateLastSystemNodePool is used to check if the existing system node pool is the last system node pool. diff --git a/api/v1beta1/azuremanagedmachinepool_webhook_test.go b/api/v1beta1/azuremanagedmachinepool_webhook_test.go index 231534c3243..bcbed6a3f53 100644 --- a/api/v1beta1/azuremanagedmachinepool_webhook_test.go +++ b/api/v1beta1/azuremanagedmachinepool_webhook_test.go @@ -608,7 +608,7 @@ func TestAzureManagedMachinePoolUpdatingWebhook(t *testing.T) { mw := &azureManagedMachinePoolWebhook{ Client: client, } - err := mw.ValidateUpdate(context.Background(), tc.old, tc.new) + _, err := mw.ValidateUpdate(context.Background(), tc.old, tc.new) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -1163,7 +1163,7 @@ func TestAzureManagedMachinePool_ValidateCreate(t *testing.T) { mw := &azureManagedMachinePoolWebhook{ Client: client, } - err := mw.ValidateCreate(context.Background(), tc.ammp) + _, err := mw.ValidateCreate(context.Background(), tc.ammp) if tc.wantErr { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(HaveLen(tc.errorLen)) @@ -1197,7 +1197,7 @@ func TestAzureManagedMachinePool_ValidateCreateFailure(t *testing.T) { t.Run(tc.name, func(t *testing.T) { defer tc.deferFunc() mw := &azureManagedMachinePoolWebhook{} - err := mw.ValidateCreate(context.Background(), tc.ammp) + _, err := mw.ValidateCreate(context.Background(), tc.ammp) g.Expect(err).To(HaveOccurred()) }) } @@ -1205,6 +1205,7 @@ func TestAzureManagedMachinePool_ValidateCreateFailure(t *testing.T) { func TestAzureManagedMachinePool_validateLastSystemNodePool(t *testing.T) { deletionTime := metav1.Now() + finalizers := []string{"test"} systemMachinePool := getManagedMachinePoolWithSystemMode() tests := []struct { name string @@ -1220,6 +1221,7 @@ func TestAzureManagedMachinePool_validateLastSystemNodePool(t *testing.T) { Name: systemMachinePool.GetLabels()[clusterv1.ClusterNameLabel], Namespace: systemMachinePool.Namespace, DeletionTimestamp: &deletionTime, + Finalizers: finalizers, }, Spec: clusterv1.ClusterSpec{ Paused: true, @@ -1235,6 +1237,7 @@ func TestAzureManagedMachinePool_validateLastSystemNodePool(t *testing.T) { Name: systemMachinePool.GetLabels()[clusterv1.ClusterNameLabel], Namespace: systemMachinePool.Namespace, DeletionTimestamp: &deletionTime, + Finalizers: finalizers, }, Spec: clusterv1.ClusterSpec{ Paused: true, @@ -1261,6 +1264,7 @@ func TestAzureManagedMachinePool_validateLastSystemNodePool(t *testing.T) { Name: systemMachinePool.GetLabels()[clusterv1.ClusterNameLabel], Namespace: systemMachinePool.Namespace, DeletionTimestamp: &deletionTime, + Finalizers: finalizers, }, }, wantErr: false, diff --git a/azure/scope/managedcontrolplane.go b/azure/scope/managedcontrolplane.go index 984b23148a6..6f3ced3381b 100644 --- a/azure/scope/managedcontrolplane.go +++ b/azure/scope/managedcontrolplane.go @@ -613,6 +613,7 @@ func (s *ManagedControlPlaneScope) MakeEmptyKubeConfigSecret() corev1.Secret { OwnerReferences: []metav1.OwnerReference{ *metav1.NewControllerRef(s.ControlPlane, infrav1.GroupVersion.WithKind("AzureManagedControlPlane")), }, + Labels: map[string]string{clusterv1.ClusterNameLabel: s.Cluster.Name}, }, } } diff --git a/config/aso/crds.yaml b/config/aso/crds.yaml index 79a57000285..fa21541e7ac 100644 --- a/config/aso/crds.yaml +++ b/config/aso/crds.yaml @@ -5,7 +5,7 @@ metadata: cert-manager.io/inject-ca-from: azureserviceoperator-system/azureserviceoperator-serving-cert controller-gen.kubebuilder.io/version: v0.11.3 labels: - serviceoperator.azure.com/version: v2.1.0 + serviceoperator.azure.com/version: v2.2.0 name: resourcegroups.resources.azure.com spec: conversion: diff --git a/config/aso/kustomization.yaml b/config/aso/kustomization.yaml index ae944fa8f6c..282ef7a9f02 100644 --- a/config/aso/kustomization.yaml +++ b/config/aso/kustomization.yaml @@ -2,7 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component namespace: capz-system resources: -- https://github.com/Azure/azure-service-operator/releases/download/v2.1.0/azureserviceoperator_v2.1.0.yaml +- https://github.com/Azure/azure-service-operator/releases/download/v2.2.0/azureserviceoperator_v2.2.0.yaml - crds.yaml - credentials.yaml diff --git a/controllers/asosecret_controller.go b/controllers/asosecret_controller.go index a3a2c145d1c..ac6ef75f55b 100644 --- a/controllers/asosecret_controller.go +++ b/controllers/asosecret_controller.go @@ -75,7 +75,7 @@ func (asos *ASOSecretReconciler) SetupWithManager(ctx context.Context, mgr ctrl. // Add a watch on infrav1.AzureManagedControlPlane. if err = c.Watch( - &source.Kind{Type: &infrav1.AzureManagedControlPlane{}}, + source.Kind(mgr.GetCache(), &infrav1.AzureManagedControlPlane{}), &handler.EnqueueRequestForObject{}, predicates.ResourceNotPausedAndHasFilterLabel(log, asos.WatchFilterValue), ); err != nil { @@ -84,18 +84,15 @@ func (asos *ASOSecretReconciler) SetupWithManager(ctx context.Context, mgr ctrl. // Add a watch on ASO secrets owned by an AzureManagedControlPlane if err = c.Watch( - &source.Kind{Type: &corev1.Secret{}}, - &handler.EnqueueRequestForOwner{ - OwnerType: &infrav1.AzureManagedControlPlane{}, - IsController: true, - }, + source.Kind(mgr.GetCache(), &corev1.Secret{}), + handler.EnqueueRequestForOwner(asos.Scheme(), asos.RESTMapper(), &infrav1.AzureManagedControlPlane{}, handler.OnlyControllerOwner()), ); err != nil { return errors.Wrap(err, "failed adding a watch for secrets") } // Add a watch on clusterv1.Cluster object for unpause notifications. if err = c.Watch( - &source.Kind{Type: &clusterv1.Cluster{}}, + source.Kind(mgr.GetCache(), &clusterv1.Cluster{}), handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("AzureCluster"), mgr.GetClient(), &infrav1.AzureCluster{})), predicates.ClusterUnpaused(log), predicates.ResourceNotPausedAndHasFilterLabel(log, asos.WatchFilterValue), diff --git a/controllers/azurecluster_controller.go b/controllers/azurecluster_controller.go index 8650954a36b..0b357ef07e6 100644 --- a/controllers/azurecluster_controller.go +++ b/controllers/azurecluster_controller.go @@ -94,7 +94,7 @@ func (acr *AzureClusterReconciler) SetupWithManager(ctx context.Context, mgr ctr // Add a watch on clusterv1.Cluster object for pause/unpause notifications. if err = c.Watch( - &source.Kind{Type: &clusterv1.Cluster{}}, + source.Kind(mgr.GetCache(), &clusterv1.Cluster{}), handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("AzureCluster"), mgr.GetClient(), &infrav1.AzureCluster{})), ClusterUpdatePauseChange(log), predicates.ResourceHasFilterLabel(log, acr.WatchFilterValue), diff --git a/controllers/azureidentity_controller.go b/controllers/azureidentity_controller.go index c8bc0dba4d7..b813c5ed22f 100644 --- a/controllers/azureidentity_controller.go +++ b/controllers/azureidentity_controller.go @@ -73,7 +73,7 @@ func (r *AzureIdentityReconciler) SetupWithManager(ctx context.Context, mgr ctrl // Add a watch on infrav1.AzureManagedControlPlane if Cluster API 'MachinePool' feature is enabled. if feature.Gates.Enabled(capifeature.MachinePool) { if err = c.Watch( - &source.Kind{Type: &infrav1.AzureManagedControlPlane{}}, + source.Kind(mgr.GetCache(), &infrav1.AzureManagedControlPlane{}), &handler.EnqueueRequestForObject{}, predicates.ResourceNotPausedAndHasFilterLabel(log, r.WatchFilterValue), ); err != nil { @@ -83,7 +83,7 @@ func (r *AzureIdentityReconciler) SetupWithManager(ctx context.Context, mgr ctrl // Add a watch on clusterv1.Cluster object for unpause notifications. if err = c.Watch( - &source.Kind{Type: &clusterv1.Cluster{}}, + source.Kind(mgr.GetCache(), &clusterv1.Cluster{}), handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("AzureCluster"), mgr.GetClient(), &infrav1.AzureCluster{})), predicates.ClusterUnpaused(log), predicates.ResourceNotPausedAndHasFilterLabel(log, r.WatchFilterValue), diff --git a/controllers/azurejson_machine_controller.go b/controllers/azurejson_machine_controller.go index 9449f1abc9a..880727d2caa 100644 --- a/controllers/azurejson_machine_controller.go +++ b/controllers/azurejson_machine_controller.go @@ -63,7 +63,7 @@ func (r *AzureJSONMachineReconciler) SetupWithManager(ctx context.Context, mgr c ) defer done() - azureMachineMapper, err := util.ClusterToObjectsMapper(r.Client, &infrav1.AzureMachineList{}, mgr.GetScheme()) + azureMachineMapper, err := util.ClusterToTypedObjectsMapper(r.Client, &infrav1.AzureMachineList{}, mgr.GetScheme()) if err != nil { return errors.Wrap(err, "failed to create mapper for Cluster to AzureMachines") } @@ -83,7 +83,7 @@ func (r *AzureJSONMachineReconciler) SetupWithManager(ctx context.Context, mgr c // Add a watch on Clusters to requeue when the infraRef is set. This is needed because the infraRef is not initially // set in Clusters created from a ClusterClass. if err := c.Watch( - &source.Kind{Type: &clusterv1.Cluster{}}, + source.Kind(mgr.GetCache(), &clusterv1.Cluster{}), handler.EnqueueRequestsFromMapFunc(azureMachineMapper), predicates.ClusterUnpausedAndInfrastructureReady(log), predicates.ResourceNotPausedAndHasFilterLabel(log, r.WatchFilterValue), diff --git a/controllers/azurejson_machinepool_controller.go b/controllers/azurejson_machinepool_controller.go index 1e2d0d80257..d94c95f084b 100644 --- a/controllers/azurejson_machinepool_controller.go +++ b/controllers/azurejson_machinepool_controller.go @@ -60,7 +60,7 @@ func (r *AzureJSONMachinePoolReconciler) SetupWithManager(ctx context.Context, m ) defer done() - azureMachinePoolMapper, err := util.ClusterToObjectsMapper(r.Client, &infrav1exp.AzureMachinePoolList{}, mgr.GetScheme()) + azureMachinePoolMapper, err := util.ClusterToTypedObjectsMapper(r.Client, &infrav1exp.AzureMachinePoolList{}, mgr.GetScheme()) if err != nil { return errors.Wrap(err, "failed to create mapper for Cluster to AzureMachinePools") } @@ -79,7 +79,7 @@ func (r *AzureJSONMachinePoolReconciler) SetupWithManager(ctx context.Context, m // Add a watch on Clusters to requeue when the infraRef is set. This is needed because the infraRef is not initially // set in Clusters created from a ClusterClass. if err := c.Watch( - &source.Kind{Type: &clusterv1.Cluster{}}, + source.Kind(mgr.GetCache(), &clusterv1.Cluster{}), handler.EnqueueRequestsFromMapFunc(azureMachinePoolMapper), predicates.ClusterUnpausedAndInfrastructureReady(log), predicates.ResourceNotPausedAndHasFilterLabel(log, r.WatchFilterValue), diff --git a/controllers/azurejson_machinetemplate_controller.go b/controllers/azurejson_machinetemplate_controller.go index 5c0678f1f12..90675cdd5ea 100644 --- a/controllers/azurejson_machinetemplate_controller.go +++ b/controllers/azurejson_machinetemplate_controller.go @@ -60,7 +60,7 @@ func (r *AzureJSONTemplateReconciler) SetupWithManager(ctx context.Context, mgr ) defer done() - azureMachineTemplateMapper, err := util.ClusterToObjectsMapper(r.Client, &infrav1.AzureMachineTemplateList{}, mgr.GetScheme()) + azureMachineTemplateMapper, err := util.ClusterToTypedObjectsMapper(r.Client, &infrav1.AzureMachineTemplateList{}, mgr.GetScheme()) if err != nil { return errors.Wrap(err, "failed to create mapper for Cluster to AzureMachineTemplates") } @@ -79,7 +79,7 @@ func (r *AzureJSONTemplateReconciler) SetupWithManager(ctx context.Context, mgr // Add a watch on Clusters to requeue when the infraRef is set. This is needed because the infraRef is not initially // set in Clusters created from a ClusterClass. if err := c.Watch( - &source.Kind{Type: &clusterv1.Cluster{}}, + source.Kind(mgr.GetCache(), &clusterv1.Cluster{}), handler.EnqueueRequestsFromMapFunc(azureMachineTemplateMapper), predicates.ClusterUnpausedAndInfrastructureReady(log), predicates.ResourceNotPausedAndHasFilterLabel(log, r.WatchFilterValue), diff --git a/controllers/azuremachine_controller.go b/controllers/azuremachine_controller.go index e484f895f4f..59ba72c689a 100644 --- a/controllers/azuremachine_controller.go +++ b/controllers/azuremachine_controller.go @@ -95,12 +95,12 @@ func (amr *AzureMachineReconciler) SetupWithManager(ctx context.Context, mgr ctr WithEventFilter(predicates.ResourceHasFilterLabel(log, amr.WatchFilterValue)). // watch for changes in CAPI Machine resources Watches( - &source.Kind{Type: &clusterv1.Machine{}}, + &clusterv1.Machine{}, handler.EnqueueRequestsFromMapFunc(util.MachineToInfrastructureMapFunc(infrav1.GroupVersion.WithKind("AzureMachine"))), ). // watch for changes in AzureCluster Watches( - &source.Kind{Type: &infrav1.AzureCluster{}}, + &infrav1.AzureCluster{}, handler.EnqueueRequestsFromMapFunc(azureClusterToAzureMachinesMapper), ). Build(r) @@ -108,14 +108,14 @@ func (amr *AzureMachineReconciler) SetupWithManager(ctx context.Context, mgr ctr return errors.Wrap(err, "error creating controller") } - azureMachineMapper, err := util.ClusterToObjectsMapper(amr.Client, &infrav1.AzureMachineList{}, mgr.GetScheme()) + azureMachineMapper, err := util.ClusterToTypedObjectsMapper(amr.Client, &infrav1.AzureMachineList{}, mgr.GetScheme()) if err != nil { return errors.Wrap(err, "failed to create mapper for Cluster to AzureMachines") } // Add a watch on clusterv1.Cluster object for pause/unpause & ready notifications. if err := c.Watch( - &source.Kind{Type: &clusterv1.Cluster{}}, + source.Kind(mgr.GetCache(), &clusterv1.Cluster{}), handler.EnqueueRequestsFromMapFunc(azureMachineMapper), ClusterPauseChangeAndInfrastructureReady(log), predicates.ResourceHasFilterLabel(log, amr.WatchFilterValue), diff --git a/controllers/azuremachine_controller_test.go b/controllers/azuremachine_controller_test.go index 09da880cd36..9e43217588f 100644 --- a/controllers/azuremachine_controller_test.go +++ b/controllers/azuremachine_controller_test.go @@ -123,7 +123,13 @@ func TestAzureMachineReconcile(t *testing.T) { for name, tc := range cases { t.Run(name, func(t *testing.T) { - client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(tc.objects...).Build() + client := fake.NewClientBuilder(). + WithScheme(scheme). + WithRuntimeObjects(tc.objects...). + WithStatusSubresource( + &infrav1.AzureMachine{}, + ). + Build() reconciler := &AzureMachineReconciler{ Client: client, @@ -361,7 +367,13 @@ func getReconcileInputs(tc TestReconcileInput) (*AzureMachineReconciler, *scope. }, } - client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(objects...).Build() + client := fake.NewClientBuilder(). + WithScheme(scheme). + WithRuntimeObjects(objects...). + WithStatusSubresource( + &infrav1.AzureMachine{}, + ). + Build() reconciler := &AzureMachineReconciler{ Client: client, diff --git a/controllers/azuremanagedcluster_controller.go b/controllers/azuremanagedcluster_controller.go index 4411beeb779..f3c2a5c304a 100644 --- a/controllers/azuremanagedcluster_controller.go +++ b/controllers/azuremanagedcluster_controller.go @@ -74,7 +74,7 @@ func (amcr *AzureManagedClusterReconciler) SetupWithManager(ctx context.Context, WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(log, amcr.WatchFilterValue)). // watch AzureManagedControlPlane resources Watches( - &source.Kind{Type: &infrav1.AzureManagedControlPlane{}}, + &infrav1.AzureManagedControlPlane{}, handler.EnqueueRequestsFromMapFunc(azureManagedControlPlaneMapper), ). Build(r) @@ -84,7 +84,7 @@ func (amcr *AzureManagedClusterReconciler) SetupWithManager(ctx context.Context, // Add a watch on clusterv1.Cluster object for unpause notifications. if err = c.Watch( - &source.Kind{Type: &clusterv1.Cluster{}}, + source.Kind(mgr.GetCache(), &clusterv1.Cluster{}), handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("AzureManagedCluster"), mgr.GetClient(), &infrav1.AzureManagedCluster{})), predicates.ClusterUnpaused(log), predicates.ResourceNotPausedAndHasFilterLabel(log, amcr.WatchFilterValue), diff --git a/controllers/azuremanagedcontrolplane_controller.go b/controllers/azuremanagedcontrolplane_controller.go index 21972631c5b..e1710976bf6 100644 --- a/controllers/azuremanagedcontrolplane_controller.go +++ b/controllers/azuremanagedcontrolplane_controller.go @@ -82,12 +82,12 @@ func (amcpr *AzureManagedControlPlaneReconciler) SetupWithManager(ctx context.Co WithEventFilter(predicates.ResourceHasFilterLabel(log, amcpr.WatchFilterValue)). // watch AzureManagedCluster resources Watches( - &source.Kind{Type: &infrav1.AzureManagedCluster{}}, + &infrav1.AzureManagedCluster{}, handler.EnqueueRequestsFromMapFunc(azureManagedClusterMapper), ). // watch MachinePool resources Watches( - &source.Kind{Type: &expv1.MachinePool{}}, + &expv1.MachinePool{}, handler.EnqueueRequestsFromMapFunc(azureManagedMachinePoolMapper), ). Build(r) @@ -97,7 +97,7 @@ func (amcpr *AzureManagedControlPlaneReconciler) SetupWithManager(ctx context.Co // Add a watch on clusterv1.Cluster object for pause/unpause & ready notifications. if err = c.Watch( - &source.Kind{Type: &clusterv1.Cluster{}}, + source.Kind(mgr.GetCache(), &clusterv1.Cluster{}), handler.EnqueueRequestsFromMapFunc(amcpr.ClusterToAzureManagedControlPlane), ClusterPauseChangeAndInfrastructureReady(log), predicates.ResourceHasFilterLabel(log, amcpr.WatchFilterValue), @@ -311,7 +311,7 @@ func (amcpr *AzureManagedControlPlaneReconciler) reconcileDelete(ctx context.Con // ClusterToAzureManagedControlPlane is a handler.ToRequestsFunc to be used to enqueue requests for // reconciliation for AzureManagedControlPlane based on updates to a Cluster. -func (amcpr *AzureManagedControlPlaneReconciler) ClusterToAzureManagedControlPlane(o client.Object) []ctrl.Request { +func (amcpr *AzureManagedControlPlaneReconciler) ClusterToAzureManagedControlPlane(_ context.Context, o client.Object) []ctrl.Request { c, ok := o.(*clusterv1.Cluster) if !ok { panic(fmt.Sprintf("Expected a Cluster but got a %T", o)) diff --git a/controllers/azuremanagedcontrolplane_controller_test.go b/controllers/azuremanagedcontrolplane_controller_test.go index 19ca6ec119e..5841c6e0564 100644 --- a/controllers/azuremanagedcontrolplane_controller_test.go +++ b/controllers/azuremanagedcontrolplane_controller_test.go @@ -73,7 +73,7 @@ func TestClusterToAzureManagedControlPlane(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { g := NewWithT(t) - actual := (&AzureManagedControlPlaneReconciler{}).ClusterToAzureManagedControlPlane(&clusterv1.Cluster{ + actual := (&AzureManagedControlPlaneReconciler{}).ClusterToAzureManagedControlPlane(context.TODO(), &clusterv1.Cluster{ Spec: clusterv1.ClusterSpec{ ControlPlaneRef: test.controlPlaneRef, }, diff --git a/controllers/azuremanagedmachinepool_controller.go b/controllers/azuremanagedmachinepool_controller.go index 1aedb65679d..eb3af33f5e0 100644 --- a/controllers/azuremanagedmachinepool_controller.go +++ b/controllers/azuremanagedmachinepool_controller.go @@ -94,12 +94,12 @@ func (ammpr *AzureManagedMachinePoolReconciler) SetupWithManager(ctx context.Con WithEventFilter(predicates.ResourceHasFilterLabel(log, ammpr.WatchFilterValue)). // watch for changes in CAPI MachinePool resources Watches( - &source.Kind{Type: &expv1.MachinePool{}}, + &expv1.MachinePool{}, handler.EnqueueRequestsFromMapFunc(MachinePoolToInfrastructureMapFunc(infrav1.GroupVersion.WithKind("AzureManagedMachinePool"), log)), ). // watch for changes in AzureManagedControlPlanes Watches( - &source.Kind{Type: &infrav1.AzureManagedControlPlane{}}, + &infrav1.AzureManagedControlPlane{}, handler.EnqueueRequestsFromMapFunc(azureManagedControlPlaneMapper), ). Build(r) @@ -107,14 +107,14 @@ func (ammpr *AzureManagedMachinePoolReconciler) SetupWithManager(ctx context.Con return errors.Wrap(err, "error creating controller") } - azureManagedMachinePoolMapper, err := util.ClusterToObjectsMapper(ammpr.Client, &infrav1.AzureManagedMachinePoolList{}, mgr.GetScheme()) + azureManagedMachinePoolMapper, err := util.ClusterToTypedObjectsMapper(ammpr.Client, &infrav1.AzureManagedMachinePoolList{}, mgr.GetScheme()) if err != nil { return errors.Wrap(err, "failed to create mapper for Cluster to AzureManagedMachinePools") } // Add a watch on clusterv1.Cluster object for pause/unpause & ready notifications. if err = c.Watch( - &source.Kind{Type: &clusterv1.Cluster{}}, + source.Kind(mgr.GetCache(), &clusterv1.Cluster{}), handler.EnqueueRequestsFromMapFunc(azureManagedMachinePoolMapper), ClusterPauseChangeAndInfrastructureReady(log), predicates.ResourceHasFilterLabel(log, ammpr.WatchFilterValue), diff --git a/controllers/azuremanagedmachinepool_controller_test.go b/controllers/azuremanagedmachinepool_controller_test.go index 90817f72af3..303f1375860 100644 --- a/controllers/azuremanagedmachinepool_controller_test.go +++ b/controllers/azuremanagedmachinepool_controller_test.go @@ -141,7 +141,11 @@ func TestAzureManagedMachinePoolReconcile(t *testing.T) { return s }() - cb = fake.NewClientBuilder().WithScheme(scheme) + cb = fake.NewClientBuilder(). + WithStatusSubresource( + &infrav1.AzureManagedMachinePool{}, + ). + WithScheme(scheme) ) defer mockCtrl.Finish() @@ -234,8 +238,9 @@ func newReadyAzureManagedMachinePoolCluster() (*clusterv1.Cluster, *infrav1.Azur // AzureManagedMachinePool ammp := &infrav1.AzureManagedMachinePool{ ObjectMeta: metav1.ObjectMeta{ - Name: "foo-ammp", - Namespace: "foobar", + Name: "foo-ammp", + Namespace: "foobar", + Finalizers: []string{"test"}, OwnerReferences: []metav1.OwnerReference{ { Name: "foo-mp1", diff --git a/controllers/helpers.go b/controllers/helpers.go index 5772f63ae83..3c404db2253 100644 --- a/controllers/helpers.go +++ b/controllers/helpers.go @@ -89,7 +89,7 @@ func AzureClusterToAzureMachinesMapper(ctx context.Context, c client.Client, obj return nil, errors.Wrap(err, "failed to find GVK for AzureMachine") } - return func(o client.Object) []ctrl.Request { + return func(ctx context.Context, o client.Object) []ctrl.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -124,7 +124,7 @@ func AzureClusterToAzureMachinesMapper(ctx context.Context, c client.Client, obj var results []ctrl.Request for _, machine := range machineList.Items { m := machine - azureMachines := mapFunc(&m) + azureMachines := mapFunc(ctx, &m) results = append(results, azureMachines...) } @@ -698,7 +698,7 @@ func RemoveClusterIdentityFinalizer(ctx context.Context, c client.Client, object // MachinePoolToInfrastructureMapFunc returns a handler.MapFunc that watches for // MachinePool events and returns reconciliation requests for an infrastructure provider object. func MachinePoolToInfrastructureMapFunc(gvk schema.GroupVersionKind, log logr.Logger) handler.MapFunc { - return func(o client.Object) []reconcile.Request { + return func(ctx context.Context, o client.Object) []reconcile.Request { m, ok := o.(*expv1.MachinePool) if !ok { log.V(4).Info("attempt to map incorrect type", "type", fmt.Sprintf("%T", o)) @@ -735,7 +735,7 @@ func AzureManagedClusterToAzureManagedMachinePoolsMapper(ctx context.Context, c return nil, errors.Wrap(err, "failed to find GVK for AzureManagedMachinePool") } - return func(o client.Object) []ctrl.Request { + return func(ctx context.Context, o client.Object) []ctrl.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -770,7 +770,7 @@ func AzureManagedClusterToAzureManagedMachinePoolsMapper(ctx context.Context, c var results []ctrl.Request for _, machine := range machineList.Items { m := machine - azureMachines := mapFunc(&m) + azureMachines := mapFunc(ctx, &m) results = append(results, azureMachines...) } @@ -788,7 +788,7 @@ func AzureManagedControlPlaneToAzureManagedMachinePoolsMapper(ctx context.Contex return nil, errors.Wrap(err, "failed to find GVK for AzureManagedMachinePool") } - return func(o client.Object) []ctrl.Request { + return func(ctx context.Context, o client.Object) []ctrl.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -823,7 +823,7 @@ func AzureManagedControlPlaneToAzureManagedMachinePoolsMapper(ctx context.Contex var results []ctrl.Request for _, machine := range machineList.Items { m := machine - azureMachines := mapFunc(&m) + azureMachines := mapFunc(ctx, &m) results = append(results, azureMachines...) } @@ -835,7 +835,7 @@ func AzureManagedControlPlaneToAzureManagedMachinePoolsMapper(ctx context.Contex // AzureManagedControlPlane. The transform requires AzureManagedCluster to map to the owning Cluster, then from the // Cluster, collect the control plane infrastructure reference. func AzureManagedClusterToAzureManagedControlPlaneMapper(ctx context.Context, c client.Client, log logr.Logger) (handler.MapFunc, error) { - return func(o client.Object) []ctrl.Request { + return func(ctx context.Context, o client.Object) []ctrl.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -884,7 +884,7 @@ func AzureManagedClusterToAzureManagedControlPlaneMapper(ctx context.Context, c // AzureManagedControlPlane. The transform requires AzureManagedCluster to map to the owning Cluster, then from the // Cluster, collect the control plane infrastructure reference. func AzureManagedControlPlaneToAzureManagedClusterMapper(ctx context.Context, c client.Client, log logr.Logger) (handler.MapFunc, error) { - return func(o client.Object) []ctrl.Request { + return func(ctx context.Context, o client.Object) []ctrl.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -932,7 +932,7 @@ func AzureManagedControlPlaneToAzureManagedClusterMapper(ctx context.Context, c // MachinePoolToAzureManagedControlPlaneMapFunc returns a handler.MapFunc that watches for // MachinePool events and returns reconciliation requests for a control plane object. func MachinePoolToAzureManagedControlPlaneMapFunc(ctx context.Context, c client.Client, gvk schema.GroupVersionKind, log logr.Logger) handler.MapFunc { - return func(o client.Object) []reconcile.Request { + return func(ctx context.Context, o client.Object) []reconcile.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() diff --git a/controllers/helpers_test.go b/controllers/helpers_test.go index de05e56ce54..0f238940c34 100644 --- a/controllers/helpers_test.go +++ b/controllers/helpers_test.go @@ -76,7 +76,7 @@ func TestAzureClusterToAzureMachinesMapper(t *testing.T) { mapper, err := AzureClusterToAzureMachinesMapper(context.Background(), client, &infrav1.AzureMachine{}, scheme, logr.New(sink)) g.Expect(err).NotTo(HaveOccurred()) - requests := mapper(&infrav1.AzureCluster{ + requests := mapper(context.TODO(), &infrav1.AzureCluster{ ObjectMeta: metav1.ObjectMeta{ Name: clusterName, Namespace: "default", @@ -841,7 +841,7 @@ func TestAzureManagedClusterToAzureManagedMachinePoolsMapper(t *testing.T) { mapper, err := AzureManagedClusterToAzureManagedMachinePoolsMapper(context.Background(), fakeClient, scheme, logr.New(sink)) g.Expect(err).NotTo(HaveOccurred()) - requests := mapper(&infrav1.AzureManagedCluster{ + requests := mapper(context.TODO(), &infrav1.AzureManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Name: clusterName, Namespace: "default", @@ -906,7 +906,7 @@ func TestAzureManagedControlPlaneToAzureManagedMachinePoolsMapper(t *testing.T) mapper, err := AzureManagedControlPlaneToAzureManagedMachinePoolsMapper(context.Background(), fakeClient, scheme, logr.New(sink)) g.Expect(err).NotTo(HaveOccurred()) - requests := mapper(&infrav1.AzureManagedControlPlane{ + requests := mapper(context.TODO(), &infrav1.AzureManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: cpName, Namespace: cluster.Namespace, @@ -978,7 +978,7 @@ func TestMachinePoolToAzureManagedControlPlaneMapFuncSuccess(t *testing.T) { mapper := MachinePoolToAzureManagedControlPlaneMapFunc(context.Background(), fakeClient, infrav1.GroupVersion.WithKind("AzureManagedControlPlane"), logr.New(sink)) // system pool should trigger - requests := mapper(newManagedMachinePoolInfraReference(clusterName, "my-mmp-0")) + requests := mapper(context.TODO(), newManagedMachinePoolInfraReference(clusterName, "my-mmp-0")) g.Expect(requests).To(ConsistOf([]reconcile.Request{ { NamespacedName: types.NamespacedName{ @@ -989,7 +989,7 @@ func TestMachinePoolToAzureManagedControlPlaneMapFuncSuccess(t *testing.T) { })) // any other pool should not trigger - requests = mapper(newManagedMachinePoolInfraReference(clusterName, "my-mmp-1")) + requests = mapper(context.TODO(), newManagedMachinePoolInfraReference(clusterName, "my-mmp-1")) g.Expect(requests).To(BeNil()) } @@ -1022,7 +1022,7 @@ func TestMachinePoolToAzureManagedControlPlaneMapFuncFailure(t *testing.T) { mapper := MachinePoolToAzureManagedControlPlaneMapFunc(context.Background(), fakeClient, infrav1.GroupVersion.WithKind("AzureManagedControlPlane"), logr.New(sink)) // default pool should trigger if owned cluster could not be fetched - requests := mapper(newManagedMachinePoolInfraReference(clusterName, "my-mmp-0")) + requests := mapper(context.TODO(), newManagedMachinePoolInfraReference(clusterName, "my-mmp-0")) g.Expect(requests).To(ConsistOf([]reconcile.Request{ { NamespacedName: types.NamespacedName{ @@ -1033,7 +1033,7 @@ func TestMachinePoolToAzureManagedControlPlaneMapFuncFailure(t *testing.T) { })) // any other pool should also trigger if owned cluster could not be fetched - requests = mapper(newManagedMachinePoolInfraReference(clusterName, "my-mmp-1")) + requests = mapper(context.TODO(), newManagedMachinePoolInfraReference(clusterName, "my-mmp-1")) g.Expect(requests).To(ConsistOf([]reconcile.Request{ { NamespacedName: types.NamespacedName{ @@ -1068,7 +1068,7 @@ func TestAzureManagedClusterToAzureManagedControlPlaneMapper(t *testing.T) { mapper, err := AzureManagedClusterToAzureManagedControlPlaneMapper(context.Background(), fakeClient, logr.New(sink)) g.Expect(err).NotTo(HaveOccurred()) - requests := mapper(&infrav1.AzureManagedCluster{ + requests := mapper(context.TODO(), &infrav1.AzureManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "az-" + cluster.Name, Namespace: "default", @@ -1137,7 +1137,7 @@ func TestAzureManagedControlPlaneToAzureManagedClusterMapper(t *testing.T) { mapper, err := AzureManagedControlPlaneToAzureManagedClusterMapper(context.Background(), fakeClient, logr.New(sink)) g.Expect(err).NotTo(HaveOccurred()) - requests := mapper(&infrav1.AzureManagedControlPlane{ + requests := mapper(context.TODO(), &infrav1.AzureManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: cpName, Namespace: cluster.Namespace, @@ -1306,7 +1306,7 @@ func Test_ManagedMachinePoolToInfrastructureMapFunc(t *testing.T) { c.Setup(sink) } f := MachinePoolToInfrastructureMapFunc(infrav1.GroupVersion.WithKind("AzureManagedMachinePool"), logr.New(sink)) - reqs := f(c.MapObjectFactory(g)) + reqs := f(context.TODO(), c.MapObjectFactory(g)) c.Expect(g, reqs) }) } diff --git a/exp/api/v1beta1/azuremachinepool_webhook.go b/exp/api/v1beta1/azuremachinepool_webhook.go index 5001327dba8..016e8aadb94 100644 --- a/exp/api/v1beta1/azuremachinepool_webhook.go +++ b/exp/api/v1beta1/azuremachinepool_webhook.go @@ -35,6 +35,7 @@ import ( capifeature "sigs.k8s.io/cluster-api/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) // SetupAzureMachinePoolWebhookWithManager sets up and registers the webhook with the manager. @@ -66,34 +67,34 @@ func (ampw *azureMachinePoolWebhook) Default(ctx context.Context, obj runtime.Ob // +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azuremachinepool,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azuremachinepools,versions=v1beta1,name=validation.azuremachinepool.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureMachinePoolWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) error { +func (ampw *azureMachinePoolWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { amp, ok := obj.(*AzureMachinePool) if !ok { - return apierrors.NewBadRequest("expected an AzureMachinePool") + return nil, apierrors.NewBadRequest("expected an AzureMachinePool") } // NOTE: AzureMachinePool is behind MachinePool feature gate flag; the webhook // must prevent creating new objects in case the feature flag is disabled. if !feature.Gates.Enabled(capifeature.MachinePool) { - return field.Forbidden( + return nil, field.Forbidden( field.NewPath("spec"), "can be set only if the MachinePool feature flag is enabled", ) } - return amp.Validate(nil, ampw.Client) + return nil, amp.Validate(nil, ampw.Client) } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureMachinePoolWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) error { +func (ampw *azureMachinePoolWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { amp, ok := newObj.(*AzureMachinePool) if !ok { - return apierrors.NewBadRequest("expected an AzureMachinePool") + return nil, apierrors.NewBadRequest("expected an AzureMachinePool") } - return amp.Validate(oldObj, ampw.Client) + return nil, amp.Validate(oldObj, ampw.Client) } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureMachinePoolWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) error { - return nil +func (ampw *azureMachinePoolWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { + return nil, nil } // Validate the Azure Machine Pool and return an aggregate error. diff --git a/exp/api/v1beta1/azuremachinepool_webhook_test.go b/exp/api/v1beta1/azuremachinepool_webhook_test.go index 4b63aa9119e..183115ced0c 100644 --- a/exp/api/v1beta1/azuremachinepool_webhook_test.go +++ b/exp/api/v1beta1/azuremachinepool_webhook_test.go @@ -247,7 +247,7 @@ func TestAzureMachinePool_ValidateCreate(t *testing.T) { ampw := &azureMachinePoolWebhook{ Client: client, } - err := ampw.ValidateCreate(context.Background(), tc.amp) + _, err := ampw.ValidateCreate(context.Background(), tc.amp) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -388,7 +388,7 @@ func TestAzureMachinePool_ValidateUpdate(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { ampw := &azureMachinePoolWebhook{} - err := ampw.ValidateUpdate(context.Background(), tc.oldAMP, tc.amp) + _, err := ampw.ValidateUpdate(context.Background(), tc.oldAMP, tc.amp) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -662,7 +662,7 @@ func TestAzureMachinePool_ValidateCreateFailure(t *testing.T) { t.Run(tc.name, func(t *testing.T) { defer tc.deferFunc() ampw := &azureMachinePoolWebhook{} - err := ampw.ValidateCreate(context.Background(), tc.amp) + _, err := ampw.ValidateCreate(context.Background(), tc.amp) g.Expect(err).To(HaveOccurred()) }) } diff --git a/exp/api/v1beta1/azuremachinepoolmachine_webhook.go b/exp/api/v1beta1/azuremachinepoolmachine_webhook.go index d8cb3b763a0..b2fef133832 100644 --- a/exp/api/v1beta1/azuremachinepoolmachine_webhook.go +++ b/exp/api/v1beta1/azuremachinepoolmachine_webhook.go @@ -24,6 +24,7 @@ import ( capifeature "sigs.k8s.io/cluster-api/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) // SetupWebhookWithManager sets up and registers the webhook with the manager. @@ -38,16 +39,16 @@ func (ampm *AzureMachinePoolMachine) SetupWebhookWithManager(mgr ctrl.Manager) e var _ webhook.Validator = &AzureMachinePoolMachine{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (ampm *AzureMachinePoolMachine) ValidateCreate() error { - return nil +func (ampm *AzureMachinePoolMachine) ValidateCreate() (admission.Warnings, error) { + return nil, nil } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (ampm *AzureMachinePoolMachine) ValidateUpdate(old runtime.Object) error { +func (ampm *AzureMachinePoolMachine) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { // NOTE: AzureMachinePoolMachine is behind MachinePool feature gate flag; the webhook // must prevent creating new objects new case the feature flag is disabled. if !feature.Gates.Enabled(capifeature.MachinePool) { - return field.Forbidden( + return nil, field.Forbidden( field.NewPath("spec"), "can be set only if the MachinePool feature flag is enabled", ) @@ -55,17 +56,17 @@ func (ampm *AzureMachinePoolMachine) ValidateUpdate(old runtime.Object) error { oldMachine, ok := old.(*AzureMachinePoolMachine) if !ok { - return errors.New("expected and AzureMachinePoolMachine") + return nil, errors.New("expected and AzureMachinePoolMachine") } if oldMachine.Spec.ProviderID != "" && ampm.Spec.ProviderID != oldMachine.Spec.ProviderID { - return errors.New("providerID is immutable") + return nil, errors.New("providerID is immutable") } - return nil + return nil, nil } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (ampm *AzureMachinePoolMachine) ValidateDelete() error { - return nil +func (ampm *AzureMachinePoolMachine) ValidateDelete() (admission.Warnings, error) { + return nil, nil } diff --git a/exp/controllers/azuremachinepool_controller.go b/exp/controllers/azuremachinepool_controller.go index 9f058441bba..69c72b48367 100644 --- a/exp/controllers/azuremachinepool_controller.go +++ b/exp/controllers/azuremachinepool_controller.go @@ -109,17 +109,17 @@ func (ampr *AzureMachinePoolReconciler) SetupWithManager(ctx context.Context, mg WithEventFilter(predicates.ResourceHasFilterLabel(log, ampr.WatchFilterValue)). // watch for changes in CAPI MachinePool resources Watches( - &source.Kind{Type: &expv1.MachinePool{}}, + &expv1.MachinePool{}, handler.EnqueueRequestsFromMapFunc(MachinePoolToInfrastructureMapFunc(infrav1exp.GroupVersion.WithKind("AzureMachinePool"), log)), ). // watch for changes in AzureCluster resources Watches( - &source.Kind{Type: &infrav1.AzureCluster{}}, + &infrav1.AzureCluster{}, handler.EnqueueRequestsFromMapFunc(azureClusterMapper), ). // watch for changes in KubeadmConfig to sync bootstrap token Watches( - &source.Kind{Type: &kubeadmv1.KubeadmConfig{}}, + &kubeadmv1.KubeadmConfig{}, handler.EnqueueRequestsFromMapFunc(KubeadmConfigToInfrastructureMapFunc(ctx, ampr.Client, log)), builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}), ). @@ -129,7 +129,7 @@ func (ampr *AzureMachinePoolReconciler) SetupWithManager(ctx context.Context, mg } if err := c.Watch( - &source.Kind{Type: &infrav1exp.AzureMachinePoolMachine{}}, + source.Kind(mgr.GetCache(), &infrav1exp.AzureMachinePoolMachine{}), handler.EnqueueRequestsFromMapFunc(AzureMachinePoolMachineMapper(mgr.GetScheme(), log)), MachinePoolMachineHasStateOrVersionChange(log), predicates.ResourceHasFilterLabel(log, ampr.WatchFilterValue), @@ -137,14 +137,14 @@ func (ampr *AzureMachinePoolReconciler) SetupWithManager(ctx context.Context, mg return errors.Wrap(err, "failed adding a watch for AzureMachinePoolMachine") } - azureMachinePoolMapper, err := util.ClusterToObjectsMapper(ampr.Client, &infrav1exp.AzureMachinePoolList{}, mgr.GetScheme()) + azureMachinePoolMapper, err := util.ClusterToTypedObjectsMapper(ampr.Client, &infrav1exp.AzureMachinePoolList{}, mgr.GetScheme()) if err != nil { return errors.Wrap(err, "failed to create mapper for Cluster to AzureMachines") } // Add a watch on clusterv1.Cluster object for unpause & ready notifications. if err := c.Watch( - &source.Kind{Type: &clusterv1.Cluster{}}, + source.Kind(mgr.GetCache(), &clusterv1.Cluster{}), handler.EnqueueRequestsFromMapFunc(azureMachinePoolMapper), infracontroller.ClusterPauseChangeAndInfrastructureReady(log), predicates.ResourceHasFilterLabel(log, ampr.WatchFilterValue), diff --git a/exp/controllers/azuremachinepoolmachine_controller.go b/exp/controllers/azuremachinepoolmachine_controller.go index 925c32ad5ef..7375e5abd2e 100644 --- a/exp/controllers/azuremachinepoolmachine_controller.go +++ b/exp/controllers/azuremachinepoolmachine_controller.go @@ -102,7 +102,7 @@ func (ampmr *AzureMachinePoolMachineController) SetupWithManager(ctx context.Con // Add a watch on AzureMachinePool for model changes if err := c.Watch( - &source.Kind{Type: &infrav1exp.AzureMachinePool{}}, + source.Kind(mgr.GetCache(), &infrav1exp.AzureMachinePool{}), handler.EnqueueRequestsFromMapFunc(AzureMachinePoolToAzureMachinePoolMachines(ctx, mgr.GetClient(), log)), MachinePoolModelHasChanged(log), predicates.ResourceNotPausedAndHasFilterLabel(log, ampmr.WatchFilterValue), diff --git a/exp/controllers/azuremachinepoolmachine_controller_test.go b/exp/controllers/azuremachinepoolmachine_controller_test.go index cbcb3051e65..3997632af33 100644 --- a/exp/controllers/azuremachinepoolmachine_controller_test.go +++ b/exp/controllers/azuremachinepoolmachine_controller_test.go @@ -172,8 +172,9 @@ func getAReadyMachinePoolMachineCluster() (*clusterv1.Cluster, *infrav1.AzureClu ampm := &infrav1exp.AzureMachinePoolMachine{ ObjectMeta: metav1.ObjectMeta{ - Name: "ampm1", - Namespace: "default", + Name: "ampm1", + Namespace: "default", + Finalizers: []string{"test"}, OwnerReferences: []metav1.OwnerReference{ { Name: amp.Name, diff --git a/exp/controllers/helpers.go b/exp/controllers/helpers.go index b7abf04a255..1dbcb4b9a42 100644 --- a/exp/controllers/helpers.go +++ b/exp/controllers/helpers.go @@ -53,7 +53,7 @@ func AzureClusterToAzureMachinePoolsMapper(ctx context.Context, c client.Client, return nil, errors.Wrap(err, "failed to find GVK for AzureMachinePool") } - return func(o client.Object) []ctrl.Request { + return func(ctx context.Context, o client.Object) []ctrl.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -89,7 +89,7 @@ func AzureClusterToAzureMachinePoolsMapper(ctx context.Context, c client.Client, var results []ctrl.Request for _, machine := range machineList.Items { m := machine - azureMachines := mapFunc(&m) + azureMachines := mapFunc(ctx, &m) results = append(results, azureMachines...) } @@ -99,7 +99,7 @@ func AzureClusterToAzureMachinePoolsMapper(ctx context.Context, c client.Client, // AzureMachinePoolMachineMapper creates a mapping handler to transform AzureMachinePoolMachine to AzureMachinePools. func AzureMachinePoolMachineMapper(scheme *runtime.Scheme, log logr.Logger) handler.MapFunc { - return func(o client.Object) []ctrl.Request { + return func(ctx context.Context, o client.Object) []ctrl.Request { gvk, err := apiutil.GVKForObject(new(infrav1exp.AzureMachinePool), scheme) if err != nil { log.Error(errors.WithStack(err), "failed to find GVK for AzureMachinePool") @@ -143,7 +143,7 @@ func AzureMachinePoolMachineMapper(scheme *runtime.Scheme, log logr.Logger) hand // MachinePoolToInfrastructureMapFunc returns a handler.MapFunc that watches for // MachinePool events and returns reconciliation requests for an infrastructure provider object. func MachinePoolToInfrastructureMapFunc(gvk schema.GroupVersionKind, log logr.Logger) handler.MapFunc { - return func(o client.Object) []reconcile.Request { + return func(ctx context.Context, o client.Object) []reconcile.Request { m, ok := o.(*expv1.MachinePool) if !ok { log.V(4).Info("attempt to map incorrect type", "type", fmt.Sprintf("%T", o)) @@ -173,7 +173,7 @@ func MachinePoolToInfrastructureMapFunc(gvk schema.GroupVersionKind, log logr.Lo // AzureClusterToAzureMachinePoolsFunc is a handler.MapFunc to be used to enqueue // requests for reconciliation of AzureMachinePools. func AzureClusterToAzureMachinePoolsFunc(ctx context.Context, c client.Client, log logr.Logger) handler.MapFunc { - return func(o client.Object) []reconcile.Request { + return func(ctx context.Context, o client.Object) []reconcile.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -218,7 +218,7 @@ func AzureClusterToAzureMachinePoolsFunc(ctx context.Context, c client.Client, l // AzureMachinePoolToAzureMachinePoolMachines maps an AzureMachinePool to its child AzureMachinePoolMachines through // Cluster and MachinePool labels. func AzureMachinePoolToAzureMachinePoolMachines(ctx context.Context, c client.Client, log logr.Logger) handler.MapFunc { - return func(o client.Object) []reconcile.Request { + return func(ctx context.Context, o client.Object) []reconcile.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -321,7 +321,7 @@ func MachinePoolMachineHasStateOrVersionChange(logger logr.Logger) predicate.Fun // KubeadmConfigToInfrastructureMapFunc returns a handler.ToRequestsFunc that watches for KubeadmConfig events and returns. func KubeadmConfigToInfrastructureMapFunc(ctx context.Context, c client.Client, log logr.Logger) handler.MapFunc { - return func(o client.Object) []reconcile.Request { + return func(ctx context.Context, o client.Object) []reconcile.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() diff --git a/exp/controllers/helpers_test.go b/exp/controllers/helpers_test.go index 966d7392a11..5cf50dbf7c9 100644 --- a/exp/controllers/helpers_test.go +++ b/exp/controllers/helpers_test.go @@ -60,7 +60,7 @@ func TestAzureClusterToAzureMachinePoolsMapper(t *testing.T) { mapper, err := AzureClusterToAzureMachinePoolsMapper(context.Background(), fakeClient, scheme, logr.New(sink)) g.Expect(err).NotTo(HaveOccurred()) - requests := mapper(&infrav1.AzureCluster{ + requests := mapper(context.Background(), &infrav1.AzureCluster{ ObjectMeta: metav1.ObjectMeta{ Name: clusterName, Namespace: "default", @@ -145,7 +145,7 @@ func Test_MachinePoolToInfrastructureMapFunc(t *testing.T) { c.Setup(sink) } f := MachinePoolToInfrastructureMapFunc(infrav1exp.GroupVersion.WithKind("AzureMachinePool"), logr.New(sink)) - reqs := f(c.MapObjectFactory(g)) + reqs := f(context.TODO(), c.MapObjectFactory(g)) c.Expect(g, reqs) }) } @@ -291,7 +291,7 @@ func Test_azureClusterToAzureMachinePoolsFunc(t *testing.T) { defer mockctrl.Finish() f := AzureClusterToAzureMachinePoolsFunc(context.Background(), fakeClient, logr.New(sink)) - reqs := f(c.MapObjectFactory(g)) + reqs := f(context.TODO(), c.MapObjectFactory(g)) c.Expect(g, reqs) }) } diff --git a/go.mod b/go.mod index ebe86b56bab..aee8be2d4ac 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/Azure/azure-sdk-for-go v68.0.0+incompatible github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 - github.com/Azure/azure-service-operator/v2 v2.1.0 + github.com/Azure/azure-service-operator/v2 v2.2.0 github.com/Azure/go-autorest/autorest v0.11.29 github.com/Azure/go-autorest/autorest/azure/auth v0.5.12 github.com/Azure/go-autorest/tracing v0.6.0 @@ -36,17 +36,17 @@ require ( golang.org/x/crypto v0.12.0 golang.org/x/mod v0.12.0 golang.org/x/text v0.12.0 - k8s.io/api v0.26.2 - k8s.io/apimachinery v0.26.2 - k8s.io/client-go v0.26.2 - k8s.io/component-base v0.26.2 + k8s.io/api v0.27.2 + k8s.io/apimachinery v0.27.2 + k8s.io/client-go v0.27.2 + k8s.io/component-base v0.27.2 k8s.io/klog/v2 v2.90.1 - k8s.io/kubectl v0.26.1 + k8s.io/kubectl v0.27.2 k8s.io/utils v0.0.0-20230726121419-3b25d923346b sigs.k8s.io/cloud-provider-azure v1.26.7 - sigs.k8s.io/cluster-api v1.4.5 - sigs.k8s.io/cluster-api/test v1.4.5 - sigs.k8s.io/controller-runtime v0.14.5 + sigs.k8s.io/cluster-api v1.5.0 + sigs.k8s.io/cluster-api/test v1.5.0 + sigs.k8s.io/controller-runtime v0.15.0 sigs.k8s.io/kind v0.20.0 ) @@ -65,9 +65,10 @@ require ( github.com/BurntSushi/toml v1.2.1 // indirect github.com/MakeNowJust/heredoc v1.0.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.2.0 // indirect + github.com/Masterminds/semver/v3 v3.2.1 // indirect github.com/Masterminds/sprig/v3 v3.2.3 // indirect github.com/Microsoft/go-winio v0.6.0 // indirect + github.com/adrg/xdg v0.4.0 // indirect github.com/alessio/shellescape v1.4.1 // indirect github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect github.com/benbjohnson/clock v1.1.0 // indirect @@ -85,17 +86,17 @@ require ( github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/drone/envsubst/v2 v2.0.0-20210730161058-179042472c46 // indirect - github.com/emicklei/go-restful/v3 v3.10.1 // indirect + github.com/emicklei/go-restful/v3 v3.10.2 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect github.com/fatih/camelcase v1.0.0 // indirect github.com/felixge/httpsnoop v1.0.3 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/go-errors/errors v1.0.1 // indirect + github.com/go-errors/errors v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-openapi/jsonpointer v0.19.5 // indirect - github.com/go-openapi/jsonreference v0.20.0 // indirect + github.com/go-openapi/jsonpointer v0.19.6 // indirect + github.com/go-openapi/jsonreference v0.20.1 // indirect github.com/go-openapi/swag v0.22.3 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/gobuffalo/flect v1.0.2 // indirect @@ -111,7 +112,7 @@ require ( github.com/google/go-github/v48 v48.2.0 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect + github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect @@ -120,7 +121,7 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/huandu/xstrings v1.4.0 // indirect github.com/imdario/mergo v0.3.13 // indirect - github.com/inconshreveable/mousetrap v1.0.1 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kr/fs v0.1.0 // indirect @@ -144,7 +145,7 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b // indirect github.com/pelletier/go-toml v1.9.5 // indirect - github.com/pelletier/go-toml/v2 v2.0.6 // indirect + github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/prometheus/client_model v0.4.0 // indirect @@ -152,11 +153,11 @@ require ( github.com/prometheus/procfs v0.11.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect - github.com/spf13/afero v1.9.3 // indirect - github.com/spf13/cast v1.5.0 // indirect - github.com/spf13/cobra v1.6.1 // indirect + github.com/spf13/afero v1.9.5 // indirect + github.com/spf13/cast v1.5.1 // indirect + github.com/spf13/cobra v1.7.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect - github.com/spf13/viper v1.15.0 // indirect + github.com/spf13/viper v1.16.0 // indirect github.com/stoewer/go-strcase v1.2.0 // indirect github.com/subosito/gotenv v1.4.2 // indirect github.com/valyala/fastjson v1.6.4 // indirect @@ -173,7 +174,7 @@ require ( golang.org/x/term v0.11.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.9.3 // 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/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 // indirect @@ -184,18 +185,18 @@ require ( gopkg.in/ini.v1 v1.67.0 // 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/apiserver v0.26.2 // indirect - k8s.io/cli-runtime v0.26.1 // indirect + k8s.io/apiextensions-apiserver v0.27.2 // indirect + k8s.io/apiserver v0.27.2 // indirect + k8s.io/cli-runtime v0.27.2 // indirect k8s.io/cloud-provider v0.26.2 // indirect - k8s.io/cluster-bootstrap v0.25.0 // indirect - k8s.io/component-helpers v0.26.2 // indirect - k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect - sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect - sigs.k8s.io/kustomize/api v0.12.1 // indirect - sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect + k8s.io/cluster-bootstrap v0.27.2 // indirect + k8s.io/component-helpers v0.27.2 // indirect + k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect + sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect + sigs.k8s.io/kustomize/api v0.13.2 // indirect + sigs.k8s.io/kustomize/kyaml v0.14.1 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) -replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.4.5 +replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.5.0 diff --git a/go.sum b/go.sum index 48b897ebab0..62d040ca276 100644 --- a/go.sum +++ b/go.sum @@ -50,13 +50,15 @@ github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aov github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appconfiguration/armappconfiguration v1.0.0 h1:5reBX+9pzc5xp9VrjSUoPrE8Wl/3y7wjfHzGjXzJbNk= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice v1.0.0 h1:figxyQZXzZQIcP3njhC68bYUiTw45J8/SsHaLW8Ax0M= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos v1.0.0 h1:Fv8iibGn1eSw0lt2V3cTsuokBEnOP+M//n8OiMcCgTM= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iothub/armiothub v1.1.1 h1:Dh8SxVXcSyQN76LI4IseKyrnqyTUsx336Axg8zDYSMs= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/machinelearning/armmachinelearning v1.0.0 h1:KWvCVjnOTKCZAlqED5KPNoN9AfcK2BhUeveLdiwy33Q= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redis/armredis v1.0.0 h1:nmpTBgRg1HynngFYICRhceC7s5dmbKN9fJ/XQz/UQ2I= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/search/armsearch v1.1.0 h1:SCO2mlFZrUMU8MmA5Y6EszSm2OGumuPBXFQXEvkESvk= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicebus/armservicebus v1.1.1 h1:h+ZMdUM0/8oVqHjY9+1rupIvT0craBLapKhuzWui9lo= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.0.0 h1:TMEyRFKh1zaSPmoQh3kxK+xRAYVq8guCI/7SMO0F3KY= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/subscription/armsubscription v1.0.0 h1:vsovXlTyKHZXnqzQyt7QMVkwpJBDkHchQL53qXaGBRY= -github.com/Azure/azure-service-operator/v2 v2.1.0 h1:P91Pfp5NeD3t7t0pj6ZwetQRfDZBntZ/T3iMHKrSxUI= -github.com/Azure/azure-service-operator/v2 v2.1.0/go.mod h1:W/AcGFo9edvj0Gdw1SiA6WEKELYaap4SaoU09BxOwEk= +github.com/Azure/azure-service-operator/v2 v2.2.0 h1:tTpEB6+umNnN+VG82/nWPG3k7neYUkJDBi7urZTZatw= +github.com/Azure/azure-service-operator/v2 v2.2.0/go.mod h1:gQZvsZuZmdS7QHHYcwviN0q/AsaE+u7C6Tm2RdhRNv8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= @@ -96,13 +98,16 @@ github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= +github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= +github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0= @@ -157,6 +162,7 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= 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= @@ -177,9 +183,8 @@ github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/drone/envsubst/v2 v2.0.0-20210730161058-179042472c46 h1:7QPwrLT79GlD5sizHf27aoY2RTvw62mO6x7mxkScNk0= github.com/drone/envsubst/v2 v2.0.0-20210730161058-179042472c46/go.mod h1:esf2rsHFNlZlxsqsZDojNBcnNs5REqIvRrWRHqX0vEU= -github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153 h1:yUdfgN0XgIJw7foRItutHYUIhlcKzcSf5vDpdhQAKTc= -github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= -github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.10.2 h1:hIovbnmBTLjHXkqEBUz3HGpXZdM7ZrE9fJIZIqlJLqE= +github.com/emicklei/go-restful/v3 v3.10.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -187,7 +192,6 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y 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 v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= @@ -202,13 +206,13 @@ github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBd github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= -github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -221,13 +225,11 @@ 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/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A= -github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= -github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonreference v0.20.0 h1:MYlu0sBgChmCfJxxUKZ8g1cPWFOB37YSZqewK7OKeyA= -github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= -github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +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.1 h1:FBLnyygC4/IZZr893oiomc9XaghoveYTrLC1F86HID8= +github.com/go-openapi/jsonreference v0.20.1/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= @@ -321,8 +323,8 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 h1:SJ+NtwL6QaZ21U+IrK7d0gGgpjGGvd2kz+FzTHVzdqI= github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2/go.mod h1:Tv1PlzqC9t8wNnpPdctvtSUOPUUg4SHeE6vR1Ir2hmg= @@ -383,8 +385,8 @@ github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= -github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= github.com/jackc/pgx/v5 v5.3.1 h1:Fcr8QJ1ZeLi5zsPZqQeUZhNhxfkkKBOgJuYkJHoBOtU= @@ -411,10 +413,12 @@ github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/leanovate/gopter v0.2.8 h1:eFPtJ3aa5zLfbxGROSNY75T9Dume60CWBAqoWQ3h/ig= @@ -424,8 +428,6 @@ github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= -github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= @@ -488,8 +490,8 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= -github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= +github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= +github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= @@ -542,16 +544,16 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9 github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk= -github.com/spf13/afero v1.9.3/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= +github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM= +github.com/spf13/afero v1.9.5/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= -github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= +github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= +github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= -github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= -github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= @@ -559,8 +561,8 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU= -github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA= +github.com/spf13/viper v1.16.0 h1:rGGH0XDZhdUOryiDWjmIvUSWpbNqisK8Wk0Vyefw8hc= +github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1FofRzQg= github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -579,6 +581,7 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= @@ -647,7 +650,6 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= @@ -808,6 +810,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -902,8 +905,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/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -1017,6 +1020,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= @@ -1038,7 +1042,7 @@ gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= +gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1046,32 +1050,32 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.26.2 h1:dM3cinp3PGB6asOySalOZxEG4CZ0IAdJsrYZXE/ovGQ= -k8s.io/api v0.26.2/go.mod h1:1kjMQsFE+QHPfskEcVNgL3+Hp88B80uj0QtSOlj8itU= -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.26.2 h1:da1u3D5wfR5u2RpLhE/ZtZS2P7QvDgLZTi9wrNZl/tQ= -k8s.io/apimachinery v0.26.2/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I= -k8s.io/apiserver v0.26.2 h1:Pk8lmX4G14hYqJd1poHGC08G03nIHVqdJMR0SD3IH3o= -k8s.io/apiserver v0.26.2/go.mod h1:GHcozwXgXsPuOJ28EnQ/jXEM9QeG6HT22YxSNmpYNh8= -k8s.io/cli-runtime v0.26.1 h1:f9+bRQ1V3elQsx37KmZy5fRAh56mVLbE9A7EMdlqVdI= -k8s.io/cli-runtime v0.26.1/go.mod h1:+e5Ym/ARySKscUhZ8K3hZ+ZBo/wYPIcg+7b5sFYi6Gg= -k8s.io/client-go v0.26.2 h1:s1WkVujHX3kTp4Zn4yGNFK+dlDXy1bAAkIl+cFAiuYI= -k8s.io/client-go v0.26.2/go.mod h1:u5EjOuSyBa09yqqyY7m3abZeovO/7D/WehVVlZ2qcqU= +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/apiserver v0.27.2 h1:p+tjwrcQEZDrEorCZV2/qE8osGTINPuS5ZNqWAvKm5E= +k8s.io/apiserver v0.27.2/go.mod h1:EsOf39d75rMivgvvwjJ3OW/u9n1/BmUMK5otEOJrb1Y= +k8s.io/cli-runtime v0.27.2 h1:9HI8gfReNujKXt16tGOAnb8b4NZ5E+e0mQQHKhFGwYw= +k8s.io/cli-runtime v0.27.2/go.mod h1:9UecpyPDTkhiYY4d9htzRqN+rKomJgyb4wi0OfrmCjw= +k8s.io/client-go v0.27.2 h1:vDLSeuYvCHKeoQRhCXjxXO45nHVv2Ip4Fe0MfioMrhE= +k8s.io/client-go v0.27.2/go.mod h1:tY0gVmUsHrAmjzHX9zs7eCjxcBsf8IiNe7KQ52biTcQ= k8s.io/cloud-provider v0.26.2 h1:VlLGDayUV5VBpvMSBFqmpz2HHTjBLUw02wuZzNeEsW0= k8s.io/cloud-provider v0.26.2/go.mod h1:/Am9R0merLIZgVqPTE4Z1JkBcCrp2uXImHCxnvVARxc= -k8s.io/cluster-bootstrap v0.25.0 h1:KJ2/r0dV+bLfTK5EBobAVKvjGel3N4Qqh3bvnzh9qPk= -k8s.io/cluster-bootstrap v0.25.0/go.mod h1:x/TCtY3EiuR/rODkA3SvVQT3uSssQLf9cXcmSjdDTe0= -k8s.io/component-base v0.26.2 h1:IfWgCGUDzrD6wLLgXEstJKYZKAFS2kO+rBRi0p3LqcI= -k8s.io/component-base v0.26.2/go.mod h1:DxbuIe9M3IZPRxPIzhch2m1eT7uFrSBJUBuVCQEBivs= -k8s.io/component-helpers v0.26.2 h1:+JJ1gwyVsqSwZCJVLJotx/IPq2pMpo0kifeAzfo6i3U= -k8s.io/component-helpers v0.26.2/go.mod h1:PRvoduZ5/IeKGGbZRki3J2cTQVwZLD+EUxIEbvvX0W4= +k8s.io/cluster-bootstrap v0.27.2 h1:OL3onrOwrUD7NQxBUqQwTl1Uu2GQKCkw9BMHpc4PbiA= +k8s.io/cluster-bootstrap v0.27.2/go.mod h1:b++PF0mjUOiTKdPQFlDw7p4V2VquANZ8SfhAwzxZJFM= +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/component-helpers v0.27.2 h1:i9TgWJ6TH8lQ9x4ExHOwhVitrRpBOr7Wn8aZLbBWxkc= +k8s.io/component-helpers v0.27.2/go.mod h1:NwcpSKo1xzXtUtrUjj5NTSVWex84UPua/z0PYDcCzNo= k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E= -k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4= -k8s.io/kubectl v0.26.1 h1:K8A0Jjlwg8GqrxOXxAbjY5xtmXYeYjLU96cHp2WMQ7s= -k8s.io/kubectl v0.26.1/go.mod h1:miYFVzldVbdIiXMrHZYmL/EDWwJKM+F0sSsdxsATFPo= +k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5FJ2kxm1WrQFanWchyKuqGg= +k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f/go.mod h1:byini6yhqGC14c3ebc/QwanvYwhuMWF6yz2F8uwW8eg= +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-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= @@ -1079,20 +1083,20 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/cloud-provider-azure v1.26.7 h1:LSVRPyxeTQZPOF7z42zNZGzL1S1N5tg28RBZVy7gea4= sigs.k8s.io/cloud-provider-azure v1.26.7/go.mod h1:UIwr0Bk4wQb77wNL9cdT4zZw6DP2AtOQ9EKRt9c5g7Q= -sigs.k8s.io/cluster-api v1.4.5 h1:Xwi9cuL3FOR1gB6FhhKi7EEadY4m3CdJAesyx9/kxUo= -sigs.k8s.io/cluster-api v1.4.5/go.mod h1:HSiT5mE5uuxctGBiQcRJrZ6/iH+CCVmTvOryxSBcBG8= -sigs.k8s.io/cluster-api/test v1.4.5 h1:0ZuQre03UaxRXgiK3wQjtJNZGebw1xFaPvKFDOi3KaM= -sigs.k8s.io/cluster-api/test v1.4.5/go.mod h1:OMWLTfmTeFqMtprBE1zCDDpYect1M5jcEYYTSY7AgSA= -sigs.k8s.io/controller-runtime v0.14.5 h1:6xaWFqzT5KuAQ9ufgUaj1G/+C4Y1GRkhrxl+BJ9i+5s= -sigs.k8s.io/controller-runtime v0.14.5/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= -sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= -sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/cluster-api v1.5.0 h1:pwXvzScbAwnrB7EWHTApzW+VQfrj2OSrWAQDC9+bcbU= +sigs.k8s.io/cluster-api v1.5.0/go.mod h1:ZSEP01t8oT6104gB4ljsOwwp5uJcI8SWy8IFp2HUvrc= +sigs.k8s.io/cluster-api/test v1.5.0 h1:ePfrh7S+eaVWy+D0ca4AjzhBqrhXxRE9NTr5te4hCa0= +sigs.k8s.io/cluster-api/test v1.5.0/go.mod h1:Ii5Mh9oVq7QJEtiUkGg9mM2qojjWxvsqmL8TMlwZViM= +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/kind v0.20.0 h1:f0sc3v9mQbGnjBUaqSFST1dwIuiikKVGgoTwpoP33a8= sigs.k8s.io/kind v0.20.0/go.mod h1:aBlbxg08cauDgZ612shr017/rZwqd7AS563FvpWKPVs= -sigs.k8s.io/kustomize/api v0.12.1 h1:7YM7gW3kYBwtKvoY216ZzY+8hM+lV53LUayghNRJ0vM= -sigs.k8s.io/kustomize/api v0.12.1/go.mod h1:y3JUhimkZkR6sbLNwfJHxvo1TCLwuwm14sCYnkH6S1s= -sigs.k8s.io/kustomize/kyaml v0.13.9 h1:Qz53EAaFFANyNgyOEJbT/yoIHygK40/ZcvU3rgry2Tk= -sigs.k8s.io/kustomize/kyaml v0.13.9/go.mod h1:QsRbD0/KcU+wdk0/L0fIp2KLnohkVzs6fQ85/nOXac4= +sigs.k8s.io/kustomize/api v0.13.2 h1:kejWfLeJhUsTGioDoFNJET5LQe/ajzXhJGYoU+pJsiA= +sigs.k8s.io/kustomize/api v0.13.2/go.mod h1:DUp325VVMFVcQSq+ZxyDisA8wtldwHxLZbr1g94UHsw= +sigs.k8s.io/kustomize/kyaml v0.14.1 h1:c8iibius7l24G2wVAGZn/Va2wNys03GXLjYVIcFVxKA= +sigs.k8s.io/kustomize/kyaml v0.14.1/go.mod h1:AN1/IpawKilWD7V+YvQwRGUvuUOOWpjsHu6uHwonSF4= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/main.go b/main.go index 4491460bb98..d9cb33a1d5b 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,6 @@ import ( "context" "flag" "fmt" - "net/http" _ "net/http/pprof" "os" "time" @@ -28,6 +27,7 @@ import ( // +kubebuilder:scaffold:imports aadpodv1 "github.com/Azure/aad-pod-identity/pkg/apis/aadpodidentity/v1" "github.com/spf13/pflag" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -51,8 +51,11 @@ import ( capifeature "sigs.k8s.io/cluster-api/feature" "sigs.k8s.io/cluster-api/util/record" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/cache" + "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/webhook" ) var ( @@ -244,27 +247,17 @@ func main() { setupLog.Info("Watching cluster-api objects only in namespace for reconciliation", "namespace", watchNamespace) } - if profilerAddress != "" { - setupLog.Info("Profiler listening for requests", "profiler-address", profilerAddress) - go func() { - server := &http.Server{ - Addr: profilerAddress, - ReadHeaderTimeout: 3 * time.Second, - } - - err := server.ListenAndServe() - if err != nil { - setupLog.Error(err, "listen and serve error") - } - }() - } - // Machine and cluster operations can create enough events to trigger the event recorder spam filter // Setting the burst size higher ensures all events will be recorded and submitted to the API broadcaster := cgrecord.NewBroadcasterWithCorrelatorOptions(cgrecord.CorrelatorOptions{ BurstSize: 100, }) + var watchNamespaces []string + if watchNamespace != "" { + watchNamespaces = []string{watchNamespace} + } + restConfig := ctrl.GetConfigOrDie() restConfig.UserAgent = "cluster-api-provider-azure-manager" mgr, err := ctrl.NewManager(restConfig, ctrl.Options{ @@ -277,11 +270,24 @@ func main() { RenewDeadline: &leaderElectionRenewDeadline, RetryPeriod: &leaderElectionRetryPeriod, LeaderElectionResourceLock: resourcelock.LeasesResourceLock, - SyncPeriod: &syncPeriod, - Namespace: watchNamespace, HealthProbeBindAddress: healthAddr, - Port: webhookPort, - EventBroadcaster: broadcaster, + PprofBindAddress: profilerAddress, + Cache: cache.Options{ + Namespaces: watchNamespaces, + SyncPeriod: &syncPeriod, + }, + Client: client.Options{ + Cache: &client.CacheOptions{ + DisableFor: []client.Object{ + &corev1.ConfigMap{}, + &corev1.Secret{}, + }, + }, + }, + WebhookServer: webhook.NewServer(webhook.Options{ + Port: webhookPort, + }), + EventBroadcaster: broadcaster, }) if err != nil { setupLog.Error(err, "unable to start manager") diff --git a/test/e2e/aks.go b/test/e2e/aks.go index 5ab766e8f4b..1c61eda53e7 100644 --- a/test/e2e/aks.go +++ b/test/e2e/aks.go @@ -42,7 +42,7 @@ type DiscoverAndWaitForAKSControlPlaneInput struct { // WaitForAKSControlPlaneInitialized waits for the Azure managed control plane to be initialized. // This will be invoked by cluster api e2e framework. -func WaitForAKSControlPlaneInitialized(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWaitInput, result *clusterctl.ApplyClusterTemplateAndWaitResult) { +func WaitForAKSControlPlaneInitialized(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateAndWaitInput, result *clusterctl.ApplyCustomClusterTemplateAndWaitResult) { client := input.ClusterProxy.GetClient() DiscoverAndWaitForAKSControlPlaneInitialized(ctx, DiscoverAndWaitForAKSControlPlaneInput{ Lister: client, @@ -53,7 +53,7 @@ func WaitForAKSControlPlaneInitialized(ctx context.Context, input clusterctl.App // WaitForAKSControlPlaneReady waits for the azure managed control plane to be ready. // This will be invoked by cluster api e2e framework. -func WaitForAKSControlPlaneReady(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWaitInput, result *clusterctl.ApplyClusterTemplateAndWaitResult) { +func WaitForAKSControlPlaneReady(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateAndWaitInput, result *clusterctl.ApplyCustomClusterTemplateAndWaitResult) { client := input.ClusterProxy.GetClient() DiscoverAndWaitForAKSControlPlaneReady(ctx, DiscoverAndWaitForAKSControlPlaneInput{ Lister: client, diff --git a/test/e2e/azure_logcollector.go b/test/e2e/azure_logcollector.go index a01fc976374..2e399bf7a62 100644 --- a/test/e2e/azure_logcollector.go +++ b/test/e2e/azure_logcollector.go @@ -125,6 +125,12 @@ func (k AzureLogCollector) CollectMachinePoolLog(ctx context.Context, management return kinderrors.NewAggregate(errs) } +// CollectInfrastructureLogs collects log from the infrastructure. +// This is currently a no-op implementation to satisfy the LogCollector interface. +func (k AzureLogCollector) CollectInfrastructureLogs(ctx context.Context, managementClusterClient client.Client, c *clusterv1.Cluster, outputPath string) error { + return nil +} + // collectLogsFromNode collects logs from various sources by ssh'ing into the node func collectLogsFromNode(cluster *clusterv1.Cluster, hostname string, isWindows bool, outputPath string) error { nodeOSType := azure.LinuxOS diff --git a/test/e2e/cloud-provider-azure.go b/test/e2e/cloud-provider-azure.go index f9bfac056ad..34848f06817 100644 --- a/test/e2e/cloud-provider-azure.go +++ b/test/e2e/cloud-provider-azure.go @@ -40,12 +40,12 @@ const ( // InstallCalicoAndCloudProviderAzureHelmChart installs the official cloud-provider-azure helm chart // and validates that expected pods exist and are Ready. -func InstallCalicoAndCloudProviderAzureHelmChart(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWaitInput, cidrBlocks []string, hasWindows bool) { +func InstallCalicoAndCloudProviderAzureHelmChart(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateAndWaitInput, cidrBlocks []string, hasWindows bool) { specName := "cloud-provider-azure-install" By("Installing cloud-provider-azure components via helm") options := &HelmOptions{ Values: []string{ - fmt.Sprintf("infra.clusterName=%s", input.ConfigCluster.ClusterName), + fmt.Sprintf("infra.clusterName=%s", input.ClusterName), "cloudControllerManager.logVerbosity=4", }, StringValues: []string{fmt.Sprintf("cloudControllerManager.clusterCIDR=%s", strings.Join(cidrBlocks, `\,`))}, @@ -60,11 +60,11 @@ func InstallCalicoAndCloudProviderAzureHelmChart(ctx context.Context, input clus options.StringValues = append(options.StringValues, fmt.Sprintf("cloudNodeManager.imageTag=%s", os.Getenv("IMAGE_TAG_CNM"))) } - if input.ConfigCluster.Flavor == "flatcar" { + if strings.Contains(input.ClusterName, "flatcar") { options.StringValues = append(options.StringValues, "cloudControllerManager.caCertDir=/usr/share/ca-certificates") } - clusterProxy := input.ClusterProxy.GetWorkloadCluster(ctx, input.ConfigCluster.Namespace, input.ConfigCluster.ClusterName) + clusterProxy := input.ClusterProxy.GetWorkloadCluster(ctx, input.Namespace, input.ClusterName) InstallHelmChart(ctx, clusterProxy, defaultNamespace, cloudProviderAzureHelmRepoURL, cloudProviderAzureChartName, cloudProviderAzureHelmReleaseName, options, "") // We do this before waiting for the pods to be ready because there is a co-dependency between CNI (nodes ready) and cloud-provider being initialized. @@ -78,7 +78,7 @@ func InstallCalicoAndCloudProviderAzureHelmChart(ctx context.Context, input clus } // InstallAzureDiskCSIDriverHelmChart installs the official azure-disk CSI driver helm chart -func InstallAzureDiskCSIDriverHelmChart(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWaitInput, hasWindows bool) { +func InstallAzureDiskCSIDriverHelmChart(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateAndWaitInput, hasWindows bool) { specName := "azuredisk-csi-drivers-install" By("Installing azure-disk CSI driver components via helm") options := &HelmOptions{ @@ -88,7 +88,7 @@ func InstallAzureDiskCSIDriverHelmChart(ctx context.Context, input clusterctl.Ap if hasWindows { options.Values = append(options.Values, "windows.useHostProcessContainers=true") } - clusterProxy := input.ClusterProxy.GetWorkloadCluster(ctx, input.ConfigCluster.Namespace, input.ConfigCluster.ClusterName) + clusterProxy := input.ClusterProxy.GetWorkloadCluster(ctx, input.Namespace, input.ClusterName) InstallHelmChart(ctx, clusterProxy, kubesystem, azureDiskCSIDriverHelmRepoURL, azureDiskCSIDriverChartName, azureDiskCSIDriverHelmReleaseName, options, "") By("Waiting for Ready csi-azuredisk-controller deployment pods") for _, d := range []string{"csi-azuredisk-controller"} { diff --git a/test/e2e/cni.go b/test/e2e/cni.go index 79765b7f9ff..6c57112e2d7 100644 --- a/test/e2e/cni.go +++ b/test/e2e/cni.go @@ -43,7 +43,7 @@ const ( ) // InstallCNI installs the CNI plugin depending on the input.CNIManifestPath -func InstallCNI(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWaitInput, cidrBlocks []string, hasWindows bool) { +func InstallCNI(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateAndWaitInput, cidrBlocks []string, hasWindows bool) { if input.CNIManifestPath != "" { InstallCNIManifest(ctx, input, cidrBlocks, hasWindows) } else { @@ -52,9 +52,9 @@ func InstallCNI(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWai } // InstallCNIManifest installs the CNI manifest provided by the user -func InstallCNIManifest(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWaitInput, cidrBlocks []string, hasWindows bool) { +func InstallCNIManifest(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateAndWaitInput, cidrBlocks []string, hasWindows bool) { By("Installing a CNI plugin to the workload cluster") - workloadCluster := input.ClusterProxy.GetWorkloadCluster(ctx, input.ConfigCluster.Namespace, input.ConfigCluster.ClusterName) + workloadCluster := input.ClusterProxy.GetWorkloadCluster(ctx, input.Namespace, input.ClusterName) cniYaml, err := os.ReadFile(input.CNIManifestPath) Expect(err).ShouldNot(HaveOccurred()) @@ -64,12 +64,12 @@ func InstallCNIManifest(ctx context.Context, input clusterctl.ApplyClusterTempla // InstallCalicoHelmChart installs the official calico helm chart // and validates that expected pods exist and are Ready. -func InstallCalicoHelmChart(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWaitInput, cidrBlocks []string, hasWindows bool) { +func InstallCalicoHelmChart(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateAndWaitInput, cidrBlocks []string, hasWindows bool) { specName := "calico-install" By("Installing Calico CNI via helm") values := getCalicoValues(cidrBlocks) - clusterProxy := input.ClusterProxy.GetWorkloadCluster(ctx, input.ConfigCluster.Namespace, input.ConfigCluster.ClusterName) + clusterProxy := input.ClusterProxy.GetWorkloadCluster(ctx, input.Namespace, input.ClusterName) InstallHelmChart(ctx, clusterProxy, calicoOperatorNamespace, calicoHelmChartRepoURL, calicoHelmChartName, calicoHelmReleaseName, values, os.Getenv(CalicoVersion)) workloadClusterClient := clusterProxy.GetClient() diff --git a/test/e2e/common.go b/test/e2e/common.go index c6002973e55..30674d3e79b 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -30,7 +30,6 @@ import ( "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-10-01/resources" "github.com/Azure/go-autorest/autorest/azure/auth" - "github.com/blang/semver" . "github.com/onsi/ginkgo/v2" "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" @@ -249,12 +248,12 @@ func createRestConfig(ctx context.Context, tmpdir, namespace, clusterName string // and then installs cloud-provider-azure components via Helm. // Fulfills the clusterctl.Waiter type so that it can be used as ApplyClusterTemplateAndWaitInput data // in the flow of a clusterctl.ApplyClusterTemplateAndWait E2E test scenario. -func EnsureControlPlaneInitialized(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWaitInput, result *clusterctl.ApplyClusterTemplateAndWaitResult) { +func EnsureControlPlaneInitialized(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateAndWaitInput, result *clusterctl.ApplyCustomClusterTemplateAndWaitResult) { getter := input.ClusterProxy.GetClient() cluster := framework.GetClusterByName(ctx, framework.GetClusterByNameInput{ Getter: getter, - Name: input.ConfigCluster.ClusterName, - Namespace: input.ConfigCluster.Namespace, + Name: input.ClusterName, + Namespace: input.Namespace, }) kubeadmControlPlane := &kubeadmv1.KubeadmControlPlane{} key := client.ObjectKey{ @@ -271,7 +270,7 @@ func EnsureControlPlaneInitialized(ctx context.Context, input clusterctl.ApplyCl By("Ensuring API Server is reachable before applying Helm charts") Eventually(func(g Gomega) { ns := &corev1.Namespace{} - clusterProxy := input.ClusterProxy.GetWorkloadCluster(ctx, input.ConfigCluster.Namespace, input.ConfigCluster.ClusterName) + clusterProxy := input.ClusterProxy.GetWorkloadCluster(ctx, input.Namespace, input.ClusterName) g.Expect(clusterProxy.GetClient().Get(ctx, client.ObjectKey{Name: kubesystem}, ns)).To(Succeed(), "Failed to get kube-system namespace") }, input.WaitForControlPlaneIntervals...).Should(Succeed(), "API Server was not reachable in time") @@ -283,13 +282,7 @@ func EnsureControlPlaneInitialized(ctx context.Context, input clusterctl.ApplyCl InstallCNI(ctx, input, cluster.Spec.ClusterNetwork.Pods.CIDRBlocks, hasWindows) } controlPlane := discoveryAndWaitForControlPlaneInitialized(ctx, input, result) - v, err := semver.ParseTolerant(input.ConfigCluster.KubernetesVersion) - Expect(err).NotTo(HaveOccurred()) - if v.GTE(semver.MustParse("1.23.0")) { - InstallAzureDiskCSIDriverHelmChart(ctx, input, hasWindows) - } else { - Logf("Skipping Azure Disk CSI Driver installation for Kubernetes version %s", input.ConfigCluster.KubernetesVersion) - } + InstallAzureDiskCSIDriverHelmChart(ctx, input, hasWindows) result.ControlPlane = controlPlane } @@ -302,7 +295,7 @@ func CheckTestBeforeCleanup() { Logf("Cleaning up after \"%s\" spec", CurrentSpecReport().FullText()) } -func discoveryAndWaitForControlPlaneInitialized(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWaitInput, result *clusterctl.ApplyClusterTemplateAndWaitResult) *kubeadmv1.KubeadmControlPlane { +func discoveryAndWaitForControlPlaneInitialized(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateAndWaitInput, result *clusterctl.ApplyCustomClusterTemplateAndWaitResult) *kubeadmv1.KubeadmControlPlane { return framework.DiscoveryAndWaitForControlPlaneInitialized(ctx, framework.DiscoveryAndWaitForControlPlaneInitializedInput{ Lister: input.ClusterProxy.GetClient(), Cluster: result.Cluster, diff --git a/test/e2e/config/azure-dev.yaml b/test/e2e/config/azure-dev.yaml index 48028d7f94a..13efe7787fe 100644 --- a/test/e2e/config/azure-dev.yaml +++ b/test/e2e/config/azure-dev.yaml @@ -3,11 +3,11 @@ managementClusterName: capz-e2e images: - name: ${MANAGER_IMAGE} loadBehavior: mustLoad - - name: registry.k8s.io/cluster-api/cluster-api-controller:v1.4.5 + - name: registry.k8s.io/cluster-api/cluster-api-controller:v1.5.0 loadBehavior: tryLoad - - name: registry.k8s.io/cluster-api/kubeadm-bootstrap-controller:v1.4.5 + - name: registry.k8s.io/cluster-api/kubeadm-bootstrap-controller:v1.5.0 loadBehavior: tryLoad - - name: registry.k8s.io/cluster-api/kubeadm-control-plane-controller:v1.4.5 + - name: registry.k8s.io/cluster-api/kubeadm-control-plane-controller:v1.5.0 loadBehavior: tryLoad providers: @@ -23,8 +23,8 @@ providers: new: --metrics-addr=:8080 files: - sourcePath: "../data/shared/v1beta1/metadata.yaml" - - name: v1.4.5 - value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.4.5/core-components.yaml + - name: v1.5.0 + value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.5.0/core-components.yaml type: url contract: v1beta1 files: @@ -46,8 +46,8 @@ providers: new: --metrics-addr=:8080 files: - sourcePath: "../data/shared/v1beta1/metadata.yaml" - - name: v1.4.5 - value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.4.5/bootstrap-components.yaml + - name: v1.5.0 + value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.5.0/bootstrap-components.yaml type: url contract: v1beta1 files: @@ -68,8 +68,8 @@ providers: new: --metrics-addr=:8080 files: - sourcePath: "../data/shared/v1beta1/metadata.yaml" - - name: v1.4.5 - value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.4.5/control-plane-components.yaml + - name: v1.5.0 + value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.5.0/control-plane-components.yaml type: url contract: v1beta1 files: diff --git a/test/e2e/data/shared/v1beta1/metadata.yaml b/test/e2e/data/shared/v1beta1/metadata.yaml index a270758c7e0..100fbab0401 100644 --- a/test/e2e/data/shared/v1beta1/metadata.yaml +++ b/test/e2e/data/shared/v1beta1/metadata.yaml @@ -1,6 +1,9 @@ apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3 kind: Metadata releaseSeries: + - major: 1 + minor: 5 + contract: v1beta1 - major: 1 minor: 4 contract: v1beta1 diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index d73e3817aa6..fd4a4584d4d 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -32,10 +32,12 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "k8s.io/klog/v2" capi_e2e "sigs.k8s.io/cluster-api/test/e2e" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/test/framework/bootstrap" "sigs.k8s.io/cluster-api/test/framework/clusterctl" + ctrl "sigs.k8s.io/controller-runtime" ) func init() { @@ -51,6 +53,7 @@ func init() { } func TestE2E(t *testing.T) { + ctrl.SetLogger(klog.Background()) RegisterFailHandler(Fail) RunSpecs(t, "capz-e2e") } diff --git a/test/e2e/helpers.go b/test/e2e/helpers.go index c10e4216904..b15c96e4c7a 100644 --- a/test/e2e/helpers.go +++ b/test/e2e/helpers.go @@ -929,7 +929,7 @@ func getPodLogs(ctx context.Context, clientset *kubernetes.Clientset, pod corev1 return b.String() } -func CopyConfigMap(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWaitInput, cl client.Client, cmName, fromNamespace, toNamespace string) { +func CopyConfigMap(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateAndWaitInput, cl client.Client, cmName, fromNamespace, toNamespace string) { cm := &corev1.ConfigMap{} Eventually(func(g Gomega) { g.Expect(cl.Get(ctx, client.ObjectKey{Name: cmName, Namespace: fromNamespace}, cm)).To(Succeed()) diff --git a/test/e2e/retry.go b/test/e2e/retry.go index 692ffb5e143..07e33d2171f 100644 --- a/test/e2e/retry.go +++ b/test/e2e/retry.go @@ -20,6 +20,7 @@ limitations under the License. package e2e import ( + "context" "time" "k8s.io/apimachinery/pkg/util/wait" @@ -36,7 +37,7 @@ const ( // retryWithTimeout retries a function that returns an error until a timeout is reached func retryWithTimeout(interval, timeout time.Duration, fn func() error) error { var pollError error - err := wait.PollImmediate(interval, timeout, func() (bool, error) { + err := wait.PollUntilContextTimeout(context.TODO(), interval, timeout, true, func(context.Context) (bool, error) { pollError = nil err := fn() if err != nil {