Repository: vshn/k8up
Pull request #473 (2021-08-05 09:48:48)

Move library functions to new operator package
## Summary

This PR moves all library code to a new `operator` package in preparation for https://github.com/vshn/k8up/issues/359. The same was done in the wrestic repository (https://github.com/vshn/wrestic/pull/101).

The code that is originally generated by the operator-sdk cli is excepted in order to maintain compatibility for future operator-sdk upgrades.

<!--
Thank you for your pull request. Please provide a description above and
review the checklist below.
-->

## Checklist
<!--
Remove items that do not apply. For completed items, change [ ] to [x].
-->

- [x] Keep pull requests small so they can be easily reviewed.
- [x] Categorize the PR by setting a good title and adding one of the labels:
      `bug`, `enhancement`, `documentation`, `change`, `breaking`,
      as they show up in the changelog
- [ ] Update the documentation.
- [x] Update tests.
- [x] Link this PR to related issues.

<!--
NOTE: these things are not required to open a PR and can be done afterwards,
while the PR is open.
-->


cimnine: I believe some of the codeclimate warnings are legit, yet they existed before and I'd rather focus on the job at hand at the moment. Hence I vote to ignore them once again.

Patch:
diff --git a/api/v1alpha1/backend.go b/api/v1alpha1/backend.go
index cf28c490..90332816 100644
--- a/api/v1alpha1/backend.go
+++ b/api/v1alpha1/backend.go
@@ -4,9 +4,9 @@ import (
 	"fmt"
 	"reflect"
 
-	"github.com/vshn/k8up/cfg"
-
 	corev1 "k8s.io/api/core/v1"
+
+	"github.com/vshn/k8up/operator/cfg"
 )
 
 type (
diff --git a/cmd/operator/main.go b/cmd/operator/main.go
index 98def962..da2617c9 100644
--- a/cmd/operator/main.go
+++ b/cmd/operator/main.go
@@ -5,23 +5,22 @@ import (
 	"os"
 	"strings"
 
+	_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
+
+	"github.com/knadh/koanf"
+	"github.com/knadh/koanf/providers/env"
 	"go.uber.org/zap/zapcore"
+	batchv1 "k8s.io/api/batch/v1"
 	"k8s.io/apimachinery/pkg/runtime"
 	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
 	clientgoscheme "k8s.io/client-go/kubernetes/scheme"
-	_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
 	ctrl "sigs.k8s.io/controller-runtime"
 	"sigs.k8s.io/controller-runtime/pkg/log/zap"
 
-	batchv1 "k8s.io/api/batch/v1"
-
-	"github.com/knadh/koanf"
-	"github.com/knadh/koanf/providers/env"
-
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
 	"github.com/vshn/k8up/controllers"
-	"github.com/vshn/k8up/executor"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/executor"
 	// +kubebuilder:scaffold:imports
 )
 
diff --git a/controllers/archive_controller.go b/controllers/archive_controller.go
index 23800955..5fdba2fb 100644
--- a/controllers/archive_controller.go
+++ b/controllers/archive_controller.go
@@ -12,9 +12,9 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/predicate"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/handler"
-	"github.com/vshn/k8up/job"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/handler"
+	"github.com/vshn/k8up/operator/job"
 )
 
 // ArchiveReconciler reconciles a Archive object
diff --git a/controllers/backup_controller.go b/controllers/backup_controller.go
index 8dba6395..83822ef6 100644
--- a/controllers/backup_controller.go
+++ b/controllers/backup_controller.go
@@ -12,9 +12,9 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/predicate"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/handler"
-	"github.com/vshn/k8up/job"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/handler"
+	"github.com/vshn/k8up/operator/job"
 )
 
 // BackupReconciler reconciles a Backup object
diff --git a/controllers/check_controller.go b/controllers/check_controller.go
index 4c2e301e..5c34cf88 100644
--- a/controllers/check_controller.go
+++ b/controllers/check_controller.go
@@ -12,9 +12,9 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/predicate"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/handler"
-	"github.com/vshn/k8up/job"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/handler"
+	"github.com/vshn/k8up/operator/job"
 )
 
 // CheckReconciler reconciles a Check object
diff --git a/controllers/job_controller.go b/controllers/job_controller.go
index 519ca088..a07286de 100644
--- a/controllers/job_controller.go
+++ b/controllers/job_controller.go
@@ -4,14 +4,15 @@ import (
 	"context"
 
 	"github.com/go-logr/logr"
-	"github.com/vshn/k8up/handler"
-	"github.com/vshn/k8up/job"
 	batchv1 "k8s.io/api/batch/v1"
 	"k8s.io/apimachinery/pkg/api/errors"
 	"k8s.io/apimachinery/pkg/runtime"
 	ctrl "sigs.k8s.io/controller-runtime"
 	"sigs.k8s.io/controller-runtime/pkg/client"
 	"sigs.k8s.io/controller-runtime/pkg/reconcile"
+
+	"github.com/vshn/k8up/operator/handler"
+	"github.com/vshn/k8up/operator/job"
 )
 
 // JobReconciler reconciles a Job object
diff --git a/controllers/prune_controller.go b/controllers/prune_controller.go
index b64f6466..f40a28cd 100644
--- a/controllers/prune_controller.go
+++ b/controllers/prune_controller.go
@@ -12,9 +12,9 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/predicate"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/handler"
-	"github.com/vshn/k8up/job"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/handler"
+	"github.com/vshn/k8up/operator/job"
 )
 
 // PruneReconciler reconciles a Prune object
diff --git a/controllers/restore_controller.go b/controllers/restore_controller.go
index b6359e2c..1786202f 100644
--- a/controllers/restore_controller.go
+++ b/controllers/restore_controller.go
@@ -12,9 +12,9 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/predicate"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/handler"
-	"github.com/vshn/k8up/job"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/handler"
+	"github.com/vshn/k8up/operator/job"
 )
 
 // RestoreReconciler reconciles a Restore object
diff --git a/controllers/schedule_controller.go b/controllers/schedule_controller.go
index 05caa4aa..a161280c 100644
--- a/controllers/schedule_controller.go
+++ b/controllers/schedule_controller.go
@@ -13,9 +13,9 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/reconcile"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/handler"
-	"github.com/vshn/k8up/job"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/handler"
+	"github.com/vshn/k8up/operator/job"
 )
 
 // ScheduleReconciler reconciles a Schedule object
diff --git a/cfg/config.go b/operator/cfg/config.go
similarity index 100%
rename from cfg/config.go
rename to operator/cfg/config.go
diff --git a/cfg/config_test.go b/operator/cfg/config_test.go
similarity index 100%
rename from cfg/config_test.go
rename to operator/cfg/config_test.go
diff --git a/executor/archive.go b/operator/executor/archive.go
similarity index 97%
rename from executor/archive.go
rename to operator/executor/archive.go
index e1cd7c16..f0d8e920 100644
--- a/executor/archive.go
+++ b/operator/executor/archive.go
@@ -3,15 +3,15 @@ package executor
 import (
 	stderrors "errors"
 
-	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/job"
-	"github.com/vshn/k8up/observer"
-
 	batchv1 "k8s.io/api/batch/v1"
 	corev1 "k8s.io/api/core/v1"
 	apierrors "k8s.io/apimachinery/pkg/api/errors"
 	"k8s.io/apimachinery/pkg/types"
+
+	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/job"
+	"github.com/vshn/k8up/operator/observer"
 )
 
 const archivePath = "/archive"
diff --git a/executor/backup.go b/operator/executor/backup.go
similarity index 98%
rename from executor/backup.go
rename to operator/executor/backup.go
index 9d8faafc..1b2c99cf 100644
--- a/executor/backup.go
+++ b/operator/executor/backup.go
@@ -9,8 +9,8 @@ import (
 	"k8s.io/apimachinery/pkg/types"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/job"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/job"
 )
 
 // BackupExecutor creates a batch.job object on the cluster. It merges all the
diff --git a/executor/backup_utils.go b/operator/executor/backup_utils.go
similarity index 97%
rename from executor/backup_utils.go
rename to operator/executor/backup_utils.go
index d7c0437f..f1d600c0 100644
--- a/executor/backup_utils.go
+++ b/operator/executor/backup_utils.go
@@ -8,8 +8,8 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"sigs.k8s.io/controller-runtime/pkg/client"
 
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/observer"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/observer"
 )
 
 func (b *BackupExecutor) fetchPVCs(list client.ObjectList) error {
diff --git a/executor/check.go b/operator/executor/check.go
similarity index 96%
rename from executor/check.go
rename to operator/executor/check.go
index aa82a9f5..31ca96dd 100644
--- a/executor/check.go
+++ b/operator/executor/check.go
@@ -4,14 +4,13 @@ import (
 	stderrors "errors"
 
 	batchv1 "k8s.io/api/batch/v1"
+	corev1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/types"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/job"
-	"github.com/vshn/k8up/observer"
-
-	corev1 "k8s.io/api/core/v1"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/job"
+	"github.com/vshn/k8up/operator/observer"
 )
 
 // CheckExecutor will execute the batch.job for checks.
diff --git a/executor/cleaner/cleaner.go b/operator/executor/cleaner/cleaner.go
similarity index 97%
rename from executor/cleaner/cleaner.go
rename to operator/executor/cleaner/cleaner.go
index c0df3f78..18a38977 100644
--- a/executor/cleaner/cleaner.go
+++ b/operator/executor/cleaner/cleaner.go
@@ -5,14 +5,14 @@ import (
 	"fmt"
 	"sort"
 
-	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/job"
-
 	"github.com/go-logr/logr"
 	"k8s.io/apimachinery/pkg/api/errors"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"sigs.k8s.io/controller-runtime/pkg/client"
+
+	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/job"
 )
 
 // ObjectCleaner cleans old, finished job objects.
diff --git a/executor/generic.go b/operator/executor/generic.go
similarity index 97%
rename from executor/generic.go
rename to operator/executor/generic.go
index bf21f27a..7a8e538e 100644
--- a/executor/generic.go
+++ b/operator/executor/generic.go
@@ -7,20 +7,19 @@ package executor
 import (
 	"fmt"
 
-	"k8s.io/apimachinery/pkg/types"
-
-	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/executor/cleaner"
-	"github.com/vshn/k8up/job"
-	"github.com/vshn/k8up/observer"
-	"github.com/vshn/k8up/queue"
-
 	"github.com/go-logr/logr"
 	"github.com/imdario/mergo"
 	corev1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/api/errors"
+	"k8s.io/apimachinery/pkg/types"
 	"sigs.k8s.io/controller-runtime/pkg/client"
+
+	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/executor/cleaner"
+	"github.com/vshn/k8up/operator/job"
+	"github.com/vshn/k8up/operator/observer"
+	"github.com/vshn/k8up/operator/queue"
 )
 
 type generic struct {
diff --git a/executor/generic_test.go b/operator/executor/generic_test.go
similarity index 100%
rename from executor/generic_test.go
rename to operator/executor/generic_test.go
diff --git a/executor/prebackup.go b/operator/executor/prebackup.go
similarity index 100%
rename from executor/prebackup.go
rename to operator/executor/prebackup.go
diff --git a/executor/prebackup_utils.go b/operator/executor/prebackup_utils.go
similarity index 99%
rename from executor/prebackup_utils.go
rename to operator/executor/prebackup_utils.go
index 0668b558..9b226be7 100644
--- a/executor/prebackup_utils.go
+++ b/operator/executor/prebackup_utils.go
@@ -13,7 +13,7 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
+	"github.com/vshn/k8up/operator/cfg"
 )
 
 // fetchPreBackupPodTemplates fetches all PreBackupPods from the same namespace as the originating backup.
diff --git a/executor/prune.go b/operator/executor/prune.go
similarity index 97%
rename from executor/prune.go
rename to operator/executor/prune.go
index 11c137ba..e8e0af2f 100644
--- a/executor/prune.go
+++ b/operator/executor/prune.go
@@ -5,15 +5,15 @@ import (
 	"strconv"
 	"strings"
 
-	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/job"
-	"github.com/vshn/k8up/observer"
-
 	batchv1 "k8s.io/api/batch/v1"
 	corev1 "k8s.io/api/core/v1"
 	apierrors "k8s.io/apimachinery/pkg/api/errors"
 	"k8s.io/apimachinery/pkg/types"
+
+	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/job"
+	"github.com/vshn/k8up/operator/observer"
 )
 
 // PruneExecutor will execute the batch.job for Prunes.
diff --git a/executor/restore.go b/operator/executor/restore.go
similarity index 97%
rename from executor/restore.go
rename to operator/executor/restore.go
index fd400ebd..79bba6c1 100644
--- a/executor/restore.go
+++ b/operator/executor/restore.go
@@ -5,15 +5,15 @@ import (
 	"fmt"
 	"strconv"
 
-	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/job"
-	"github.com/vshn/k8up/observer"
-
 	batchv1 "k8s.io/api/batch/v1"
 	corev1 "k8s.io/api/core/v1"
 	apierrors "k8s.io/apimachinery/pkg/api/errors"
 	"k8s.io/apimachinery/pkg/types"
+
+	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/job"
+	"github.com/vshn/k8up/operator/observer"
 )
 
 const restorePath = "/restore"
diff --git a/executor/worker.go b/operator/executor/worker.go
similarity index 96%
rename from executor/worker.go
rename to operator/executor/worker.go
index f4ee0c63..11082ccd 100644
--- a/executor/worker.go
+++ b/operator/executor/worker.go
@@ -5,10 +5,10 @@ package executor
 import (
 	"time"
 
-	"github.com/vshn/k8up/observer"
-	"github.com/vshn/k8up/queue"
-
 	"k8s.io/apimachinery/pkg/api/errors"
+
+	"github.com/vshn/k8up/operator/observer"
+	"github.com/vshn/k8up/operator/queue"
 )
 
 var (
diff --git a/handler/effectiveschedule.go b/operator/handler/effectiveschedule.go
similarity index 99%
rename from handler/effectiveschedule.go
rename to operator/handler/effectiveschedule.go
index 0e55e90e..c7535290 100644
--- a/handler/effectiveschedule.go
+++ b/operator/handler/effectiveschedule.go
@@ -10,7 +10,7 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/client"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
+	"github.com/vshn/k8up/operator/cfg"
 )
 
 func (s *ScheduleHandler) newEffectiveSchedule(jobType k8upv1alpha1.JobType) k8upv1alpha1.EffectiveSchedule {
diff --git a/handler/generic.go b/operator/handler/generic.go
similarity index 81%
rename from handler/generic.go
rename to operator/handler/generic.go
index 010addc7..06b3155b 100644
--- a/handler/generic.go
+++ b/operator/handler/generic.go
@@ -1,9 +1,9 @@
 package handler
 
 import (
-	"github.com/vshn/k8up/executor"
-	"github.com/vshn/k8up/job"
-	"github.com/vshn/k8up/queue"
+	"github.com/vshn/k8up/operator/executor"
+	"github.com/vshn/k8up/operator/job"
+	"github.com/vshn/k8up/operator/queue"
 )
 
 // Handler is the generic job handler for most of the k8up jobs.
diff --git a/handler/job.go b/operator/handler/job.go
similarity index 96%
rename from handler/job.go
rename to operator/handler/job.go
index b0334864..101dbcb4 100644
--- a/handler/job.go
+++ b/operator/handler/job.go
@@ -9,8 +9,8 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
 
 	"github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/job"
-	"github.com/vshn/k8up/observer"
+	"github.com/vshn/k8up/operator/job"
+	"github.com/vshn/k8up/operator/observer"
 )
 
 const (
diff --git a/handler/randomizer.go b/operator/handler/randomizer.go
similarity index 100%
rename from handler/randomizer.go
rename to operator/handler/randomizer.go
diff --git a/handler/randomizer_test.go b/operator/handler/randomizer_test.go
similarity index 100%
rename from handler/randomizer_test.go
rename to operator/handler/randomizer_test.go
diff --git a/handler/schedule.go b/operator/handler/schedule.go
similarity index 97%
rename from handler/schedule.go
rename to operator/handler/schedule.go
index c0f03522..0726e82c 100644
--- a/handler/schedule.go
+++ b/operator/handler/schedule.go
@@ -8,9 +8,9 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
-	"github.com/vshn/k8up/job"
-	"github.com/vshn/k8up/scheduler"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/job"
+	"github.com/vshn/k8up/operator/scheduler"
 )
 
 // ScheduleHandler handles the reconciles for the schedules. Schedules are a special
diff --git a/job/job.go b/operator/job/job.go
similarity index 98%
rename from job/job.go
rename to operator/job/job.go
index 24a11649..36b46d0c 100644
--- a/job/job.go
+++ b/operator/job/job.go
@@ -6,7 +6,7 @@ import (
 	"context"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
+	"github.com/vshn/k8up/operator/cfg"
 
 	"github.com/go-logr/logr"
 	batchv1 "k8s.io/api/batch/v1"
diff --git a/observer/observer.go b/operator/observer/observer.go
similarity index 100%
rename from observer/observer.go
rename to operator/observer/observer.go
diff --git a/observer/observer_test.go b/operator/observer/observer_test.go
similarity index 100%
rename from observer/observer_test.go
rename to operator/observer/observer_test.go
diff --git a/queue/execution.go b/operator/queue/execution.go
similarity index 100%
rename from queue/execution.go
rename to operator/queue/execution.go
diff --git a/queue/execution_test.go b/operator/queue/execution_test.go
similarity index 100%
rename from queue/execution_test.go
rename to operator/queue/execution_test.go
diff --git a/queue/priority.go b/operator/queue/priority.go
similarity index 100%
rename from queue/priority.go
rename to operator/queue/priority.go
diff --git a/scheduler/scheduler.go b/operator/scheduler/scheduler.go
similarity index 99%
rename from scheduler/scheduler.go
rename to operator/scheduler/scheduler.go
index c9684b13..0fcb16ad 100644
--- a/scheduler/scheduler.go
+++ b/operator/scheduler/scheduler.go
@@ -16,7 +16,7 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/metrics"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/job"
+	"github.com/vshn/k8up/operator/job"
 )
 
 type (


Test patch:
diff --git a/api/v1alpha1/backend_test.go b/api/v1alpha1/backend_test.go
index 66500adc..adadd75e 100644
--- a/api/v1alpha1/backend_test.go
+++ b/api/v1alpha1/backend_test.go
@@ -6,7 +6,7 @@ import (
 	"github.com/stretchr/testify/assert"
 	corev1 "k8s.io/api/core/v1"
 
-	"github.com/vshn/k8up/cfg"
+	"github.com/vshn/k8up/operator/cfg"
 )
 
 var tests = map[string]struct {
diff --git a/cmd/operator/main_test.go b/cmd/operator/main_test.go
index 1148ec8a..4040631a 100644
--- a/cmd/operator/main_test.go
+++ b/cmd/operator/main_test.go
@@ -7,7 +7,7 @@ import (
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
 
-	"github.com/vshn/k8up/cfg"
+	"github.com/vshn/k8up/operator/cfg"
 )
 
 func Test_loadEnvironmentVariables(t *testing.T) {
diff --git a/controllers/backup_integration_test.go b/controllers/backup_integration_test.go
index 3fe505fc..37daf176 100644
--- a/controllers/backup_integration_test.go
+++ b/controllers/backup_integration_test.go
@@ -13,7 +13,7 @@ import (
 	k8upv1a1 "github.com/vshn/k8up/api/v1alpha1"
 	"github.com/vshn/k8up/controllers"
 	"github.com/vshn/k8up/envtest"
-	"github.com/vshn/k8up/observer"
+	"github.com/vshn/k8up/operator/observer"
 )
 
 type BackupTestSuite struct {
diff --git a/controllers/backup_it_utils_test.go b/controllers/backup_it_utils_test.go
index fd4188b4..1eb6c18b 100644
--- a/controllers/backup_it_utils_test.go
+++ b/controllers/backup_it_utils_test.go
@@ -20,7 +20,7 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/client"
 
 	k8upv1a1 "github.com/vshn/k8up/api/v1alpha1"
-	k8upObserver "github.com/vshn/k8up/observer"
+	k8upObserver "github.com/vshn/k8up/operator/observer"
 )
 
 func (ts *BackupTestSuite) newPreBackupPod() *k8upv1a1.PreBackupPod {
diff --git a/controllers/check_integration_test.go b/controllers/check_integration_test.go
index ec368e53..0540a27c 100644
--- a/controllers/check_integration_test.go
+++ b/controllers/check_integration_test.go
@@ -19,7 +19,7 @@ import (
 	k8upv1a1 "github.com/vshn/k8up/api/v1alpha1"
 	"github.com/vshn/k8up/controllers"
 	"github.com/vshn/k8up/envtest"
-	"github.com/vshn/k8up/observer"
+	"github.com/vshn/k8up/operator/observer"
 )
 
 type CheckTestSuite struct {
diff --git a/controllers/envsuite_test.go b/controllers/envsuite_test.go
index 3925941a..fce0fcd3 100644
--- a/controllers/envsuite_test.go
+++ b/controllers/envsuite_test.go
@@ -33,7 +33,7 @@ import (
 	// +kubebuilder:scaffold:imports
 
 	k8upv1a1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/executor"
+	"github.com/vshn/k8up/operator/executor"
 )
 
 var InvalidNSNameCharacters = regexp.MustCompile("[^a-z0-9-]")
diff --git a/controllers/schedule_it_test.go b/controllers/schedule_it_test.go
index 0a505ec3..d7ca4498 100644
--- a/controllers/schedule_it_test.go
+++ b/controllers/schedule_it_test.go
@@ -10,10 +10,10 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
 	"github.com/vshn/k8up/controllers"
-	"github.com/vshn/k8up/handler"
-	"github.com/vshn/k8up/scheduler"
+	"github.com/vshn/k8up/operator/cfg"
+	"github.com/vshn/k8up/operator/handler"
+	"github.com/vshn/k8up/operator/scheduler"
 )
 
 type (
diff --git a/controllers/schedule_it_utils_test.go b/controllers/schedule_it_utils_test.go
index 76b0aef1..e4fa8880 100644
--- a/controllers/schedule_it_utils_test.go
+++ b/controllers/schedule_it_utils_test.go
@@ -7,7 +7,7 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/handler"
+	"github.com/vshn/k8up/operator/handler"
 )
 
 func (ts *ScheduleControllerTestSuite) givenScheduleResource(schedule k8upv1alpha1.ScheduleDefinition) {
diff --git a/envtest/envtest.go b/envtest/envtest.go
index 3681f05c..ba2f1352 100644
--- a/envtest/envtest.go
+++ b/envtest/envtest.go
@@ -32,7 +32,7 @@ import (
 	// +kubebuilder:scaffold:imports
 
 	k8upv1a1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/executor"
+	"github.com/vshn/k8up/operator/executor"
 )
 
 var InvalidNSNameCharacters = regexp.MustCompile("[^a-z0-9-]")
diff --git a/executor/cleaner/cleaner_test.go b/operator/executor/cleaner/cleaner_test.go
similarity index 97%
rename from executor/cleaner/cleaner_test.go
rename to operator/executor/cleaner/cleaner_test.go
index 08fcb532..0e510170 100644
--- a/executor/cleaner/cleaner_test.go
+++ b/operator/executor/cleaner/cleaner_test.go
@@ -5,15 +5,15 @@ package cleaner_test
 import (
 	"testing"
 
-	k8upv1a1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/envtest"
-	"github.com/vshn/k8up/executor/cleaner"
-	"github.com/vshn/k8up/job"
-	"sigs.k8s.io/controller-runtime/pkg/client"
-
 	"github.com/stretchr/testify/suite"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/util/uuid"
+	"sigs.k8s.io/controller-runtime/pkg/client"
+
+	k8upv1a1 "github.com/vshn/k8up/api/v1alpha1"
+	"github.com/vshn/k8up/envtest"
+	"github.com/vshn/k8up/operator/executor/cleaner"
+	"github.com/vshn/k8up/operator/job"
 )
 
 type CleanerTestSuite struct {
diff --git a/executor/restore_test.go b/operator/executor/restore_test.go
similarity index 99%
rename from executor/restore_test.go
rename to operator/executor/restore_test.go
index 6ec95318..afbcd25e 100644
--- a/executor/restore_test.go
+++ b/operator/executor/restore_test.go
@@ -10,7 +10,7 @@ import (
 	"k8s.io/apimachinery/pkg/runtime"
 
 	k8upv1a1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/job"
+	"github.com/vshn/k8up/operator/job"
 )
 
 var (
diff --git a/handler/effectiveschedule_test.go b/operator/handler/effectiveschedule_test.go
similarity index 98%
rename from handler/effectiveschedule_test.go
rename to operator/handler/effectiveschedule_test.go
index 0bd16a30..6c6021c6 100644
--- a/handler/effectiveschedule_test.go
+++ b/operator/handler/effectiveschedule_test.go
@@ -8,7 +8,7 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/log/zap"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/job"
+	"github.com/vshn/k8up/operator/job"
 )
 
 func TestScheduleHandler_findExistingSchedule(t *testing.T) {
diff --git a/handler/schedule_test.go b/operator/handler/schedule_test.go
similarity index 99%
rename from handler/schedule_test.go
rename to operator/handler/schedule_test.go
index 4cdca152..4849f60e 100644
--- a/handler/schedule_test.go
+++ b/operator/handler/schedule_test.go
@@ -9,7 +9,7 @@ import (
 	"k8s.io/apimachinery/pkg/api/resource"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/cfg"
+	"github.com/vshn/k8up/operator/cfg"
 )
 
 func TestScheduleHandler_mergeResourcesWithDefaults(t *testing.T) {
diff --git a/job/status.go b/operator/job/status.go
similarity index 100%
rename from job/status.go
rename to operator/job/status.go
diff --git a/job/status_test.go b/operator/job/status_test.go
similarity index 97%
rename from job/status_test.go
rename to operator/job/status_test.go
index dfbee6cd..60647cb3 100644
--- a/job/status_test.go
+++ b/operator/job/status_test.go
@@ -8,7 +8,7 @@ import (
 	"k8s.io/apimachinery/pkg/util/uuid"
 
 	k8upv1a1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/job"
+	"github.com/vshn/k8up/operator/job"
 )
 
 func TestGroupByStatus(t *testing.T) {
diff --git a/scheduler/scheduler_test.go b/operator/scheduler/scheduler_test.go
similarity index 99%
rename from scheduler/scheduler_test.go
rename to operator/scheduler/scheduler_test.go
index 6b15fe00..c3091f60 100644
--- a/scheduler/scheduler_test.go
+++ b/operator/scheduler/scheduler_test.go
@@ -10,7 +10,7 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/log/zap"
 
 	k8upv1alpha1 "github.com/vshn/k8up/api/v1alpha1"
-	"github.com/vshn/k8up/job"
+	"github.com/vshn/k8up/operator/job"
 )
 
 func TestScheduler_SyncSchedules(t *testing.T) {