Skip to content

Commit

Permalink
upgrade controller-runtime version (#1034)
Browse files Browse the repository at this point in the history
upgrade controller runtime version

Signed-off-by: coderth <coderth@outlook.com>
  • Loading branch information
CoderTH committed May 24, 2023
1 parent 4831f9a commit 98058f8
Show file tree
Hide file tree
Showing 68 changed files with 17,562 additions and 12,833 deletions.
3 changes: 1 addition & 2 deletions apis/goharbor.io/v1alpha3/harbor_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package v1alpha3_test
import (
goharborv1 "github.com/goharbor/harbor-operator/apis/goharbor.io/v1alpha3"
harbormetav1 "github.com/goharbor/harbor-operator/apis/meta/v1alpha1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
)
Expand Down
2 changes: 1 addition & 1 deletion apis/goharbor.io/v1alpha3/v1alpha3_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v1alpha3_test
import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

Expand Down
2 changes: 1 addition & 1 deletion apis/goharbor.io/v1beta1/v1beta1_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v1beta1_test
import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

Expand Down
2 changes: 1 addition & 1 deletion controllers/goharbor/chartmuseum/chartmuseum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

goharborv1 "github.com/goharbor/harbor-operator/apis/goharbor.io/v1beta1"
Expand Down
13 changes: 4 additions & 9 deletions controllers/goharbor/chartmuseum/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"context"
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/goharbor/harbor-operator/controllers/goharbor/chartmuseum"
"github.com/goharbor/harbor-operator/controllers/goharbor/internal/test"
"github.com/goharbor/harbor-operator/controllers/goharbor/internal/test/controllers"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
)

var (
Expand All @@ -21,22 +20,18 @@ var (
func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

RunSpecsWithDefaultAndCustomReporters(t,
"Controller Suite",
[]Reporter{printer.NewlineReporter{}})
RunSpecs(t, "Controller Suite")
}

var _ = BeforeSuite(func(done Done) {
var _ = BeforeSuite(func() {
ctx = test.InitSuite()

className := test.NewName("class")

reconciler = controllers.NewChartMuseum(ctx, className)

test.StartManager(ctx)

close(done)
}, 60)
})

var _ = AfterSuite(func() {
defer test.AfterSuite(ctx)
Expand Down
3 changes: 1 addition & 2 deletions controllers/goharbor/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import (
"context"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gstruct"

Expand Down
2 changes: 1 addition & 1 deletion controllers/goharbor/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

goharborv1 "github.com/goharbor/harbor-operator/apis/goharbor.io/v1beta1"
Expand Down
13 changes: 4 additions & 9 deletions controllers/goharbor/core/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ import (
"context"
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/goharbor/harbor-operator/controllers/goharbor/core"
"github.com/goharbor/harbor-operator/controllers/goharbor/internal/test"
"github.com/goharbor/harbor-operator/controllers/goharbor/internal/test/controllers"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
)

var (
Expand All @@ -34,22 +33,18 @@ var (
func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

RunSpecsWithDefaultAndCustomReporters(t,
"Controller Suite",
[]Reporter{printer.NewlineReporter{}})
RunSpecs(t, "Controller Suite")
}

var _ = BeforeSuite(func(done Done) {
var _ = BeforeSuite(func() {
ctx = test.InitSuite()

className := test.NewName("class")

reconciler = controllers.NewCore(ctx, className)

test.StartManager(ctx)

close(done)
}, 60)
})

var _ = AfterSuite(func() {
defer test.AfterSuite(ctx)
Expand Down
6 changes: 3 additions & 3 deletions controllers/goharbor/harbor/harbor_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package harbor_test

import (
"context"
"io/ioutil"
"os"
"strings"
"testing"

goharborv1 "github.com/goharbor/harbor-operator/apis/goharbor.io/v1beta1"
"github.com/goharbor/harbor-operator/controllers"
"github.com/goharbor/harbor-operator/controllers/goharbor/harbor"
"github.com/goharbor/harbor-operator/pkg/config"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
Expand All @@ -24,7 +24,7 @@ func TestHarbor(t *testing.T) {
}

func fileString(filePath string) string {
content, err := ioutil.ReadFile(filePath)
content, err := os.ReadFile(filePath)
Expect(err).NotTo(HaveOccurred())

return strings.TrimSpace(string(content))
Expand Down
2 changes: 1 addition & 1 deletion controllers/goharbor/harbor/harbor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/goharbor/harbor-operator/controllers/goharbor/harbor"
"github.com/goharbor/harbor-operator/controllers/goharbor/internal/test"
"github.com/goharbor/harbor-operator/pkg/image"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down
2 changes: 1 addition & 1 deletion controllers/goharbor/harbor/trivy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/goharbor/harbor-operator/pkg/controller"
"github.com/goharbor/harbor-operator/pkg/factories/owner"
"github.com/goharbor/harbor-operator/pkg/graph"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/ovh/configstore"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down
2 changes: 1 addition & 1 deletion controllers/goharbor/harbor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/goharbor/harbor-operator/pkg/factories/logger"
certv1 "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
cmmeta "github.com/jetstack/cert-manager/pkg/apis/meta/v1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
Expand Down
2 changes: 1 addition & 1 deletion controllers/goharbor/internal/test/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/goharbor/harbor-operator/pkg/factories/application"
"github.com/goharbor/harbor-operator/pkg/factories/logger"
"github.com/goharbor/harbor-operator/pkg/scheme"
"github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/rest"
Expand Down
4 changes: 2 additions & 2 deletions controllers/goharbor/internal/test/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"math/rand"

"github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -72,7 +72,7 @@ func InitNamespace(ctxFactory func() context.Context) *corev1.Namespace {
})

ginkgo.AfterEach(func() {
if ginkgo.CurrentGinkgoTestDescription().Failed && keepNamespaceOnFailure {
if ginkgo.CurrentSpecReport().Failed() && keepNamespaceOnFailure {
fmt.Fprintf(ginkgo.GinkgoWriter, "keeping namespace %s\n", ns.GetName())

return
Expand Down
2 changes: 1 addition & 1 deletion controllers/goharbor/internal/test/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package test
import (
"context"

"github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/manager"
Expand Down
8 changes: 3 additions & 5 deletions controllers/goharbor/internal/test/pods/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/goharbor/harbor-operator/controllers/goharbor/internal/test"
"github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -43,10 +43,8 @@ func (pods Pods) Logs(ctx context.Context) map[string][]byte {
}

func LogsAll(ctx *context.Context, name func() types.NamespacedName) interface{} {
return func(done ginkgo.Done) {
defer close(done)

if !ginkgo.CurrentGinkgoTestDescription().Failed {
return func() {
if !ginkgo.CurrentSpecReport().Failed() {
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/go-logr/logr"
"github.com/goharbor/harbor-operator/controllers/goharbor/internal/test"
"github.com/goharbor/harbor-operator/controllers/goharbor/internal/test/pods"
"github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/rest"
Expand Down
2 changes: 1 addition & 1 deletion controllers/goharbor/jobservice/jobservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gstruct"

Expand Down
13 changes: 4 additions & 9 deletions controllers/goharbor/jobservice/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"context"
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/goharbor/harbor-operator/controllers/goharbor/internal/test"
"github.com/goharbor/harbor-operator/controllers/goharbor/internal/test/controllers"
"github.com/goharbor/harbor-operator/controllers/goharbor/jobservice"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
)

var (
Expand All @@ -21,22 +20,18 @@ var (
func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

RunSpecsWithDefaultAndCustomReporters(t,
"Controller Suite",
[]Reporter{printer.NewlineReporter{}})
RunSpecs(t, "Controller Suite")
}

var _ = BeforeSuite(func(done Done) {
var _ = BeforeSuite(func() {
ctx = test.InitSuite()

className := test.NewName("class")

reconciler = controllers.NewJobService(ctx, className)

test.StartManager(ctx)

close(done)
}, 60)
})

var _ = AfterSuite(func() {
defer test.AfterSuite(ctx)
Expand Down
2 changes: 1 addition & 1 deletion controllers/goharbor/notaryserver/notaryserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

goharborv1 "github.com/goharbor/harbor-operator/apis/goharbor.io/v1beta1"
Expand Down
13 changes: 4 additions & 9 deletions controllers/goharbor/notaryserver/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"context"
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/goharbor/harbor-operator/controllers/goharbor/internal/test"
"github.com/goharbor/harbor-operator/controllers/goharbor/internal/test/controllers"
"github.com/goharbor/harbor-operator/controllers/goharbor/notaryserver"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
)

var (
Expand All @@ -21,22 +20,18 @@ var (
func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

RunSpecsWithDefaultAndCustomReporters(t,
"Controller Suite",
[]Reporter{printer.NewlineReporter{}})
RunSpecs(t, "Controller Suite")
}

var _ = BeforeSuite(func(done Done) {
var _ = BeforeSuite(func() {
ctx = test.InitSuite()

className := test.NewName("class")

reconciler = controllers.NewNotaryServer(ctx, className)

test.StartManager(ctx)

close(done)
}, 60)
})

var _ = AfterSuite(func() {
defer test.AfterSuite(ctx)
Expand Down
2 changes: 1 addition & 1 deletion controllers/goharbor/notarysigner/notarysigner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

goharborv1 "github.com/goharbor/harbor-operator/apis/goharbor.io/v1beta1"
Expand Down
Loading

0 comments on commit 98058f8

Please sign in to comment.