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

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 6 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Golang
uses: actions/setup-go@v5
uses: actions/setup-go@v5.0.0
with:
go-version: "1.21"
- name: Restore go build cache
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Golang
uses: actions/setup-go@v5
uses: actions/setup-go@v5.0.0
with:
go-version: "1.21"
- name: Restore go build cache
Expand All @@ -95,7 +95,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Golang
uses: actions/setup-go@v5
uses: actions/setup-go@v5.0.0
with:
go-version: "1.21"
- name: Restore go build cache
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Golang
uses: actions/setup-go@v5
uses: actions/setup-go@v5.0.0
with:
go-version: "1.21"
- name: Restore go build cache
Expand All @@ -141,11 +141,11 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Install k3d
run: curl -sfL https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash &
run: curl -sfL https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash &
- 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

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

echo '127.0.0.1 k3d-e2e-registry' | sudo tee -a /etc/hosts
- name: Run tests
run: |
Expand Down
4 changes: 0 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ run:
- ".*generated.*"
linters:
enable:
- deadcode
# - depguard
- dogsled
- goconst
- gocritic
Expand All @@ -23,9 +21,7 @@ linters:
- nakedret
- rowserrcheck
- staticcheck
# - structcheck
- typecheck
- unconvert
- unused
- varcheck
- whitespace
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ ARG ARCH=$TARGETARCH
####################################################################################################
# base
####################################################################################################
FROM alpine:3.16.2 as base
FROM alpine:3.19.1 as base
ARG ARCH
RUN apk update && apk upgrade && \
apk add ca-certificates && \
apk --no-cache add tzdata

ENV ARGO_VERSION=v3.4.8
ENV ARGO_VERSION=v3.5.5

RUN wget -q https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-${ARCH}.gz
RUN gunzip -f argo-linux-${ARCH}.gz
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PACKAGE=github.com/argoproj/argo-events
SHELL := /usr/bin/env bash # Make will use bash instead of sh
CURRENT_DIR=$(shell pwd)
DIST_DIR=${CURRENT_DIR}/dist

Expand Down Expand Up @@ -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?=k3s-default

# Check that the needed executables are available, else exit before the build
K := $(foreach exec,$(EXECUTABLES), $(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
Expand Down Expand Up @@ -73,7 +75,7 @@ image: clean $(BUILD_DIST)
DOCKER_BUILDKIT=1 docker build -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) --target $(BINARY_NAME) -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ]; then docker push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION); fi
ifeq ($(K3D),true)
k3d image import $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)
k3d image import $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) --cluster $(K3DCLUSTER)
endif

image-linux-%: dist/$(BINARY_NAME)-linux-%
Expand Down Expand Up @@ -155,7 +157,7 @@ start: image
kubectl -n argo-events wait --for=condition=Ready --timeout 60s pod --all

$(GOPATH)/bin/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b `go env GOPATH`/bin v1.54.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b `go env GOPATH`/bin v1.57.2

.PHONY: lint
lint: $(GOPATH)/bin/golangci-lint
Expand Down
16 changes: 10 additions & 6 deletions controllers/eventbus/installer/jetstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

// Workarounds for golangci-lint errors:
// string `STRING` has N occurrences, make it a constant (goconst)
const eventBusPrefix = "eventbus-"

var (
testJetStreamEventBus = &v1alpha1.EventBus{
TypeMeta: metav1.TypeMeta{
Expand Down Expand Up @@ -71,17 +75,17 @@ func TestJetStreamBadInstallation(t *testing.T) {

func TestJetStreamGenerateNames(t *testing.T) {
n := generateJetStreamStatefulSetName(testJetStreamEventBus)
assert.Equal(t, "eventbus-"+testJetStreamEventBus.Name+"-js", n)
assert.Equal(t, eventBusPrefix+testJetStreamEventBus.Name+"-js", n)
n = generateJetStreamServerSecretName(testJetStreamEventBus)
assert.Equal(t, "eventbus-"+testJetStreamEventBus.Name+"-js-server", n)
assert.Equal(t, eventBusPrefix+testJetStreamEventBus.Name+"-js-server", n)
n = generateJetStreamClientAuthSecretName(testJetStreamEventBus)
assert.Equal(t, "eventbus-"+testJetStreamEventBus.Name+"-js-client-auth", n)
assert.Equal(t, eventBusPrefix+testJetStreamEventBus.Name+"-js-client-auth", n)
n = generateJetStreamConfigMapName(testJetStreamEventBus)
assert.Equal(t, "eventbus-"+testJetStreamEventBus.Name+"-js-config", n)
assert.Equal(t, eventBusPrefix+testJetStreamEventBus.Name+"-js-config", n)
n = generateJetStreamPVCName(testJetStreamEventBus)
assert.Equal(t, "eventbus-"+testJetStreamEventBus.Name+"-js-vol", n)
assert.Equal(t, eventBusPrefix+testJetStreamEventBus.Name+"-js-vol", n)
n = generateJetStreamServiceName(testJetStreamEventBus)
assert.Equal(t, "eventbus-"+testJetStreamEventBus.Name+"-js-svc", n)
assert.Equal(t, eventBusPrefix+testJetStreamEventBus.Name+"-js-svc", n)
}

func TestJetStreamCreateObjects(t *testing.T) {
Expand Down
10 changes: 7 additions & 3 deletions test/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ import (
sensorpkg "github.com/argoproj/argo-events/pkg/client/sensor/clientset/versioned/typed/sensor/v1alpha1"
)

// Workarounds for golangci-lint errors:
// string `STRING` has N occurrences, make it a constant (goconst)
const fieldSelectorMetadataName = "metadata.name="

func WaitForEventBusReady(ctx context.Context, eventBusClient eventbuspkg.EventBusInterface, eventBusName string, timeout time.Duration) error {
fieldSelector := "metadata.name=" + eventBusName
fieldSelector := fieldSelectorMetadataName + eventBusName
opts := metav1.ListOptions{FieldSelector: fieldSelector}
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
Expand Down Expand Up @@ -62,7 +66,7 @@ func WaitForEventBusStatefulSetReady(ctx context.Context, kubeClient kubernetes.
}

func WaitForEventSourceReady(ctx context.Context, eventSourceClient eventsourcepkg.EventSourceInterface, eventSourceName string, timeout time.Duration) error {
fieldSelector := "metadata.name=" + eventSourceName
fieldSelector := fieldSelectorMetadataName + eventSourceName
opts := metav1.ListOptions{FieldSelector: fieldSelector}
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
Expand All @@ -89,7 +93,7 @@ func WaitForEventSourceDeploymentReady(ctx context.Context, kubeClient kubernete
}

func WaitForSensorReady(ctx context.Context, sensorClient sensorpkg.SensorInterface, sensorName string, timeout time.Duration) error {
fieldSelector := "metadata.name=" + sensorName
fieldSelector := fieldSelectorMetadataName + sensorName
opts := metav1.ListOptions{FieldSelector: fieldSelector}
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Golang binary building stage
FROM golang:1.20.2
FROM golang:1.21
WORKDIR $GOPATH/src/github.com/nats-io/prometheus-nats-exporter
RUN git clone --branch v0.10.1 https://github.com/nats-io/prometheus-nats-exporter.git .
RUN git clone --branch v0.14.0 https://github.com/nats-io/prometheus-nats-exporter.git .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -a -tags netgo -installsuffix netgo -ldflags "-s -w"

# Final docker image building stage
Expand Down
Loading