From 379e2d96310ccf35f1713692243c9a7a9b31c6db Mon Sep 17 00:00:00 2001 From: Tsuzu <8574909+tsuzu@users.noreply.github.com> Date: Fri, 13 Dec 2024 03:31:47 +0900 Subject: [PATCH] Fix bugs --- .github/workflows/docker-publish.yml | 1 + internal/controller/incuscluster_controller.go | 4 ++-- internal/controller/incusmachine_controller.go | 4 ++-- test/e2e/e2e_test.go | 14 +++++++------- test/utils/utils.go | 4 ++-- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 4b518df..8082382 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -76,6 +76,7 @@ jobs: uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 with: context: . + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha diff --git a/internal/controller/incuscluster_controller.go b/internal/controller/incuscluster_controller.go index 63a9a28..735aa4f 100644 --- a/internal/controller/incuscluster_controller.go +++ b/internal/controller/incuscluster_controller.go @@ -110,13 +110,13 @@ func (r *IncusClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request return r.reconcileNormal(ctx, cluster, incusCluster) } -func (r *IncusClusterReconciler) reconcileDelete(_ context.Context, cluster *clusterv1.Cluster, incusCluster *infrav1alpha1.IncusCluster) error { +func (r *IncusClusterReconciler) reconcileDelete(_ context.Context, _ *clusterv1.Cluster, incusCluster *infrav1alpha1.IncusCluster) error { controllerutil.RemoveFinalizer(incusCluster, infrav1alpha1.ClusterFinalizer) return nil } -func (r *IncusClusterReconciler) reconcileNormal(ctx context.Context, cluster *clusterv1.Cluster, incusCluster *infrav1alpha1.IncusCluster) (ctrl.Result, error) { +func (r *IncusClusterReconciler) reconcileNormal(ctx context.Context, _ *clusterv1.Cluster, incusCluster *infrav1alpha1.IncusCluster) (ctrl.Result, error) { log := log.FromContext(ctx) if incusCluster.Spec.ControlPlaneEndpoint.Host == "" { diff --git a/internal/controller/incusmachine_controller.go b/internal/controller/incusmachine_controller.go index dace25a..70a9c36 100644 --- a/internal/controller/incusmachine_controller.go +++ b/internal/controller/incusmachine_controller.go @@ -186,7 +186,7 @@ func patchIncusMachine(ctx context.Context, patchHelper *patch.Helper, incusMach ) } -func (r *IncusMachineReconciler) reconcileDelete(ctx context.Context, incusCluster *infrav1alpha1.IncusCluster, machine *clusterv1.Machine, incusMachine *infrav1alpha1.IncusMachine) (ctrl.Result, error) { +func (r *IncusMachineReconciler) reconcileDelete(ctx context.Context, _ *infrav1alpha1.IncusCluster, _ *clusterv1.Machine, incusMachine *infrav1alpha1.IncusMachine) (ctrl.Result, error) { log := ctrl.LoggerFrom(ctx) // If the IncusMachine is being deleted, handle its deletion. @@ -222,7 +222,7 @@ func (r *IncusMachineReconciler) reconcileDelete(ctx context.Context, incusClust }, nil } -func (r *IncusMachineReconciler) reconcileNormal(ctx context.Context, cluster *clusterv1.Cluster, incusCluster *infrav1alpha1.IncusCluster, machine *clusterv1.Machine, incusMachine *infrav1alpha1.IncusMachine) (ctrl.Result, error) { +func (r *IncusMachineReconciler) reconcileNormal(ctx context.Context, cluster *clusterv1.Cluster, _ *infrav1alpha1.IncusCluster, machine *clusterv1.Machine, incusMachine *infrav1alpha1.IncusMachine) (ctrl.Result, error) { log := ctrl.LoggerFrom(ctx) // Check if the infrastructure is ready, otherwise return and wait for the cluster object to be updated diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index d580868..b7c52cd 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -93,27 +93,27 @@ var _ = Describe("Manager", Ordered, func() { cmd := exec.Command("kubectl", "logs", controllerPodName, "-n", namespace) controllerLogs, err := utils.Run(cmd) if err == nil { - _, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Controller logs:\n %s", controllerLogs)) + _, _ = fmt.Fprintf(GinkgoWriter, "Controller logs:\n %s", controllerLogs) } else { - _, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Failed to get Controller logs: %s", err)) + _, _ = fmt.Fprintf(GinkgoWriter, "Failed to get Controller logs: %s", err) } By("Fetching Kubernetes events") cmd = exec.Command("kubectl", "get", "events", "-n", namespace, "--sort-by=.lastTimestamp") eventsOutput, err := utils.Run(cmd) if err == nil { - _, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Kubernetes events:\n%s", eventsOutput)) + _, _ = fmt.Fprintf(GinkgoWriter, "Kubernetes events:\n%s", eventsOutput) } else { - _, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Failed to get Kubernetes events: %s", err)) + _, _ = fmt.Fprintf(GinkgoWriter, "Failed to get Kubernetes events: %s", err) } By("Fetching curl-metrics logs") cmd = exec.Command("kubectl", "logs", "curl-metrics", "-n", namespace) metricsOutput, err := utils.Run(cmd) if err == nil { - _, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Metrics logs:\n %s", metricsOutput)) + _, _ = fmt.Fprintf(GinkgoWriter, "Metrics logs:\n %s", metricsOutput) } else { - _, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Failed to get curl-metrics logs: %s", err)) + _, _ = fmt.Fprintf(GinkgoWriter, "Failed to get curl-metrics logs: %s", err) } By("Fetching controller manager pod description") @@ -278,7 +278,7 @@ func serviceAccountToken() (string, error) { // Parse the JSON output to extract the token var token tokenRequest - err = json.Unmarshal([]byte(output), &token) + err = json.Unmarshal(output, &token) g.Expect(err).NotTo(HaveOccurred()) out = token.Status.Token diff --git a/test/utils/utils.go b/test/utils/utils.go index c3d51ce..8319bc4 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -92,7 +92,7 @@ func IsPrometheusCRDsInstalled() bool { if err != nil { return false } - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range prometheusCRDs { for _, line := range crdList { if strings.Contains(line, crd) { @@ -153,7 +153,7 @@ func IsCertManagerCRDsInstalled() bool { } // Check if any of the Cert Manager CRDs are present - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range certManagerCRDs { for _, line := range crdList { if strings.Contains(line, crd) {