From 30a24c7adbf38aa4ef6f049daada8b7b1e7302e5 Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Sun, 22 Oct 2023 11:23:49 +0800 Subject: [PATCH] chore: pkg import only once --- pkg/controller/internal/testutil/cluster.go | 3 +-- pkg/controller/mysqlcluster/mysqlcluster_controller.go | 5 ++--- pkg/controller/mysqldatabase/db_controller_test.go | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/controller/internal/testutil/cluster.go b/pkg/controller/internal/testutil/cluster.go index f57c4662a..8292c2df9 100644 --- a/pkg/controller/internal/testutil/cluster.go +++ b/pkg/controller/internal/testutil/cluster.go @@ -24,7 +24,6 @@ import ( . "github.com/onsi/gomega" . "github.com/onsi/gomega/gstruct" gomegatypes "github.com/onsi/gomega/types" - corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" core "k8s.io/api/core/v1" @@ -111,7 +110,7 @@ func HaveClusterStatusReadyNodes(nodes int) gomegatypes.GomegaMatcher { } // HaveClusterCond is a helper func that returns a matcher to check for an existing condition in a ClusterCondition list. -func HaveClusterCond(condType api.ClusterConditionType, status corev1.ConditionStatus) gomegatypes.GomegaMatcher { +func HaveClusterCond(condType api.ClusterConditionType, status core.ConditionStatus) gomegatypes.GomegaMatcher { return PointTo(MatchFields(IgnoreExtras, Fields{ "Status": MatchFields(IgnoreExtras, Fields{ "Conditions": ContainElement(MatchFields(IgnoreExtras, Fields{ diff --git a/pkg/controller/mysqlcluster/mysqlcluster_controller.go b/pkg/controller/mysqlcluster/mysqlcluster_controller.go index a9f20ca79..0534580d2 100644 --- a/pkg/controller/mysqlcluster/mysqlcluster_controller.go +++ b/pkg/controller/mysqlcluster/mysqlcluster_controller.go @@ -37,7 +37,6 @@ import ( mysqlv1alpha1 "github.com/bitpoke/mysql-operator/pkg/apis/mysql/v1alpha1" - api "github.com/bitpoke/mysql-operator/pkg/apis/mysql/v1alpha1" cleaner "github.com/bitpoke/mysql-operator/pkg/controller/mysqlcluster/internal/cleaner" clustersyncer "github.com/bitpoke/mysql-operator/pkg/controller/mysqlcluster/internal/syncer" "github.com/bitpoke/mysql-operator/pkg/controller/mysqlcluster/internal/upgrades" @@ -191,11 +190,11 @@ func (r *ReconcileMysqlCluster) Reconcile(ctx context.Context, request reconcile // condition will be true all the time. When user set cluster's replicas to a value greater than 0, // the pods of the cluster will boot one by one, but node controller will not init mysql when FailoverInProgress // is true. - fip := cluster.GetClusterCondition(api.ClusterConditionFailoverInProgress) + fip := cluster.GetClusterCondition(mysqlv1alpha1.ClusterConditionFailoverInProgress) if fip != nil && fip.Status == corev1.ConditionTrue && *cluster.Spec.Replicas == 0 && cluster.Status.ReadyNodes == 0 { - cluster.UpdateStatusCondition(api.ClusterConditionFailoverInProgress, corev1.ConditionFalse, + cluster.UpdateStatusCondition(mysqlv1alpha1.ClusterConditionFailoverInProgress, corev1.ConditionFalse, "ClusterNotRunning", "cluster is not running") if sErr := r.Status().Update(context.TODO(), cluster.Unwrap()); sErr != nil { diff --git a/pkg/controller/mysqldatabase/db_controller_test.go b/pkg/controller/mysqldatabase/db_controller_test.go index 4eb978e20..f8333ec9a 100644 --- a/pkg/controller/mysqldatabase/db_controller_test.go +++ b/pkg/controller/mysqldatabase/db_controller_test.go @@ -26,7 +26,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" "sigs.k8s.io/controller-runtime/pkg/client" @@ -185,7 +184,7 @@ var _ = Describe("MySQL database controller", func() { It("should succeed if the cluster has been deleted", func() { // delete the cluster cluster := &mysqlv1alpha1.MysqlCluster{ - ObjectMeta: v1.ObjectMeta{ + ObjectMeta: metav1.ObjectMeta{ Name: clusterName, Namespace: db.Namespace, }, }