Skip to content

Commit

Permalink
Update go version to 1.21 (#91)
Browse files Browse the repository at this point in the history
* Update go version to 1.21

Signed-off-by: thepetk <thepetk@gmail.com>

* Pin image version

Signed-off-by: thepetk <thepetk@gmail.com>

---------

Signed-off-by: thepetk <thepetk@gmail.com>
  • Loading branch information
thepetk committed Jun 24, 2024
1 parent 1e66505 commit 94bde09
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 141 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

# Build the manager binary
FROM golang:1.19 as builder
FROM golang:1.21@sha256:b405b620c7b53ef64695c7da7c8396f411f381c1eb7da6713c585dd7eca1559b as builder
ARG TARGETARCH=amd64

WORKDIR /workspace
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ security setups.

### Development

- Go 1.19.x
- Go 1.21.x
- Docker / Podman
- Operator SDK 1.28.x

Expand Down
19 changes: 10 additions & 9 deletions api/v1alpha1/clusterdevfileregistrieslist_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand Down Expand Up @@ -54,7 +55,7 @@ func (r *ClusterDevfileRegistriesList) Default() {
var _ webhook.Validator = &ClusterDevfileRegistriesList{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *ClusterDevfileRegistriesList) ValidateCreate() error {
func (r *ClusterDevfileRegistriesList) ValidateCreate() (admission.Warnings, error) {
clusterdevfileregistrieslistlog.Info("validate create", "name", r.Name)
//limit CR creation to one per cluster
clusterDevfileRegistriesList := &ClusterDevfileRegistriesListList{}
Expand All @@ -63,29 +64,29 @@ func (r *ClusterDevfileRegistriesList) ValidateCreate() error {
}

if err := kubeClient.List(context.TODO(), clusterDevfileRegistriesList, listOpts...); err != nil {
return fmt.Errorf("error listing clusterDevfileRegistriesList custom resources: %v", err)
return nil, fmt.Errorf("error listing clusterDevfileRegistriesList custom resources: %v", err)
}

if len(clusterDevfileRegistriesList.Items) == 1 {
return fmt.Errorf(multiCRError)
return nil, fmt.Errorf(multiCRError)
}

if err := validateURLs(r.Spec.DevfileRegistries); err != nil {
return err
return nil, err
}

return IsNamespaceValid(r.Namespace)
return nil, IsNamespaceValid(r.Namespace)
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *ClusterDevfileRegistriesList) ValidateUpdate(old runtime.Object) error {
func (r *ClusterDevfileRegistriesList) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
clusterdevfileregistrieslistlog.Info("validate update", "name", r.Name)
//re-validate the entire list to ensure existing URLs have not gone stale
return validateURLs(r.Spec.DevfileRegistries)
return nil, validateURLs(r.Spec.DevfileRegistries)
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *ClusterDevfileRegistriesList) ValidateDelete() error {
func (r *ClusterDevfileRegistriesList) ValidateDelete() (admission.Warnings, error) {
clusterdevfileregistrieslistlog.Info("validate delete", "name", r.Name)
return nil
return nil, nil
}
19 changes: 10 additions & 9 deletions api/v1alpha1/devfileregistrieslist_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand Down Expand Up @@ -54,7 +55,7 @@ func (r *DevfileRegistriesList) Default() {
var _ webhook.Validator = &DevfileRegistriesList{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *DevfileRegistriesList) ValidateCreate() error {
func (r *DevfileRegistriesList) ValidateCreate() (admission.Warnings, error) {
devfileregistrieslistlog.Info("validate create", "name", r.Name)

//limit CR creation to one per namespace
Expand All @@ -64,29 +65,29 @@ func (r *DevfileRegistriesList) ValidateCreate() error {
}

if err := kubeClient.List(context.TODO(), devfileRegistriesList, listOpts...); err != nil {
return fmt.Errorf("error listing devfileRegistriesList custom resources: %v", err)
return nil, fmt.Errorf("error listing devfileRegistriesList custom resources: %v", err)
}

if len(devfileRegistriesList.Items) == 1 {
return fmt.Errorf("a DevfileRegistriesList instance already exists. Only one instance can exist on a namespace")
return nil, fmt.Errorf("a DevfileRegistriesList instance already exists. Only one instance can exist on a namespace")
}

if err := validateURLs(r.Spec.DevfileRegistries); err != nil {
return err
return nil, err
}

return IsNamespaceValid(r.Namespace)
return nil, IsNamespaceValid(r.Namespace)
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *DevfileRegistriesList) ValidateUpdate(old runtime.Object) error {
func (r *DevfileRegistriesList) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
devfileregistrieslistlog.Info("validate update", "name", r.Name)
//re-validate the entire list to ensure existing URLs have not gone stale
return validateURLs(r.Spec.DevfileRegistries)
return nil, validateURLs(r.Spec.DevfileRegistries)
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *DevfileRegistriesList) ValidateDelete() error {
func (r *DevfileRegistriesList) ValidateDelete() (admission.Warnings, error) {
devfileregistrieslistlog.Info("validate delete", "name", r.Name)
return nil
return nil, nil
}
13 changes: 7 additions & 6 deletions api/v1alpha1/devfileregistry_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand Down Expand Up @@ -48,19 +49,19 @@ func (r *DevfileRegistry) Default() {
var _ webhook.Validator = &DevfileRegistry{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *DevfileRegistry) ValidateCreate() error {
func (r *DevfileRegistry) ValidateCreate() (admission.Warnings, error) {
devfileregistrylog.Info("validate create", "name", r.Name)
return IsNamespaceValid(r.Namespace)
return nil, IsNamespaceValid(r.Namespace)
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *DevfileRegistry) ValidateUpdate(old runtime.Object) error {
func (r *DevfileRegistry) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
devfileregistrylog.Info("validate update", "name", r.Name)
return nil
return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *DevfileRegistry) ValidateDelete() error {
func (r *DevfileRegistry) ValidateDelete() (admission.Warnings, error) {
devfileregistrylog.Info("validate delete", "name", r.Name)
return nil
return nil, nil
}
18 changes: 12 additions & 6 deletions api/v1alpha1/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/envtest"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"
)

// These tests use Ginkgo (BDD-style Go testing framework). Refer to
Expand Down Expand Up @@ -119,12 +121,16 @@ var _ = BeforeSuite(func() {
// start webhook server using Manager
webhookInstallOptions := &testEnv.WebhookInstallOptions
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
Host: webhookInstallOptions.LocalServingHost,
Port: webhookInstallOptions.LocalServingPort,
CertDir: webhookInstallOptions.LocalServingCertDir,
LeaderElection: false,
MetricsBindAddress: "0",
Scheme: scheme,
WebhookServer: webhook.NewServer(webhook.Options{
Host: webhookInstallOptions.LocalServingHost,
Port: webhookInstallOptions.LocalServingPort,
CertDir: webhookInstallOptions.LocalServingCertDir,
}),
Metrics: metricsserver.Options{
BindAddress: "0",
},
LeaderElection: false,
})
Expect(err).NotTo(HaveOccurred())

Expand Down
58 changes: 29 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
module github.com/devfile/registry-operator

go 1.19
go 1.21

require (
github.com/devfile/registry-support/index/generator v0.0.0-20240311135803-6215550f93d4
github.com/devfile/registry-support/registry-library v0.0.0-20240311160550-e51ee8934746
github.com/go-logr/logr v1.4.1
github.com/hashicorp/go-multierror v1.1.1
github.com/onsi/ginkgo/v2 v2.9.1
github.com/onsi/gomega v1.27.4
github.com/onsi/ginkgo/v2 v2.14.0
github.com/onsi/gomega v1.30.0
github.com/openshift/api v0.0.0-20221013123532-e8b83ffadbab
github.com/stretchr/testify v1.8.4
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.26.10
k8s.io/apiextensions-apiserver v0.26.10
k8s.io/apimachinery v0.27.7
k8s.io/client-go v0.26.10
sigs.k8s.io/controller-runtime v0.14.7
k8s.io/api v0.29.2
k8s.io/apiextensions-apiserver v0.29.2
k8s.io/apimachinery v0.29.2
k8s.io/client-go v0.29.2
sigs.k8s.io/controller-runtime v0.17.5
)

require (
Expand All @@ -34,20 +34,20 @@ require (
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-logr/zapr v1.2.3 // 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/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // 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.4 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
Expand All @@ -60,7 +60,7 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand All @@ -69,40 +69,40 @@ require (
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.39.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.22.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.19.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/component-base v0.26.10 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 // indirect
k8s.io/component-base v0.29.2 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
oras.land/oras-go v1.2.5 // 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/yaml v1.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit 94bde09

Please sign in to comment.