From 07f1e549317912f083d3a944079e518f507481f6 Mon Sep 17 00:00:00 2001 From: Abhisek Dwivedi Date: Wed, 7 Aug 2024 17:31:52 +0530 Subject: [PATCH] Refactored cluster code --- controllers/{ => cluster}/access_control.go | 2 +- controllers/{ => cluster}/aero_info_calls.go | 2 +- controllers/{ => cluster}/aerospikecluster_controller.go | 2 +- controllers/{ => cluster}/client_policy.go | 2 +- controllers/{ => cluster}/configmap.go | 2 +- controllers/{ => cluster}/pod.go | 2 +- controllers/{ => cluster}/poddistruptionbudget.go | 2 +- controllers/{ => cluster}/pvc.go | 2 +- controllers/{ => cluster}/rack.go | 2 +- controllers/{ => cluster}/reconciler.go | 2 +- controllers/{ => cluster}/scripts/common-env.sh | 0 controllers/{ => cluster}/scripts/copy-templates.sh | 0 controllers/{ => cluster}/scripts/create-aerospike-conf.sh | 0 .../{ => cluster}/scripts/create_pod_status_patch.py | 0 controllers/{ => cluster}/scripts/initialize.sh | 0 .../{ => cluster}/scripts/refresh-cmap-restart-asd.sh | 0 controllers/{ => cluster}/scripts/restart-asd.sh | 0 controllers/{ => cluster}/scripts/update-pod-status.sh | 0 controllers/{ => cluster}/service.go | 2 +- controllers/{ => cluster}/statefulset.go | 2 +- controllers/{ => cluster}/strong_consistency.go | 2 +- main.go | 7 ++++--- test/cluster/access_control_test.go | 2 +- test/cluster/network_policy_test.go | 2 +- test/cluster/test_client.go | 2 +- 25 files changed, 20 insertions(+), 19 deletions(-) rename controllers/{ => cluster}/access_control.go (99%) rename controllers/{ => cluster}/aero_info_calls.go (99%) rename controllers/{ => cluster}/aerospikecluster_controller.go (99%) rename controllers/{ => cluster}/client_policy.go (99%) rename controllers/{ => cluster}/configmap.go (99%) rename controllers/{ => cluster}/pod.go (99%) rename controllers/{ => cluster}/poddistruptionbudget.go (99%) rename controllers/{ => cluster}/pvc.go (99%) rename controllers/{ => cluster}/rack.go (99%) rename controllers/{ => cluster}/reconciler.go (99%) rename controllers/{ => cluster}/scripts/common-env.sh (100%) rename controllers/{ => cluster}/scripts/copy-templates.sh (100%) rename controllers/{ => cluster}/scripts/create-aerospike-conf.sh (100%) rename controllers/{ => cluster}/scripts/create_pod_status_patch.py (100%) rename controllers/{ => cluster}/scripts/initialize.sh (100%) rename controllers/{ => cluster}/scripts/refresh-cmap-restart-asd.sh (100%) rename controllers/{ => cluster}/scripts/restart-asd.sh (100%) rename controllers/{ => cluster}/scripts/update-pod-status.sh (100%) rename controllers/{ => cluster}/service.go (99%) rename controllers/{ => cluster}/statefulset.go (99%) rename controllers/{ => cluster}/strong_consistency.go (99%) diff --git a/controllers/access_control.go b/controllers/cluster/access_control.go similarity index 99% rename from controllers/access_control.go rename to controllers/cluster/access_control.go index 6c7042e4a..9a2fe3d6d 100644 --- a/controllers/access_control.go +++ b/controllers/cluster/access_control.go @@ -1,4 +1,4 @@ -package controllers +package cluster // Aerospike access control reconciliation of access control. diff --git a/controllers/aero_info_calls.go b/controllers/cluster/aero_info_calls.go similarity index 99% rename from controllers/aero_info_calls.go rename to controllers/cluster/aero_info_calls.go index 3aeaa1b27..df1e6dc9b 100644 --- a/controllers/aero_info_calls.go +++ b/controllers/cluster/aero_info_calls.go @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controllers +package cluster import ( "context" diff --git a/controllers/aerospikecluster_controller.go b/controllers/cluster/aerospikecluster_controller.go similarity index 99% rename from controllers/aerospikecluster_controller.go rename to controllers/cluster/aerospikecluster_controller.go index 025af166b..abcfd76bf 100644 --- a/controllers/aerospikecluster_controller.go +++ b/controllers/cluster/aerospikecluster_controller.go @@ -1,4 +1,4 @@ -package controllers +package cluster import ( "context" diff --git a/controllers/client_policy.go b/controllers/cluster/client_policy.go similarity index 99% rename from controllers/client_policy.go rename to controllers/cluster/client_policy.go index 0e0ebf09c..1cd6f8290 100644 --- a/controllers/client_policy.go +++ b/controllers/cluster/client_policy.go @@ -1,4 +1,4 @@ -package controllers +package cluster import ( "context" diff --git a/controllers/configmap.go b/controllers/cluster/configmap.go similarity index 99% rename from controllers/configmap.go rename to controllers/cluster/configmap.go index c9271b98d..93d1f41a6 100644 --- a/controllers/configmap.go +++ b/controllers/cluster/configmap.go @@ -1,4 +1,4 @@ -package controllers +package cluster import ( "bytes" diff --git a/controllers/pod.go b/controllers/cluster/pod.go similarity index 99% rename from controllers/pod.go rename to controllers/cluster/pod.go index 25204a597..64eef6232 100644 --- a/controllers/pod.go +++ b/controllers/cluster/pod.go @@ -1,4 +1,4 @@ -package controllers +package cluster import ( "context" diff --git a/controllers/poddistruptionbudget.go b/controllers/cluster/poddistruptionbudget.go similarity index 99% rename from controllers/poddistruptionbudget.go rename to controllers/cluster/poddistruptionbudget.go index 9899a2d68..e13287f2d 100644 --- a/controllers/poddistruptionbudget.go +++ b/controllers/cluster/poddistruptionbudget.go @@ -1,4 +1,4 @@ -package controllers +package cluster import ( "context" diff --git a/controllers/pvc.go b/controllers/cluster/pvc.go similarity index 99% rename from controllers/pvc.go rename to controllers/cluster/pvc.go index 7a316e617..f91d0f649 100644 --- a/controllers/pvc.go +++ b/controllers/cluster/pvc.go @@ -1,4 +1,4 @@ -package controllers +package cluster import ( "context" diff --git a/controllers/rack.go b/controllers/cluster/rack.go similarity index 99% rename from controllers/rack.go rename to controllers/cluster/rack.go index d51d49aca..458fdad2d 100644 --- a/controllers/rack.go +++ b/controllers/cluster/rack.go @@ -1,4 +1,4 @@ -package controllers +package cluster import ( "context" diff --git a/controllers/reconciler.go b/controllers/cluster/reconciler.go similarity index 99% rename from controllers/reconciler.go rename to controllers/cluster/reconciler.go index 995e694d0..b9a99aacd 100644 --- a/controllers/reconciler.go +++ b/controllers/cluster/reconciler.go @@ -1,4 +1,4 @@ -package controllers +package cluster import ( "context" diff --git a/controllers/scripts/common-env.sh b/controllers/cluster/scripts/common-env.sh similarity index 100% rename from controllers/scripts/common-env.sh rename to controllers/cluster/scripts/common-env.sh diff --git a/controllers/scripts/copy-templates.sh b/controllers/cluster/scripts/copy-templates.sh similarity index 100% rename from controllers/scripts/copy-templates.sh rename to controllers/cluster/scripts/copy-templates.sh diff --git a/controllers/scripts/create-aerospike-conf.sh b/controllers/cluster/scripts/create-aerospike-conf.sh similarity index 100% rename from controllers/scripts/create-aerospike-conf.sh rename to controllers/cluster/scripts/create-aerospike-conf.sh diff --git a/controllers/scripts/create_pod_status_patch.py b/controllers/cluster/scripts/create_pod_status_patch.py similarity index 100% rename from controllers/scripts/create_pod_status_patch.py rename to controllers/cluster/scripts/create_pod_status_patch.py diff --git a/controllers/scripts/initialize.sh b/controllers/cluster/scripts/initialize.sh similarity index 100% rename from controllers/scripts/initialize.sh rename to controllers/cluster/scripts/initialize.sh diff --git a/controllers/scripts/refresh-cmap-restart-asd.sh b/controllers/cluster/scripts/refresh-cmap-restart-asd.sh similarity index 100% rename from controllers/scripts/refresh-cmap-restart-asd.sh rename to controllers/cluster/scripts/refresh-cmap-restart-asd.sh diff --git a/controllers/scripts/restart-asd.sh b/controllers/cluster/scripts/restart-asd.sh similarity index 100% rename from controllers/scripts/restart-asd.sh rename to controllers/cluster/scripts/restart-asd.sh diff --git a/controllers/scripts/update-pod-status.sh b/controllers/cluster/scripts/update-pod-status.sh similarity index 100% rename from controllers/scripts/update-pod-status.sh rename to controllers/cluster/scripts/update-pod-status.sh diff --git a/controllers/service.go b/controllers/cluster/service.go similarity index 99% rename from controllers/service.go rename to controllers/cluster/service.go index 3c5f86b07..65f86325e 100644 --- a/controllers/service.go +++ b/controllers/cluster/service.go @@ -1,4 +1,4 @@ -package controllers +package cluster import ( "context" diff --git a/controllers/statefulset.go b/controllers/cluster/statefulset.go similarity index 99% rename from controllers/statefulset.go rename to controllers/cluster/statefulset.go index f213b6d74..ff0d47c7c 100644 --- a/controllers/statefulset.go +++ b/controllers/cluster/statefulset.go @@ -1,4 +1,4 @@ -package controllers +package cluster import ( "context" diff --git a/controllers/strong_consistency.go b/controllers/cluster/strong_consistency.go similarity index 99% rename from controllers/strong_consistency.go rename to controllers/cluster/strong_consistency.go index aeb178c8c..3b996de48 100644 --- a/controllers/strong_consistency.go +++ b/controllers/cluster/strong_consistency.go @@ -1,4 +1,4 @@ -package controllers +package cluster import ( gosets "github.com/deckarep/golang-set/v2" diff --git a/main.go b/main.go index af7d3f1f4..e511ca8ba 100644 --- a/main.go +++ b/main.go @@ -23,11 +23,12 @@ import ( "github.com/aerospike/aerospike-management-lib/asconfig" asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" - // +kubebuilder:scaffold:imports asdbv1beta1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1beta1" - aerospikecluster "github.com/aerospike/aerospike-kubernetes-operator/controllers" "github.com/aerospike/aerospike-kubernetes-operator/controllers/backup" backupservice "github.com/aerospike/aerospike-kubernetes-operator/controllers/backup-service" + + // +kubebuilder:scaffold:imports + "github.com/aerospike/aerospike-kubernetes-operator/controllers/cluster" "github.com/aerospike/aerospike-kubernetes-operator/controllers/restore" "github.com/aerospike/aerospike-kubernetes-operator/pkg/configschema" ) @@ -137,7 +138,7 @@ func main() { eventBroadcaster.StartStructuredLogging(0) eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")}) - if err = (&aerospikecluster.AerospikeClusterReconciler{ + if err = (&cluster.AerospikeClusterReconciler{ Client: client, KubeClient: kubeClient, KubeConfig: kubeConfig, diff --git a/test/cluster/access_control_test.go b/test/cluster/access_control_test.go index 64ebee231..97417aa68 100644 --- a/test/cluster/access_control_test.go +++ b/test/cluster/access_control_test.go @@ -20,7 +20,7 @@ import ( as "github.com/aerospike/aerospike-client-go/v7" asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" - aerospikecluster "github.com/aerospike/aerospike-kubernetes-operator/controllers" + aerospikecluster "github.com/aerospike/aerospike-kubernetes-operator/controllers/cluster" "github.com/aerospike/aerospike-kubernetes-operator/test" ) diff --git a/test/cluster/network_policy_test.go b/test/cluster/network_policy_test.go index fd72ba5b7..ec4191030 100644 --- a/test/cluster/network_policy_test.go +++ b/test/cluster/network_policy_test.go @@ -22,7 +22,7 @@ import ( "k8s.io/utils/ptr" asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" - aerospikecluster "github.com/aerospike/aerospike-kubernetes-operator/controllers" + aerospikecluster "github.com/aerospike/aerospike-kubernetes-operator/controllers/cluster" "github.com/aerospike/aerospike-kubernetes-operator/test" "github.com/aerospike/aerospike-management-lib/deployment" ) diff --git a/test/cluster/test_client.go b/test/cluster/test_client.go index b02adf90c..a046e6934 100644 --- a/test/cluster/test_client.go +++ b/test/cluster/test_client.go @@ -21,7 +21,7 @@ import ( as "github.com/aerospike/aerospike-client-go/v7" asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" - aerospikecluster "github.com/aerospike/aerospike-kubernetes-operator/controllers" + aerospikecluster "github.com/aerospike/aerospike-kubernetes-operator/controllers/cluster" ) // FromSecretPasswordProvider provides user password from the secret provided in AerospikeUserSpec.