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

Chore: golang 1.21 #3002

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

shyukri
Copy link

@shyukri shyukri commented Jan 28, 2024

Checklist:

This has also gone bigger than anticipated:

  • bump golangci-lint; drop abandoned linters && add recommendations
  • move k3d to 1.27 and fix CI
  • update github action setup-go to v5
  • ...

@whynowy
Copy link
Member

whynowy commented Jan 30, 2024

Thanks @shyukri ! could you figure out why the lint is failing?

@shyukri shyukri force-pushed the chore/golang-1.21 branch 2 times, most recently from 971fdf4 to c6150ad Compare January 30, 2024 15:06
@shyukri
Copy link
Author

shyukri commented Jan 30, 2024

Issues even after upgrading the linter:

``` # make lint

INFO [runner] linters took 26.82040325s with stages: goanalysis_metalinter: 26.7034705s
test/util/util.go:21:19: string metadata.name= has 3 occurrences, make it a constant (goconst)
fieldSelector := "metadata.name=" + eventBusName
^
controllers/eventbus/installer/jetstream_test.go:74:18: string eventbus- has 6 occurrences, make it a constant (goconst)
assert.Equal(t, "eventbus-"+testJetStreamEventBus.Name+"-js", n)
^
common/string_keyed_map.go:7:2: items is unused (structcheck)
items map[string]T
^
common/string_keyed_map.go:8:2: lock is unused (structcheck)
lock *sync.RWMutex
^
controllers/config.go:7:2: import 'github.com/fsnotify/fsnotify' is not allowed from list 'Main' (depguard)
"github.com/fsnotify/fsnotify"
^
controllers/config.go:8:2: import 'github.com/spf13/viper' is not allowed from list 'Main' (depguard)
"github.com/spf13/viper"
^
eventbus/jetstream/base/jetstream.go:8:2: import 'github.com/argoproj/argo-events/common' is not allowed from list 'Main' (depguard)
"github.com/argoproj/argo-events/common"
^
eventbus/jetstream/base/jetstream.go:9:2: import 'github.com/argoproj/argo-events/eventbus/common' is not allowed from list 'Main' (depguard)
eventbuscommon "github.com/argoproj/argo-events/eventbus/common"
^
eventbus/jetstream/base/jetstream.go:10:2: import 'github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1' is not allowed from list 'Main' (depguard)
eventbusv1alpha1 "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1"
^
eventbus/jetstream/base/jetstream.go:11:2: import 'github.com/nats-io/nats.go' is not allowed from list 'Main' (depguard)
nats "github.com/nats-io/nats.go"
^
eventbus/jetstream/base/jetstream.go:12:2: import 'github.com/spf13/viper' is not allowed from list 'Main' (depguard)
"github.com/spf13/viper"
^
eventbus/jetstream/base/jetstream_conn.go:6:2: import 'github.com/nats-io/nats.go' is not allowed from list 'Main' (depguard)
nats "github.com/nats-io/nats.go"
^
eventbus/jetstream/sensor/sensor_jetstream.go:9:2: import 'github.com/argoproj/argo-events/eventbus/common' is not allowed from list 'Main' (depguard)
eventbuscommon "github.com/argoproj/argo-events/eventbus/common"
^
eventbus/jetstream/sensor/sensor_jetstream.go:10:2: import 'github.com/argoproj/argo-events/eventbus/jetstream/base' is not allowed from list 'Main' (depguard)
eventbusjetstreambase "github.com/argoproj/argo-events/eventbus/jetstream/base"
^
eventbus/jetstream/sensor/sensor_jetstream.go:11:2: import 'github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1' is not allowed from list 'Main' (depguard)
"github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1"
^
eventbus/jetstream/sensor/sensor_jetstream.go:12:2: import 'github.com/nats-io/nats.go' is not allowed from list 'Main' (depguard)
nats "github.com/nats-io/nats.go"
^
eventbus/jetstream/sensor/sensor_jetstream.go:17:2: import 'github.com/argoproj/argo-events/common' is not allowed from list 'Main' (depguard)
"github.com/argoproj/argo-events/common"
^
eventbus/jetstream/sensor/sensor_jetstream.go:18:2: import 'github.com/cloudevents/sdk-go/v2' is not allowed from list 'Main' (depguard)
cloudevents "github.com/cloudevents/sdk-go/v2"
^
eventbus/jetstream/sensor/sensor_jetstream.go:19:2: import 'github.com/mitchellh/hashstructure/v2' is not allowed from list 'Main' (depguard)
hashstructure "github.com/mitchellh/hashstructure/v2"
^
eventbus/jetstream/sensor/trigger_conn.go:12:2: import 'github.com/Knetic/govaluate' is not allowed from list 'Main' (depguard)
"github.com/Knetic/govaluate"
^
eventbus/jetstream/sensor/trigger_conn.go:13:2: import 'github.com/cloudevents/sdk-go/v2' is not allowed from list 'Main' (depguard)
cloudevents "github.com/cloudevents/sdk-go/v2"
^
eventbus/jetstream/sensor/trigger_conn.go:16:2: import 'github.com/argoproj/argo-events/eventbus/common' is not allowed from list 'Main' (depguard)
eventbuscommon "github.com/argoproj/argo-events/eventbus/common"
^
eventbus/jetstream/sensor/trigger_conn.go:17:2: import 'github.com/argoproj/argo-events/eventbus/jetstream/base' is not allowed from list 'Main' (depguard)
jetstreambase "github.com/argoproj/argo-events/eventbus/jetstream/base"
^
eventbus/kafka/eventsource/source_conn.go:6:2: import 'github.com/IBM/sarama' is not allowed from list 'Main' (depguard)
"github.com/IBM/sarama"
^
eventbus/kafka/eventsource/source_conn.go:8:2: import 'github.com/argoproj/argo-events/eventbus/kafka/base' is not allowed from list 'Main' (depguard)
"github.com/argoproj/argo-events/eventbus/kafka/base"
^
eventbus/kafka/eventsource/source_kafka.go:4:2: import 'github.com/IBM/sarama' is not allowed from list 'Main' (depguard)
"github.com/IBM/sarama"
^
eventbus/kafka/eventsource/source_kafka.go:6:2: import 'github.com/argoproj/argo-events/eventbus/kafka/base' is not allowed from list 'Main' (depguard)
"github.com/argoproj/argo-events/eventbus/kafka/base"
^
eventbus/kafka/eventsource/source_kafka.go:7:2: import 'github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1' is not allowed from list 'Main' (depguard)
eventbusv1alpha1 "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1"
^
eventbus/kafka/sensor/kafka_handler.go:9:2: import 'github.com/IBM/sarama' is not allowed from list 'Main' (depguard)
"github.com/IBM/sarama"
^
eventbus/kafka/sensor/kafka_handler.go:10:2: import 'github.com/argoproj/argo-events/eventbus/kafka/base' is not allowed from list 'Main' (depguard)
"github.com/argoproj/argo-events/eventbus/kafka/base"
^
eventbus/kafka/sensor/kafka_sensor.go:12:2: import 'github.com/Knetic/govaluate' is not allowed from list 'Main' (depguard)
"github.com/Knetic/govaluate"
^
eventbus/kafka/sensor/kafka_sensor.go:15:2: import 'github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1' is not allowed from list 'Main' (depguard)
eventbusv1alpha1 "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1"
^
eventbus/kafka/sensor/kafka_sensor.go:16:2: import 'github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1' is not allowed from list 'Main' (depguard)
sensorv1alpha1 "github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1"
^
eventbus/kafka/sensor/kafka_sensor.go:17:2: import 'github.com/cloudevents/sdk-go/v2' is not allowed from list 'Main' (depguard)
cloudevents "github.com/cloudevents/sdk-go/v2"
^
eventbus/kafka/sensor/trigger_conn.go:8:2: import 'github.com/Knetic/govaluate' is not allowed from list 'Main' (depguard)
"github.com/Knetic/govaluate"
^
eventbus/stan/base/stan.go:9:2: import 'github.com/nats-io/stan.go' is not allowed from list 'Main' (depguard)
"github.com/nats-io/stan.go"
^
eventbus/stan/base/stan_conn.go:7:2: import 'github.com/nats-io/stan.go' is not allowed from list 'Main' (depguard)
"github.com/nats-io/stan.go"
^
eventbus/stan/eventsource/source_conn.go:8:2: import 'github.com/argoproj/argo-events/eventbus/stan/base' is not allowed from list 'Main' (depguard)
stanbase "github.com/argoproj/argo-events/eventbus/stan/base"
^
eventbus/stan/eventsource/source_stan.go:5:2: import 'github.com/argoproj/argo-events/eventbus/stan/base' is not allowed from list 'Main' (depguard)
stanbase "github.com/argoproj/argo-events/eventbus/stan/base"
^
eventbus/stan/sensor/sensor_stan.go:9:2: import 'github.com/argoproj/argo-events/common' is not allowed from list 'Main' (depguard)
"github.com/argoproj/argo-events/common"
^
eventbus/stan/sensor/sensor_stan.go:11:2: import 'github.com/argoproj/argo-events/eventbus/stan/base' is not allowed from list 'Main' (depguard)
stanbase "github.com/argoproj/argo-events/eventbus/stan/base"
^
eventbus/stan/sensor/trigger_conn.go:13:2: import 'github.com/gobwas/glob' is not allowed from list 'Main' (depguard)
"github.com/gobwas/glob"
^
eventbus/stan/sensor/trigger_conn.go:14:2: import 'github.com/nats-io/stan.go' is not allowed from list 'Main' (depguard)
"github.com/nats-io/stan.go"
^
eventbus/stan/sensor/trigger_conn.go:15:2: import 'github.com/nats-io/stan.go/pb' is not allowed from list 'Main' (depguard)
"github.com/nats-io/stan.go/pb"
^
eventsources/common/common.go:3:8: import 'github.com/cloudevents/sdk-go/v2/event' is not allowed from list 'Main' (depguard)
import "github.com/cloudevents/sdk-go/v2/event"
^
pkg/apis/events/event-data.go:23:2: import 'github.com/minio/minio-go/v7/pkg/notification' is not allowed from list 'Main' (depguard)
"github.com/minio/minio-go/v7/pkg/notification"
^
pkg/apis/events/event-data.go:24:2: import 'github.com/stripe/stripe-go' is not allowed from list 'Main' (depguard)
"github.com/stripe/stripe-go"
^
pkg/apis/events/event-data.go:26:2: import 'github.com/aws/aws-sdk-go/service/sqs' is not allowed from list 'Main' (depguard)
sqslib "github.com/aws/aws-sdk-go/service/sqs"
^
eventsources/eventing.go:14:2: import 'github.com/google/uuid' is not allowed from list 'Main' (depguard)
"github.com/google/uuid"
^
eventsources/eventing.go:18:2: import 'github.com/argoproj/argo-events/common/expr' is not allowed from list 'Main' (depguard)
"github.com/argoproj/argo-events/common/expr"
^
eventsources/eventing.go:19:2: import 'github.com/argoproj/argo-events/common/leaderelection' is not allowed from list 'Main' (depguard)
"github.com/argoproj/argo-events/common/leaderelection"
^
eventsources/eventing.go:20:2: import 'github.com/argoproj/argo-events/common/logging' is not allowed from list 'Main' (depguard)
"github.com/argoproj/argo-events/common/logging"
^
eventsources/eventing.go:21:2: import 'github.com/argoproj/argo-events/eventbus' is not allowed from list 'Main' (depguard)
"github.com/argoproj/argo-events/eventbus"
^
eventsources/eventing.go:23:2: import 'github.com/argoproj/argo-events/eventsources/common' is not allowed from list 'Main' (depguard)
eventsourcecommon "github.com/argoproj/argo-events/eventsources/common"


</details>

@ryancurrah
Copy link
Contributor

I think you should remove depguard from the enabled linters. We do not seem be using it, how I can tell is there is no list of allowed linters. Then you can resolve the rest of the lints easily.

@shyukri shyukri force-pushed the chore/golang-1.21 branch 4 times, most recently from 1f405f0 to f3ec013 Compare February 7, 2024 06:59
@shyukri
Copy link
Author

shyukri commented Feb 7, 2024

@ryancurrah @whynowy can you please re-check ?

Makefile Outdated
@@ -38,6 +39,7 @@ override LDFLAGS += -X ${PACKAGE}.gitTag=${GIT_TAG}
endif

K3D ?= $(shell [ "`command -v kubectl`" != '' ] && [ "`command -v k3d`" != '' ] && [[ "`kubectl config current-context`" =~ k3d-* ]] && echo true || echo false)
K3DCLUSTER?=e2e
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires everyone to create a cluster e2e. Can we still use default K3DCLUSTER?=k3s-default?

All the reset looks good to me, thanks!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

- name: Create k3d registry and cluster
run: |
k3d registry create e2e-registry --port 5111
k3d cluster create e2e -i rancher/k3s:v1.21.7-k3s1 --registry-use k3d-e2e-registry:5111
k3d cluster create -i rancher/k3s:v1.27.10-k3s2 --registry-use k3d-e2e-registry:5111
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not need to remove e2e here for the CI.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@blkperl
Copy link
Contributor

blkperl commented Mar 29, 2024

@ryancurrah do you need any assistance? I was considering opening a separate lint fix pr

@shyukri shyukri force-pushed the chore/golang-1.21 branch 3 times, most recently from 6787d3d to 82ee2e4 Compare March 29, 2024 07:56
- name: Create k3d registry and cluster
run: |
k3d registry create e2e-registry --port 5111
k3d cluster create e2e -i rancher/k3s:v1.21.7-k3s1 --registry-use k3d-e2e-registry:5111
k3d cluster create -i rancher/k3s:v1.27.10-k3s2 --registry-use k3d-e2e-registry:5111
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
k3d cluster create -i rancher/k3s:v1.27.10-k3s2 --registry-use k3d-e2e-registry:5111
k3d cluster create e2e-i rancher/k3s:v1.27.10-k3s2 --registry-use k3d-e2e-registry:5111

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Dockerfile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@@ -1,5 +1,5 @@
# Golang binary building stage
FROM golang:1.20.2
FROM golang:1.21.6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM golang:1.21.6
FROM golang:1.21

Its hard to keep up with patch releases, I suggest we use major minor tags which will always use the latest patch release.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard to track down possible issues if the image is not static.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@shyukri shyukri force-pushed the chore/golang-1.21 branch 2 times, most recently from 9f8386f to df8e15f Compare March 31, 2024 09:29
@blkperl blkperl added dependencies Pull requests that update a dependency file go Pull requests that update Go code labels Apr 1, 2024
@shyukri shyukri requested review from ryancurrah and removed request for goat-ssh April 4, 2024 16:04
Copy link
Contributor

@ryancurrah ryancurrah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Shyukri Shyukriev <shukera@gmail.com>
Signed-off-by: Shyukri Shyukriev <shukera@gmail.com>
Signed-off-by: Shyukri Shyukriev <shukera@gmail.com>
Signed-off-by: Shyukri Shyukriev <shukera@gmail.com>
Signed-off-by: Shyukri Shyukriev <shukera@gmail.com>
Signed-off-by: Shyukri Shyukriev <shukera@gmail.com>
Signed-off-by: Shyukri Shyukriev <shukera@gmail.com>

chore: upgrade k3d to k8s 1.27, specify kubeconfig as k3d defaults to k3s-default name

Signed-off-by: Shyukri Shyukriev <shukera@gmail.com>

chore: use k3s-default as cluster and drop it from GHA

Signed-off-by: Shyukri Shyukriev <shukera@gmail.com>
Signed-off-by: Shyukri Shyukriev <shukera@gmail.com>
@yucombinator
Copy link

yucombinator commented May 4, 2024

Hello! Is there any updates on this PR? We are blocked on our end pending the resolution of a few CVEs that are present in the older Go version used in the latest release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

go 1.21 upgrade
6 participants