From e6204ff8b9de4593f182dcf7746788ec76563a93 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Thu, 5 Oct 2023 11:56:53 +0200 Subject: [PATCH] Use database helpers from mariadb-operator/api The lib-common/modules/database is moved to mariadb-operator/api to remove a circular dependency. --- controllers/ironic_controller.go | 5 ++--- controllers/ironicinspector_controller.go | 6 +++--- go.mod | 3 +-- go.sum | 6 ++---- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/controllers/ironic_controller.go b/controllers/ironic_controller.go index 570b8e8b..ca1ce05e 100644 --- a/controllers/ironic_controller.go +++ b/controllers/ironic_controller.go @@ -36,7 +36,6 @@ import ( common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac" oko_secret "github.com/openstack-k8s-operators/lib-common/modules/common/secret" util "github.com/openstack-k8s-operators/lib-common/modules/common/util" - database "github.com/openstack-k8s-operators/lib-common/modules/database" ironicv1 "github.com/openstack-k8s-operators/ironic-operator/api/v1beta1" keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1" @@ -221,7 +220,7 @@ func (r *IronicReconciler) reconcileDelete(ctx context.Context, instance *ironic r.Log.Info("Reconciling Ironic delete") // remove db finalizer first - db, err := database.GetDatabaseByName(ctx, helper, instance.Name) + db, err := mariadbv1.GetDatabaseByName(ctx, helper, instance.Name) if err != nil && !k8s_errors.IsNotFound(err) { return ctrl.Result{}, err } @@ -584,7 +583,7 @@ func (r *IronicReconciler) reconcileInit( // // create service DB instance // - db := database.NewDatabase( + db := mariadbv1.NewDatabase( instance.Name, instance.Name, instance.Spec.Secret, diff --git a/controllers/ironicinspector_controller.go b/controllers/ironicinspector_controller.go index 9d315639..69a2ec6f 100644 --- a/controllers/ironicinspector_controller.go +++ b/controllers/ironicinspector_controller.go @@ -25,6 +25,7 @@ import ( "github.com/go-logr/logr" ironic "github.com/openstack-k8s-operators/ironic-operator/pkg/ironic" ironicinspector "github.com/openstack-k8s-operators/ironic-operator/pkg/ironicinspector" + mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" common "github.com/openstack-k8s-operators/lib-common/modules/common" configmap "github.com/openstack-k8s-operators/lib-common/modules/common/configmap" @@ -37,7 +38,6 @@ import ( "github.com/openstack-k8s-operators/lib-common/modules/common/service" "github.com/openstack-k8s-operators/lib-common/modules/common/statefulset" util "github.com/openstack-k8s-operators/lib-common/modules/common/util" - database "github.com/openstack-k8s-operators/lib-common/modules/database" routev1 "github.com/openshift/api/route/v1" k8s_errors "k8s.io/apimachinery/pkg/api/errors" @@ -727,7 +727,7 @@ func (r *IronicInspectorReconciler) reconcileDeleteDatabase( helper *helper.Helper, ) (ctrl.Result, error) { // remove db finalizer first - db, err := database.GetDatabaseByName(ctx, helper, instance.Name) + db, err := mariadbv1.GetDatabaseByName(ctx, helper, instance.Name) if err != nil && !k8s_errors.IsNotFound(err) { return ctrl.Result{}, err } @@ -775,7 +775,7 @@ func (r *IronicInspectorReconciler) reconcileServiceDBinstance( serviceLabels map[string]string, ) (ctrl.Result, error) { databaseName := strings.Replace(instance.Name, "-", "_", -1) - db := database.NewDatabase( + db := mariadbv1.NewDatabase( databaseName, databaseName, instance.Spec.Secret, diff --git a/go.mod b/go.mod index a898c307..758eae67 100644 --- a/go.mod +++ b/go.mod @@ -12,9 +12,8 @@ require ( github.com/openstack-k8s-operators/ironic-operator/api v0.1.1-0.20230901035810-610538e222c9 github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20230925133339-116a3a39cdfa github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20231001084618-12369665b166 - github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20230927082538-4f614f333d17 github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20230927082538-4f614f333d17 - github.com/openstack-k8s-operators/mariadb-operator/api v0.1.1-0.20230928103342-106bb85983f4 + github.com/openstack-k8s-operators/mariadb-operator/api v0.3.0 k8s.io/api v0.26.9 k8s.io/apimachinery v0.27.1 k8s.io/client-go v0.26.9 diff --git a/go.sum b/go.sum index cafb77f8..d36d6cf5 100644 --- a/go.sum +++ b/go.sum @@ -242,14 +242,12 @@ github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20230925133339 github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20230925133339-116a3a39cdfa/go.mod h1:Zyp4nHS/JggPqlsMNM8WZN546oYINvGVlHA1NivE3sU= github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20231001084618-12369665b166 h1:pZPl9njjTchHSFf2OSuzyRxrRW8LLb1OscPxVNoATrk= github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20231001084618-12369665b166/go.mod h1:Ozg6SxfwOtMkiH553c0XQBWuygZQq4jDQCpR4hZqlxM= -github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20230927082538-4f614f333d17 h1:pjpbv2RqrBkAO7Gt/6wZ3SSjkd/1//c3s9TAOQ7Z0d4= -github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20230927082538-4f614f333d17/go.mod h1:RroLfB6Wstc+z7JVJY9o+6YPu+wBIzTAAfMpwhv7pDI= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.20230927082538-4f614f333d17 h1:d3HP0nEGNd8cQ088beQbyWzcgdMppD+Zs8HeoMdzRws= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.20230927082538-4f614f333d17/go.mod h1:+iJZo5alCeOGD/524hWWdlINA6zqY+MjfWT7cDcbvBE= github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20230927082538-4f614f333d17 h1:zJguNin+9IwRnGKy1A7ranxASKO1vTvWxoXwkCz8MWw= github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20230927082538-4f614f333d17/go.mod h1:YOFHrNK/QqCvZUPlDJYmDyaCkbKIB98V04uyofiC9a8= -github.com/openstack-k8s-operators/mariadb-operator/api v0.1.1-0.20230928103342-106bb85983f4 h1:37bbJ9XzpCvB+zZckdweJEEH3pqM6Q88OHH8eHFvlpI= -github.com/openstack-k8s-operators/mariadb-operator/api v0.1.1-0.20230928103342-106bb85983f4/go.mod h1:xhiz5wFdKWwVM7BF/VYon4TT3NuUPXp/Pyn2hWcp0CE= +github.com/openstack-k8s-operators/mariadb-operator/api v0.3.0 h1:FB0xB6whYM6W4XIncYo2mPiOJWkFsIOWtCT+UOtvOaQ= +github.com/openstack-k8s-operators/mariadb-operator/api v0.3.0/go.mod h1:xhiz5wFdKWwVM7BF/VYon4TT3NuUPXp/Pyn2hWcp0CE= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=