From c922517b10d2e1452a83ab0e7d155646c2ec1d20 Mon Sep 17 00:00:00 2001 From: Michal Fiedorowicz Date: Thu, 8 Aug 2024 23:12:59 +0200 Subject: [PATCH 1/2] chore: upgrade to go 1.22 Signed-off-by: Michal Fiedorowicz --- .github/actions/go-lint/Dockerfile | 2 +- .github/actions/go-report/Dockerfile | 2 +- .github/workflows/agent.yml | 2 +- .github/workflows/go-develop.yml | 12 ++++++------ .github/workflows/go-main.yml | 12 ++++++------ .github/workflows/go-production.yml | 12 ++++++------ agent/docker/Dockerfile | 2 +- docker/Dockerfile | 2 +- docker/Dockerfile.debug | 2 +- go.mod | 2 +- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/actions/go-lint/Dockerfile b/.github/actions/go-lint/Dockerfile index aed96deaf..dfcb253ea 100644 --- a/.github/actions/go-lint/Dockerfile +++ b/.github/actions/go-lint/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21-buster +FROM golang:1.22-alpine LABEL author="Everton Haise Taques" LABEL maintainer="netboxlabs" diff --git a/.github/actions/go-report/Dockerfile b/.github/actions/go-report/Dockerfile index 40e0b4657..c8c970a4c 100644 --- a/.github/actions/go-report/Dockerfile +++ b/.github/actions/go-report/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine +FROM golang:1.22-alpine LABEL author="Everton Haise Taques" LABEL maintainer="netboxlabs" diff --git a/.github/workflows/agent.yml b/.github/workflows/agent.yml index 4ff3756c9..5c7ac4908 100644 --- a/.github/workflows/agent.yml +++ b/.github/workflows/agent.yml @@ -26,7 +26,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Get branch name shell: bash diff --git a/.github/workflows/go-develop.yml b/.github/workflows/go-develop.yml index 71263b7d9..8d3879581 100644 --- a/.github/workflows/go-develop.yml +++ b/.github/workflows/go-develop.yml @@ -116,7 +116,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.agent == 'true' || github.event_name != 'pull_request' }} @@ -155,7 +155,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.orb == 'true' || github.event_name != 'pull_request' }} @@ -194,7 +194,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.orb == 'true' || github.event_name != 'pull_request' }} @@ -233,7 +233,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.orb == 'true' || github.event_name != 'pull_request' }} @@ -272,7 +272,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.orb == 'true' || github.event_name != 'pull_request' }} @@ -311,7 +311,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.orb == 'true' || github.event_name != 'pull_request' }} diff --git a/.github/workflows/go-main.yml b/.github/workflows/go-main.yml index 2fc3fefde..374a3eaff 100644 --- a/.github/workflows/go-main.yml +++ b/.github/workflows/go-main.yml @@ -70,7 +70,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests run: SERVICE=agent make test_service @@ -83,7 +83,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.orb == 'true' }} @@ -97,7 +97,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.orb == 'true' }} @@ -111,7 +111,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.orb == 'true' }} @@ -125,7 +125,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.orb == 'true' }} @@ -139,7 +139,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.orb == 'true' }} diff --git a/.github/workflows/go-production.yml b/.github/workflows/go-production.yml index 13b32975f..f940d3e7c 100644 --- a/.github/workflows/go-production.yml +++ b/.github/workflows/go-production.yml @@ -70,7 +70,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.agent == 'true' }} @@ -84,7 +84,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests run: | @@ -100,7 +100,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.orb == 'true' }} @@ -114,7 +114,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.orb == 'true' }} @@ -128,7 +128,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests if: ${{ needs.prebuild.outputs.orb == 'true' }} @@ -142,7 +142,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: '1.22' - name: Go unit tests run: | diff --git a/agent/docker/Dockerfile b/agent/docker/Dockerfile index 6ce10d025..c445b9c42 100644 --- a/agent/docker/Dockerfile +++ b/agent/docker/Dockerfile @@ -1,5 +1,5 @@ ARG PKTVISOR_TAG=latest-develop -FROM golang:1.21-alpine AS builder +FROM golang:1.22-alpine AS builder WORKDIR /go/src/github.com/orbcommunity/orb COPY go.mod . diff --git a/docker/Dockerfile b/docker/Dockerfile index 2a59fa816..905d9f6bc 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine AS builder +FROM golang:1.22-alpine AS builder ARG SVC ARG GOARCH ARG GOARM diff --git a/docker/Dockerfile.debug b/docker/Dockerfile.debug index 04a498ac0..29b2a68a7 100644 --- a/docker/Dockerfile.debug +++ b/docker/Dockerfile.debug @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine AS builder +FROM golang:1.22-alpine AS builder ARG SVC ARG GOARCH ARG GOARM diff --git a/go.mod b/go.mod index 59267a809..12cf8d250 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/orb-community/orb -go 1.21 +go 1.22 require ( github.com/andybalholm/brotli v1.0.6 From 388e177bf814dd19e78b1a4f27332121abece978 Mon Sep 17 00:00:00 2001 From: Michal Fiedorowicz Date: Thu, 8 Aug 2024 23:19:36 +0200 Subject: [PATCH 2/2] chore: gofmt Signed-off-by: Michal Fiedorowicz --- fleet/api/http/transport.go | 1 - maestro/kubecontrol/kubecontrol.go | 2 +- maestro/postgres/init.go | 2 +- maestro/redis/consumer/sinker.go | 2 +- pkg/errors/types.go | 2 +- sinker/redis/consumer/sink_key_expire.go | 4 ++-- sinks/api/http/requests.go | 2 +- sinks/api/http/transport.go | 5 ++--- sinks/authentication_type/basicauth/authentication.go | 6 +++--- 9 files changed, 12 insertions(+), 14 deletions(-) diff --git a/fleet/api/http/transport.go b/fleet/api/http/transport.go index 265f680bb..f71f7244a 100644 --- a/fleet/api/http/transport.go +++ b/fleet/api/http/transport.go @@ -283,7 +283,6 @@ func encodeError(_ context.Context, err error, w http.ResponseWriter) { case errors.Contains(errorVal, errors.ErrUnsupportedContentType): w.WriteHeader(http.StatusUnsupportedMediaType) - case errors.Contains(errorVal, errors.ErrMalformedEntity): w.WriteHeader(http.StatusBadRequest) case errors.Contains(errorVal, errors.ErrNotFound): diff --git a/maestro/kubecontrol/kubecontrol.go b/maestro/kubecontrol/kubecontrol.go index 0aa7004ad..3db5751c9 100644 --- a/maestro/kubecontrol/kubecontrol.go +++ b/maestro/kubecontrol/kubecontrol.go @@ -96,7 +96,7 @@ func (svc *deployService) collectorDeploy(ctx context.Context, operation, ownerI } // delete temporary file - os.Remove("/tmp/otel-collector-"+sinkId+".json") + os.Remove("/tmp/otel-collector-" + sinkId + ".json") // TODO this will be retrieved once we move to K8s SDK collectorName := fmt.Sprintf("otel-%s", sinkId) diff --git a/maestro/postgres/init.go b/maestro/postgres/init.go index 83077a742..527d1acf0 100644 --- a/maestro/postgres/init.go +++ b/maestro/postgres/init.go @@ -32,7 +32,7 @@ func migrateDB(db *sqlx.DB) error { Migrations: []*migrate.Migration{ { Id: "1", - Up: []string{ + Up: []string{ `CREATE TABLE IF NOT EXISTS deployments ( id UUID NOT NULL DEFAULT gen_random_uuid(), owner_id VARCHAR(255) NOT NULL, diff --git a/maestro/redis/consumer/sinker.go b/maestro/redis/consumer/sinker.go index de431d1d0..d4533d8e2 100644 --- a/maestro/redis/consumer/sinker.go +++ b/maestro/redis/consumer/sinker.go @@ -24,7 +24,7 @@ type sinkerActivityListenerService struct { } const ( - idleStream = "orb.sink_idle" + idleStream = "orb.sink_idle" activityStream = "orb.sink_activity" ) diff --git a/pkg/errors/types.go b/pkg/errors/types.go index f09a283c4..744570246 100644 --- a/pkg/errors/types.go +++ b/pkg/errors/types.go @@ -41,7 +41,7 @@ var ( // ErrAuthTypeNotFound indicates that authentication type field was not found on the authentication field ErrAuthTypeNotFound = New("malformed entity specification: authentication type field is expected on configuration field") - + // ErrInvalidAuthType indicates invalid authentication type ErrInvalidAuthType = New("malformed entity specification. type key on authentication field is invalid") diff --git a/sinker/redis/consumer/sink_key_expire.go b/sinker/redis/consumer/sink_key_expire.go index 8e2318c27..1f3a6785e 100644 --- a/sinker/redis/consumer/sink_key_expire.go +++ b/sinker/redis/consumer/sink_key_expire.go @@ -34,7 +34,7 @@ func (s *sinkerKeyExpirationListener) SubscribeToKeyExpiration(ctx context.Conte pubsub := s.cacheRedisClient.PSubscribe(ctx, "__keyevent@"+redisDB+"__:expired") defer func(pubsub *redis.PubSub) { _ = pubsub.Close() - }(pubsub) + }(pubsub) for { select { case <-ctx.Done(): @@ -57,7 +57,7 @@ func (s *sinkerKeyExpirationListener) SubscribeToKeyExpiration(ctx context.Conte // ReceiveMessage to be used to receive the message from the sinker key expiration func (s *sinkerKeyExpirationListener) ReceiveMessage(ctx context.Context, message string) error { // goroutine - go func(msg string) { + go func(msg string) { ownerID := message[15:51] sinkID := message[52:] event := producer.SinkIdleEvent{ diff --git a/sinks/api/http/requests.go b/sinks/api/http/requests.go index df5f336a0..9d7922d5e 100644 --- a/sinks/api/http/requests.go +++ b/sinks/api/http/requests.go @@ -85,7 +85,7 @@ func GetConfigurationAndMetadataFromMeta(backendName string, config types.Metada } func GetConfigurationAndMetadataFromYaml(backendName string, config string) (configSvc *sinks.Configuration, exporter types.Metadata, authentication types.Metadata, err error) { - + if !backend.HaveBackend(backendName) { return nil, nil, nil, errors.Wrap(errors.ErrInvalidBackend, errors.New("invalid backend")) } diff --git a/sinks/api/http/transport.go b/sinks/api/http/transport.go index 8f0277f76..c919c0980 100644 --- a/sinks/api/http/transport.go +++ b/sinks/api/http/transport.go @@ -236,7 +236,6 @@ func encodeError(_ context.Context, err error, w http.ResponseWriter) { case errors.Contains(errorVal, errors.ErrUnsupportedContentType): w.WriteHeader(http.StatusUnsupportedMediaType) - case errors.Contains(errorVal, errors.ErrInvalidEndpoint): w.WriteHeader(http.StatusBadRequest) case errors.Contains(errorVal, errors.ErrEndpointNotFound): @@ -252,7 +251,7 @@ func encodeError(_ context.Context, err error, w http.ResponseWriter) { case errors.Contains(errorVal, errors.ErrInvalidPasswordType): w.WriteHeader(http.StatusBadRequest) case errors.Contains(errorVal, errors.ErrInvalidAuthType): - w.WriteHeader(http.StatusBadRequest) + w.WriteHeader(http.StatusBadRequest) case errors.Contains(errorVal, errors.ErrRemoteHostNotFound): w.WriteHeader(http.StatusBadRequest) case errors.Contains(errorVal, errors.ErrAuthFieldNotFound): @@ -262,7 +261,7 @@ func encodeError(_ context.Context, err error, w http.ResponseWriter) { case errors.Contains(errorVal, errors.ErrExporterFieldNotFound): w.WriteHeader(http.StatusBadRequest) case errors.Contains(errorVal, errors.ErrInvalidBackend): - w.WriteHeader(http.StatusBadRequest) + w.WriteHeader(http.StatusBadRequest) case errors.Contains(errorVal, errors.ErrEntityNameNotFound): w.WriteHeader(http.StatusBadRequest) case errors.Contains(errorVal, errors.ErrMalformedEntity): diff --git a/sinks/authentication_type/basicauth/authentication.go b/sinks/authentication_type/basicauth/authentication.go index 71de2fa66..ba25beabf 100644 --- a/sinks/authentication_type/basicauth/authentication.go +++ b/sinks/authentication_type/basicauth/authentication.go @@ -59,13 +59,13 @@ func (a *AuthConfig) ValidateConfiguration(inputFormat string, input interface{} for key, value := range input.(types.Metadata) { if _, ok := value.(string); !ok { if key == "password" { - return errors.Wrap(errors.ErrInvalidPasswordType, errors.New("invalid auth type for field: " + key)) + return errors.Wrap(errors.ErrInvalidPasswordType, errors.New("invalid auth type for field: "+key)) } if key == "type" { - return errors.Wrap(errors.ErrInvalidAuthType, errors.New("invalid auth type for field: " + key)) + return errors.Wrap(errors.ErrInvalidAuthType, errors.New("invalid auth type for field: "+key)) } if key == "username" { - return errors.Wrap(errors.ErrInvalidUsernameType, errors.New("invalid auth type for field: " + key)) + return errors.Wrap(errors.ErrInvalidUsernameType, errors.New("invalid auth type for field: "+key)) } } vs := value.(string)