Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update go version to 1.21 #91

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 as builder
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Show resolved Hide resolved
thepetk marked this conversation as resolved.
Show resolved Hide resolved
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) {
thepetk marked this conversation as resolved.
Show resolved Hide resolved
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
Loading