Skip to content

Commit

Permalink
Bump go version (1.22.2) (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
I065450 authored Jun 5, 2024
1 parent 069e9c3 commit 7063318
Show file tree
Hide file tree
Showing 18 changed files with 180 additions and 227 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.21.0
- name: Set up Go 1.22.2
uses: actions/setup-go@v2
with:
go-version: 1.21.0
go-version: 1.22.2

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ SED ?= sed -i
ifeq ($(shell go env GOOS),darwin)
SED = sed -i ''
endif
TEST_PACKAGES=$(shell go list ./... | egrep "controllers|internal/utils|api|client" | egrep -v "client/sm/smfakes" | paste -sd " " -)

GO_TEST = go test ./... -coverpkg=$(go list ./... | egrep -v "fakes|test" | paste -sd "," -) -coverprofile=$(TEST_PROFILE) -ginkgo.flakeAttempts=3
GO_TEST = go test $(TEST_PACKAGES) -coverprofile=$(TEST_PROFILE) -ginkgo.flakeAttempts=3

all: manager

# Run tests go test and coverage
test: generate fmt vet manifests
KUBEBUILDER_ASSETS="$(shell setup-envtest use 1.19.2 --bin-dir /usr/local/bin -p path)" $(GO_TEST)
KUBEBUILDER_ASSETS="$(shell setup-envtest use --bin-dir /usr/local/bin -p path)" $(GO_TEST)

# Build manager binary
manager: generate fmt vet
Expand Down Expand Up @@ -86,7 +87,7 @@ ifeq (, $(shell which controller-gen))
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.0 ;\
go install sigs.k8s.io/controller-tools/cmd/controller-gen@latest ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
Expand Down
1 change: 0 additions & 1 deletion api/v1/serviceinstance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ type ServiceInstanceSpec struct {

// Indicates the desired shared state
// +optional
// +kubebuilder:default={}
Shared *bool `json:"shared,omitempty"`

// Provisioning parameters for the instance.
Expand Down
2 changes: 1 addition & 1 deletion api/v1/webhooks/servicebinding_mutating_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
var bindinglog = logf.Log.WithName("servicebinding-webhook")

type ServiceBindingDefaulter struct {
Decoder *admission.Decoder
Decoder admission.Decoder
}

func (s *ServiceBindingDefaulter) Handle(_ context.Context, req admission.Request) admission.Response {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/webhooks/serviceinstance_mutating_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
var instancelog = logf.Log.WithName("serviceinstance-webhook")

type ServiceInstanceDefaulter struct {
Decoder *admission.Decoder
Decoder admission.Decoder
}

func (s *ServiceInstanceDefaulter) Handle(_ context.Context, req admission.Request) admission.Response {
Expand Down
1 change: 0 additions & 1 deletion api/v1alpha1/serviceinstance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ type ServiceInstanceSpec struct {

// Indicates the desired shared state
// +optional
// +kubebuilder:default={}
Shared *bool `json:"shared,omitempty"`

// Provisioning parameters for the instance.
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/services.cloud.sap.com_servicebindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
uid:
description: A unique value that identifies this user across time.
If this user is deleted and another user by the same name is
Expand Down Expand Up @@ -418,6 +419,7 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
uid:
description: A unique value that identifies this user across time.
If this user is deleted and another user by the same name is
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/services.cloud.sap.com_serviceinstances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
uid:
description: A unique value that identifies this user across time.
If this user is deleted and another user by the same name is
Expand Down Expand Up @@ -397,6 +398,7 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
uid:
description: A unique value that identifies this user across time.
If this user is deleted and another user by the same name is
Expand Down
5 changes: 3 additions & 2 deletions controllers/serviceinstance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"fmt"
"net/http"

"k8s.io/utils/ptr"

"github.com/SAP/sap-btp-service-operator/api/common"
"github.com/SAP/sap-btp-service-operator/internal/config"
"github.com/SAP/sap-btp-service-operator/internal/utils"
Expand All @@ -36,7 +38,6 @@ import (

servicesv1 "github.com/SAP/sap-btp-service-operator/api/v1"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/utils/pointer"

"github.com/google/uuid"

Expand Down Expand Up @@ -663,7 +664,7 @@ func getTags(tags []byte) ([]string, error) {

func getSpecHash(serviceInstance *servicesv1.ServiceInstance) string {
spec := serviceInstance.Spec
spec.Shared = pointer.Bool(false)
spec.Shared = ptr.To(false)
specBytes, _ := json.Marshal(spec)
s := string(specBytes)
return generateEncodedMD5Hash(s)
Expand Down
50 changes: 21 additions & 29 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"testing"
"time"

"sigs.k8s.io/controller-runtime/pkg/metrics/server"

"github.com/SAP/sap-btp-service-operator/api/common"
"github.com/SAP/sap-btp-service-operator/internal/utils"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
Expand Down Expand Up @@ -72,13 +74,16 @@ const (

fakeBindingID = "fake-binding-id"
bindingTestNamespace = "test-namespace"
StopTimeout = 60
)

var (
cfg *rest.Config
k8sClient client.Client
testEnv *envtest.Environment
fakeClient *smfakes.FakeClient
cancel context.CancelFunc
ctx context.Context
)

func TestAPIs(t *testing.T) {
Expand Down Expand Up @@ -117,12 +122,16 @@ var _ = BeforeSuite(func(done Done) {
webhookInstallOptions := &testEnv.WebhookInstallOptions

k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme.Scheme,
Host: webhookInstallOptions.LocalServingHost,
Port: webhookInstallOptions.LocalServingPort,
CertDir: webhookInstallOptions.LocalServingCertDir,
LeaderElection: false,
MetricsBindAddress: "0",
Scheme: scheme.Scheme,
WebhookServer: webhook.NewServer(webhook.Options{
Host: webhookInstallOptions.LocalServingHost,
Port: webhookInstallOptions.LocalServingPort,
CertDir: webhookInstallOptions.LocalServingCertDir,
}),
LeaderElection: false,
Metrics: server.Options{
BindAddress: "0",
},
})
Expect(err).ToNot(HaveOccurred())

Expand Down Expand Up @@ -167,15 +176,17 @@ var _ = BeforeSuite(func(done Done) {
Expect(err).ToNot(HaveOccurred())

// +kubebuilder:scaffold:webhook
ctx, cancel = context.WithCancel(context.TODO())

By("starting the k8s manager")
go func() {
defer GinkgoRecover()
err = k8sManager.Start(ctrl.SetupSignalHandler())
err = k8sManager.Start(ctx)
Expect(err).ToNot(HaveOccurred())
}()

By("waiting for the webhook server to get ready")

dialer := &net.Dialer{Timeout: time.Second}
addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort)
Eventually(func() error {
Expand All @@ -202,12 +213,13 @@ var _ = BeforeSuite(func(done Done) {

printSection("Finished BeforeSuite")
close(done)
}, 60)
}, StopTimeout)

var _ = AfterSuite(func() {
printSection("Starting AfterSuite")

By("tearing down the test environment")
cancel()

err := testEnv.Stop()
Expect(err).ToNot(HaveOccurred())

Expand Down Expand Up @@ -259,26 +271,6 @@ func waitForResourceCondition(ctx context.Context, resource common.SAPBTPResourc
resource),
)
}
func waitForResourceAnnotationRemove(ctx context.Context, resource common.SAPBTPResource, annotationsKey ...string) {
key := getResourceNamespacedName(resource)
Eventually(func() bool {
if err := k8sClient.Get(ctx, key, resource); err != nil {
return false
}
for _, annotationKey := range annotationsKey {
_, ok := resource.GetAnnotations()[annotationKey]
if ok {
return false
}
}
return true
}, timeout*2, interval).Should(BeTrue(),
eventuallyMsgForResource(
fmt.Sprintf("annotation %s was not removed", annotationsKey),
key,
resource),
)
}

func getResourceNamespacedName(resource client.Object) types.NamespacedName {
return types.NamespacedName{Namespace: resource.GetNamespace(), Name: resource.GetName()}
Expand Down
60 changes: 29 additions & 31 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
module github.com/SAP/sap-btp-service-operator

go 1.21
go 1.22.2

require (
github.com/Masterminds/sprig/v3 v3.2.3
github.com/go-logr/logr v1.2.4
github.com/google/uuid v1.3.0
github.com/go-logr/logr v1.4.2
github.com/google/uuid v1.6.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/lithammer/dedent v1.1.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.27.10
github.com/onsi/gomega v1.33.1
github.com/pkg/errors v0.9.1
golang.org/x/oauth2 v0.12.0
k8s.io/api v0.27.3
k8s.io/apimachinery v0.27.3
k8s.io/client-go v0.27.3
k8s.io/utils v0.0.0-20230209194617-a36077c30491
sigs.k8s.io/controller-runtime v0.15.0
sigs.k8s.io/yaml v1.3.0
golang.org/x/oauth2 v0.20.0
k8s.io/api v0.30.1
k8s.io/apimachinery v0.30.1
k8s.io/client-go v0.30.1
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
sigs.k8s.io/controller-runtime v0.18.3
sigs.k8s.io/yaml v1.4.0
)

require (
Expand All @@ -26,19 +26,19 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand All @@ -59,26 +59,24 @@ require (
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.8.4 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.27.2 // indirect
k8s.io/component-base v0.27.2 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/apiextensions-apiserver v0.30.1 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)
Loading

0 comments on commit 7063318

Please sign in to comment.