Skip to content

Commit

Permalink
Multi-mod prep: Move all utilities into utils (#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
adracus authored Jan 11, 2023
1 parent 328184c commit 2791758
Show file tree
Hide file tree
Showing 77 changed files with 144 additions and 146 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ RUN go mod download

# Copy the go source
COPY api/ api/
COPY apiutils/ apiutils/
COPY broker/ broker/
COPY client-go/ client-go/
COPY onmetal-apiserver/ onmetal-apiserver/
COPY onmetal-controller-manager/ onmetal-controller-manager/
COPY ori/ ori/
COPY orictl/ orictl/
COPY poollet/ poollet/
COPY testutils/ testutils/
COPY utils/ utils/

ARG TARGETOS
Expand Down
4 changes: 2 additions & 2 deletions broker/common/sync/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
"sync"

. "github.com/onmetal/onmetal-api/broker/common/sync"
"github.com/onmetal/onmetal-api/testutils"
. "github.com/onmetal/onmetal-api/utils/testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("Sync", func() {
ctx := testutils.SetupContext()
ctx := SetupContext()

Context("MutexMap", func() {
const (
Expand Down
2 changes: 1 addition & 1 deletion broker/machinebroker/loadbalancers/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (

commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1"
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
"github.com/onmetal/onmetal-api/apiutils/annotations"
"github.com/onmetal/onmetal-api/broker/common/cleaner"
commonsync "github.com/onmetal/onmetal-api/broker/common/sync"
"github.com/onmetal/onmetal-api/broker/common/utils"
machinebrokerv1alpha1 "github.com/onmetal/onmetal-api/broker/machinebroker/api/v1alpha1"
"github.com/onmetal/onmetal-api/broker/machinebroker/apiutils"
"github.com/onmetal/onmetal-api/broker/machinebroker/cluster"
"github.com/onmetal/onmetal-api/utils/annotations"
utilslices "github.com/onmetal/onmetal-api/utils/slices"
"golang.org/x/exp/slices"
corev1 "k8s.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion broker/machinebroker/natgateways/natgateways.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (

commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1"
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
"github.com/onmetal/onmetal-api/apiutils/annotations"
"github.com/onmetal/onmetal-api/broker/common/cleaner"
commonsync "github.com/onmetal/onmetal-api/broker/common/sync"
"github.com/onmetal/onmetal-api/broker/common/utils"
machinebrokerv1alpha1 "github.com/onmetal/onmetal-api/broker/machinebroker/api/v1alpha1"
"github.com/onmetal/onmetal-api/broker/machinebroker/apiutils"
"github.com/onmetal/onmetal-api/broker/machinebroker/cluster"
"github.com/onmetal/onmetal-api/utils/annotations"
utilslices "github.com/onmetal/onmetal-api/utils/slices"
"golang.org/x/exp/slices"
corev1 "k8s.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion broker/machinebroker/networks/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (
"fmt"

networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
"github.com/onmetal/onmetal-api/apiutils/annotations"
"github.com/onmetal/onmetal-api/broker/common/cleaner"
commonsync "github.com/onmetal/onmetal-api/broker/common/sync"
machinebrokerv1alpha1 "github.com/onmetal/onmetal-api/broker/machinebroker/api/v1alpha1"
"github.com/onmetal/onmetal-api/broker/machinebroker/apiutils"
"github.com/onmetal/onmetal-api/broker/machinebroker/cluster"
"github.com/onmetal/onmetal-api/broker/machinebroker/transaction"
"github.com/onmetal/onmetal-api/utils/annotations"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down
4 changes: 2 additions & 2 deletions broker/machinebroker/server/machine_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
package server_test

import (
"github.com/onmetal/onmetal-api/testutils"
. "github.com/onmetal/onmetal-api/utils/testing"
. "github.com/onsi/ginkgo/v2"
)

var _ = Describe("CreateMachine", func() {
ctx := testutils.SetupContext()
ctx := SetupContext()
_, _ = SetupTest(ctx)

It("should correctly create a machine", func() {
Expand Down
2 changes: 1 addition & 1 deletion broker/machinebroker/server/networkinterface_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import (
"github.com/go-logr/logr"
commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1"
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
onmetalapiannotations "github.com/onmetal/onmetal-api/apiutils/annotations"
"github.com/onmetal/onmetal-api/broker/common/cleaner"
machinebrokerv1alpha1 "github.com/onmetal/onmetal-api/broker/machinebroker/api/v1alpha1"
"github.com/onmetal/onmetal-api/broker/machinebroker/apiutils"
ori "github.com/onmetal/onmetal-api/ori/apis/machine/v1alpha1"
onmetalapiannotations "github.com/onmetal/onmetal-api/utils/annotations"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import (
machinebrokerv1alpha1 "github.com/onmetal/onmetal-api/broker/machinebroker/api/v1alpha1"
ori "github.com/onmetal/onmetal-api/ori/apis/machine/v1alpha1"
orimeta "github.com/onmetal/onmetal-api/ori/apis/meta/v1alpha1"
"github.com/onmetal/onmetal-api/testutils"
. "github.com/onmetal/onmetal-api/utils/testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
)

var _ = Describe("NetworkInterfaceCreateLoadBalancerTarget", func() {
ctx := testutils.SetupContext()
ctx := SetupContext()
_, srv := SetupTest(ctx)

It("should correctly create a load balancer target for a network interface", func() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (
machinebrokerv1alpha1 "github.com/onmetal/onmetal-api/broker/machinebroker/api/v1alpha1"
ori "github.com/onmetal/onmetal-api/ori/apis/machine/v1alpha1"
orimeta "github.com/onmetal/onmetal-api/ori/apis/meta/v1alpha1"
"github.com/onmetal/onmetal-api/testutils"
. "github.com/onmetal/onmetal-api/utils/testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("NetworkInterfaceCreateNAT", func() {
ctx := testutils.SetupContext()
ctx := SetupContext()
_, srv := SetupTest(ctx)

It("should correctly create nat for a network interface", func() {
Expand Down
4 changes: 2 additions & 2 deletions broker/machinebroker/server/networkinterface_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/onmetal/onmetal-api/broker/machinebroker/apiutils"
ori "github.com/onmetal/onmetal-api/ori/apis/machine/v1alpha1"
orimeta "github.com/onmetal/onmetal-api/ori/apis/meta/v1alpha1"
"github.com/onmetal/onmetal-api/testutils"
. "github.com/onmetal/onmetal-api/utils/testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand All @@ -31,7 +31,7 @@ import (
)

var _ = Describe("CreateNetworkInterface", func() {
ctx := testutils.SetupContext()
ctx := SetupContext()
ns, srv := SetupTest(ctx)

It("should correctly create a network interface", func() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
ori "github.com/onmetal/onmetal-api/ori/apis/machine/v1alpha1"
orimeta "github.com/onmetal/onmetal-api/ori/apis/meta/v1alpha1"
"github.com/onmetal/onmetal-api/testutils"
. "github.com/onmetal/onmetal-api/utils/testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand All @@ -28,7 +28,7 @@ import (
)

var _ = Describe("NetworkInterfaceCreateVirtualIP", func() {
ctx := testutils.SetupContext()
ctx := SetupContext()
ns, srv := SetupTest(ctx)

It("should correctly create a virtual ip for a network interface", func() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ package server_test
import (
ori "github.com/onmetal/onmetal-api/ori/apis/machine/v1alpha1"
orimeta "github.com/onmetal/onmetal-api/ori/apis/meta/v1alpha1"
"github.com/onmetal/onmetal-api/testutils"
. "github.com/onmetal/onmetal-api/utils/testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("NetworkInterfaceDeleteLoadBalancer", func() {
ctx := testutils.SetupContext()
ctx := SetupContext()
_, srv := SetupTest(ctx)

It("should correctly delete a load balancer target for a network interface", func() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ package server_test
import (
ori "github.com/onmetal/onmetal-api/ori/apis/machine/v1alpha1"
orimeta "github.com/onmetal/onmetal-api/ori/apis/meta/v1alpha1"
"github.com/onmetal/onmetal-api/testutils"
. "github.com/onmetal/onmetal-api/utils/testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("NetworkInterfaceDeleteNAT", func() {
ctx := testutils.SetupContext()
ctx := SetupContext()
_, srv := SetupTest(ctx)

It("should correctly delete nat for a network interface", func() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ package server_test
import (
ori "github.com/onmetal/onmetal-api/ori/apis/machine/v1alpha1"
orimeta "github.com/onmetal/onmetal-api/ori/apis/meta/v1alpha1"
"github.com/onmetal/onmetal-api/testutils"
. "github.com/onmetal/onmetal-api/utils/testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("NetworkInterfaceDeletePrefix", func() {
ctx := testutils.SetupContext()
ctx := SetupContext()
_, srv := SetupTest(ctx)

It("should correctly delete a prefix for a network interface", func() {
Expand Down
14 changes: 7 additions & 7 deletions broker/machinebroker/server/server_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
storagev1alpha1 "github.com/onmetal/onmetal-api/api/storage/v1alpha1"
"github.com/onmetal/onmetal-api/broker/machinebroker/server"
"github.com/onmetal/onmetal-api/testutils/envtestutils"
"github.com/onmetal/onmetal-api/testutils/envtestutils/apiserver"
utilsenvtest "github.com/onmetal/onmetal-api/utils/envtest"
"github.com/onmetal/onmetal-api/utils/envtest/apiserver"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand All @@ -44,7 +44,7 @@ import (
var (
cfg *rest.Config
testEnv *envtest.Environment
testEnvExt *envtestutils.EnvironmentExtensions
testEnvExt *utilsenvtest.EnvironmentExtensions
k8sClient client.Client
)

Expand All @@ -71,18 +71,18 @@ var _ = BeforeSuite(func() {
var err error
By("bootstrapping test environment")
testEnv = &envtest.Environment{}
testEnvExt = &envtestutils.EnvironmentExtensions{
testEnvExt = &utilsenvtest.EnvironmentExtensions{
APIServiceDirectoryPaths: []string{
modutils.Dir("github.com/onmetal/onmetal-api", "config", "apiserver", "apiservice", "bases"),
},
ErrorIfAPIServicePathIsMissing: true,
}

cfg, err = envtestutils.StartWithExtensions(testEnv, testEnvExt)
cfg, err = utilsenvtest.StartWithExtensions(testEnv, testEnvExt)
Expect(err).NotTo(HaveOccurred())
Expect(cfg).NotTo(BeNil())

DeferCleanup(envtestutils.StopWithExtensions, testEnv, testEnvExt)
DeferCleanup(utilsenvtest.StopWithExtensions, testEnv, testEnvExt)

Expect(computev1alpha1.AddToScheme(scheme.Scheme)).To(Succeed())
Expect(networkingv1alpha1.AddToScheme(scheme.Scheme)).To(Succeed())
Expand All @@ -108,7 +108,7 @@ var _ = BeforeSuite(func() {
Expect(apiSrv.Start()).To(Succeed())
DeferCleanup(apiSrv.Stop)

Expect(envtestutils.WaitUntilAPIServicesReadyWithTimeout(apiServiceTimeout, testEnvExt, k8sClient, scheme.Scheme)).To(Succeed())
Expect(utilsenvtest.WaitUntilAPIServicesReadyWithTimeout(apiServiceTimeout, testEnvExt, k8sClient, scheme.Scheme)).To(Succeed())
})

func SetupTest(ctx context.Context) (*corev1.Namespace, *server.Server) {
Expand Down
2 changes: 1 addition & 1 deletion broker/machinebroker/server/volume_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (

"github.com/go-logr/logr"
storagev1alpha1 "github.com/onmetal/onmetal-api/api/storage/v1alpha1"
onmetalapiannotations "github.com/onmetal/onmetal-api/apiutils/annotations"
machinebrokerv1alpha1 "github.com/onmetal/onmetal-api/broker/machinebroker/api/v1alpha1"
"github.com/onmetal/onmetal-api/broker/machinebroker/apiutils"
ori "github.com/onmetal/onmetal-api/ori/apis/machine/v1alpha1"
onmetalapiannotations "github.com/onmetal/onmetal-api/utils/annotations"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down
4 changes: 2 additions & 2 deletions broker/machinebroker/server/volume_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/onmetal/onmetal-api/broker/machinebroker/apiutils"
ori "github.com/onmetal/onmetal-api/ori/apis/machine/v1alpha1"
orimeta "github.com/onmetal/onmetal-api/ori/apis/meta/v1alpha1"
"github.com/onmetal/onmetal-api/testutils"
. "github.com/onmetal/onmetal-api/utils/testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand All @@ -29,7 +29,7 @@ import (
)

var _ = Describe("CreateVolume", func() {
ctx := testutils.SetupContext()
ctx := SetupContext()
ns, srv := SetupTest(ctx)

It("Should correctly create a volume", func() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.19

require (
github.com/bits-and-blooms/bitset v1.4.0
github.com/blang/semver/v4 v4.0.0
github.com/go-logr/logr v1.2.3
github.com/gogo/protobuf v1.3.2
github.com/google/go-cmp v0.5.9
Expand Down Expand Up @@ -38,7 +39,6 @@ require (
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion onmetal-apiserver/internal/api/validation/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/onmetal/controller-utils/set"
"github.com/onmetal/onmetal-api/api/common/v1alpha1"
"github.com/onmetal/onmetal-api/apiutils/equality"
"github.com/onmetal/onmetal-api/utils/equality"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/validation"
"k8s.io/apimachinery/pkg/util/validation/field"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ package validation
import (
"fmt"

"github.com/onmetal/onmetal-api/apiutils/equality"
onmetalapivalidation "github.com/onmetal/onmetal-api/onmetal-apiserver/internal/api/validation"
commonvalidation "github.com/onmetal/onmetal-api/onmetal-apiserver/internal/apis/common/validation"
"github.com/onmetal/onmetal-api/onmetal-apiserver/internal/apis/ipam"
"github.com/onmetal/onmetal-api/utils/equality"
apivalidation "k8s.io/apimachinery/pkg/api/validation"
metav1validation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
"k8s.io/apimachinery/pkg/util/validation/field"
Expand Down
2 changes: 1 addition & 1 deletion onmetal-apiserver/internal/app/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
ipamv1alpha1 "github.com/onmetal/onmetal-api/api/ipam/v1alpha1"
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
storagev1alpha1 "github.com/onmetal/onmetal-api/api/storage/v1alpha1"
apiequality "github.com/onmetal/onmetal-api/apiutils/equality"
"github.com/onmetal/onmetal-api/client-go/informers"
clientset "github.com/onmetal/onmetal-api/client-go/onmetalapi"
onmetalopenapi "github.com/onmetal/onmetal-api/client-go/openapi"
Expand All @@ -33,6 +32,7 @@ import (
"github.com/onmetal/onmetal-api/onmetal-apiserver/internal/apis/compute"
"github.com/onmetal/onmetal-api/onmetal-apiserver/internal/apiserver"
"github.com/onmetal/onmetal-api/onmetal-apiserver/internal/machinepoollet/client"
apiequality "github.com/onmetal/onmetal-api/utils/equality"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/api/equality"
Expand Down
Loading

0 comments on commit 2791758

Please sign in to comment.