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

[TT-11566][TT-11953] upgraded go to 1.22 #6230

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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 .github/workflows/api-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
secrets:
ORG_GH_TOKEN: ${{ secrets.ORG_GH_TOKEN }}
with:
go-version: 1.21
go-version: 1.22
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
matrix:
redis-version: [5, 7]
python-version: ["3.11"]
go-version: [1.21.x]
go-version: [1.22.x]

steps:
- name: Checkout Tyk
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/plugin-compiler-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- 'v*'

env:
GOLANG_CROSS: 1.21-bullseye
GOLANG_CROSS: 1.22-bullseye

jobs:
docker-build:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
fail-fast: false
matrix:
golang_cross:
- 1.21-bullseye
- 1.22-bullseye
include:
- golang_cross: 1.21-bullseye
- golang_cross: 1.22-bullseye
goreleaser: 'ci/goreleaser/goreleaser.yml'
cgo: 1
rpmvers: 'el/7 el/8 el/9 amazon/2 amazon/2023'
Expand Down Expand Up @@ -113,12 +113,12 @@ jobs:
mask-aws-account-id: false
- uses: aws-actions/amazon-ecr-login@v2
id: ecr
if: ${{ matrix.golang_cross == '1.21-bullseye' }}
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
with:
mask-password: 'true'
- name: Docker metadata for CI
id: metadata
if: ${{ matrix.golang_cross == '1.21-bullseye' }}
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
uses: docker/metadata-action@v5
with:
images: ${{ steps.ecr.outputs.registry }}/tyk
Expand All @@ -131,7 +131,7 @@ jobs:
type=semver,pattern=v{{major}}.{{minor}},prefix=v
type=semver,pattern=v{{version}},prefix=v
- name: CI push
if: ${{ matrix.golang_cross == '1.21-bullseye' }}
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
shell: bash
env:
t: ${{ steps.metadata.outputs.tags }}
Expand All @@ -146,15 +146,15 @@ jobs:
docker manifest create ${tag} ${tag}-amd64 ${tag}-arm64 && docker manifest push ${tag}
done
- uses: actions/upload-artifact@v4
if: ${{ matrix.golang_cross == '1.21-bullseye' }}
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
with:
name: deb
retention-days: 1
path: |
dist/*.deb
!dist/*PAYG*.deb
- uses: actions/upload-artifact@v4
if: ${{ matrix.golang_cross == '1.21-bullseye' }}
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
with:
name: rpm
retention-days: 1
Expand Down Expand Up @@ -472,4 +472,4 @@ jobs:
secrets:
DEPDASH_URL: ${{ secrets.DEPDASH_URL }}
DEPDASH_KEY: ${{ secrets.DEPDASH_KEY }}
ORG_GH_TOKEN: ${{ secrets.ORG_GH_TOKEN }}
ORG_GH_TOKEN: ${{ secrets.ORG_GH_TOKEN }}
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21
1.22
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ run:
# Define the Go version limit.
# Mainly related to generics support since go1.18.
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.18
go: '1.21'
go: '1.22'

linters:
disable:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM debian:bookworm AS assets
# If you need to tweak the environment for testing, you can override the
# `GO_VERSION` and `PYTHON_VERSION` as docker build arguments.

ARG GO_VERSION=1.21.4
ARG GO_VERSION=1.22.3
ARG PYTHON_VERSION=3.11.6

WORKDIR /assets
Expand All @@ -16,7 +16,7 @@ RUN apt update && apt install wget -y && \

FROM debian:bookworm

ARG GO_VERSION=1.21.4
ARG GO_VERSION=1.22.3
ARG PYTHON_VERSION=3.11.6

COPY --from=assets /assets/ /tmp/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Compile from Source
git clone https://github.com/TykTechnologies/tyk
go build
```
Go version 1.21 is required to build `master`, the current development version. Tyk is officially supported on `Linux/amd64`, `Linux/i386` and `Linux/arm64`.
Go version 1.22 is required to build `master`, the current development version. Tyk is officially supported on `Linux/amd64`, `Linux/i386` and `Linux/arm64`.

To run tests locally use the following command:
```console
Expand Down
4 changes: 2 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ tasks:
test:plugin-compiler:
desc: "Plugin compiler local build/test"
cmds:
- docker build --build-arg GO_VERSION=1.21 --build-arg BASE_IMAGE=tykio/golang-cross:1.21-bookworm --build-arg GITHUB_TAG=v5.1.0-alpha18 --build-arg GITHUB_SHA=$(git rev-parse HEAD) --platform=linux/amd64 --rm -t internal/plugin-compiler -f ci/images/plugin-compiler/Dockerfile .
- docker build --build-arg GO_VERSION=1.22 --build-arg BASE_IMAGE=tykio/golang-cross:1.22-bookworm --build-arg GITHUB_TAG=v5.1.0-alpha18 --build-arg GITHUB_SHA=$(git rev-parse HEAD) --platform=linux/amd64 --rm -t internal/plugin-compiler -f ci/images/plugin-compiler/Dockerfile .
- docker run -it -e GOARCH=arm64 -e GOOS=linux --rm -v $(readlink -f .)/ci/images/plugin-compiler/data/basic-plugin:/plugin-source internal/plugin-compiler basic-plugin.so
- docker run -it --rm -v $PWD:/go/src/github.com/TykTechnologies/tyk -w /go/src/github.com/TykTechnologies/tyk tykio/golang-cross:1.21-bookworm go build -trimpath -tags=goplugin .
- docker run -it --rm -v $PWD:/go/src/github.com/TykTechnologies/tyk -w /go/src/github.com/TykTechnologies/tyk tykio/golang-cross:1.22-bookworm go build -trimpath -tags=goplugin .
- ./tyk plugin load -f ./ci/images/plugin-compiler/data/basic-plugin/basic-plugin*.so -s MyPluginPre
- docker rmi internal/plugin-compiler

Expand Down
1 change: 1 addition & 0 deletions bin/ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if [[ -z "$OPTS" ]]; then
fi

export PKG_PATH=${GOPATH}/src/github.com/TykTechnologies/tyk
export GODEBUG=tlsrsakex=1

# exit on non-zero exit from go test/vet
set -e
Expand Down
2 changes: 1 addition & 1 deletion ci/images/plugin-compiler/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE=tykio/golang-cross:1.21-bullseye
ARG BASE_IMAGE=tykio/golang-cross:1.22-bullseye
FROM ${BASE_IMAGE}

LABEL description="Image for plugin development"
Expand Down
2 changes: 1 addition & 1 deletion ci/images/plugin-compiler/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tasks:
desc: "Build plugin compiler"
dir: '{{.root}}'
cmds:
- docker build --no-cache --progress=plain --build-arg GO_VERSION=1.21 --build-arg GITHUB_TAG={{.tag}} --build-arg GITHUB_SHA={{.sha}} --platform=linux/amd64 --rm -t {{.image}} -f ci/images/plugin-compiler/Dockerfile .
- docker build --no-cache --progress=plain --build-arg GO_VERSION=1.22 --build-arg GITHUB_TAG={{.tag}} --build-arg GITHUB_SHA={{.sha}} --platform=linux/amd64 --rm -t {{.image}} -f ci/images/plugin-compiler/Dockerfile .

test:
desc: "Run test docker image"
Expand Down
2 changes: 1 addition & 1 deletion ci/smoke-tests/plugin-aliasing/foobar-plugin/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/TykTechnologies/tyk/smoke-tests/plugin-compiler/foobar-plugin

go 1.21
go 1.22

require github.com/kr/pretty v0.3.1 // indirect
2 changes: 1 addition & 1 deletion ci/smoke-tests/plugin-aliasing/helloworld-plugin/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/TykTechnologies/tyk/smoke-tests/plugin-compiler/helloworld-plugin

go 1.21
go 1.22

require github.com/kr/pretty v0.3.1 // indirect
2 changes: 1 addition & 1 deletion ci/tests/plugin-compiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The following variables are set as defaults:
| Variable name | Default value |
| ------------- | ------------------------------------ |
| tag | v0.0.0 |
| base | tykio/golang-cross:1.21-bookworm |
| base | tykio/golang-cross:1.22-bookworm |
| dockerfile | ci/images/plugin-compiler/Dockerfile |
| image | internal/plugin-compiler |
| sha | `$(git rev-parse HEAD)` |
Expand Down
2 changes: 1 addition & 1 deletion ci/tests/plugin-compiler/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3"

vars:
tag: v0.0.0
base: tykio/golang-cross:1.21-bookworm
base: tykio/golang-cross:1.22-bookworm
dockerfile: ci/images/plugin-compiler/Dockerfile
image: internal/plugin-compiler
sha:
Expand Down
2 changes: 1 addition & 1 deletion ci/tests/plugin-compiler/testdata/basic-plugin/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module example.com/basic-plugin

go 1.21
go 1.22
2 changes: 1 addition & 1 deletion ci/tests/plugin-compiler/testdata/test-plugin/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/TykTechnologies/tyk/ci/tests/plugin-compiler/testplugin

go 1.21
go 1.22

require (
github.com/Masterminds/sprig/v3 v3.2.2
Expand Down
19 changes: 19 additions & 0 deletions gateway/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,23 @@ func (gw *Gateway) getGlobalStorageHandler(keyPrefix string, hashKeys bool) stor
return &storage.RedisCluster{KeyPrefix: keyPrefix, HashKeys: hashKeys, ConnectionHandler: gw.StorageConnectionHandler}
}

func setGODEBUG() {
// With go 1.22 a few ciphers have been deprecated by the golang team due to security concerns
// To mitigate this, we need to set the GODEBUG environment variable to re-enable the deprecated ciphers
// to ensure that our clients can still upgrade to the lastest version of Tyk without any functionality breaking
// For more details see: https://github.com/golang/go/issues/63413
var goDebugVal string
if os.Getenv("GODEBUG") == "" {
goDebugVal = "tlsrsakex=1"
} else {
goDebugVal = "tlsrsakex=1," + os.Getenv("GODEBUG")
}
err := os.Setenv("GODEBUG", goDebugVal)
if err != nil {
mainLog.Warn("Could not set GODEBUG=tlsrsakex=1, some deprecated ciphers might stop working")
}
}

func Start() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand All @@ -1582,6 +1599,8 @@ func Start() {
os.Exit(0)
}

setGODEBUG()

gwConfig := config.Config{}
if err := config.Load(confPaths, &gwConfig); err != nil {
mainLog.Errorf("Error loading config, using defaults: %v", err)
Expand Down
18 changes: 18 additions & 0 deletions gateway/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gateway
import (
"context"
"errors"
"os"
"testing"
"time"

Expand Down Expand Up @@ -216,3 +217,20 @@ func TestGateway_SyncResourcesWithReload(t *testing.T) {
})

}

func TestSetGODEBUG(t *testing.T) {
// Backup the current GODEBUG environment variable and restore it after the test
originalGODEBUG := os.Getenv("GODEBUG")
defer os.Setenv("GODEBUG", originalGODEBUG)

// Test when GODEBUG is not set
os.Unsetenv("GODEBUG")
setGODEBUG()

assert.Equal(t, "tlsrsakex=1", os.Getenv("GODEBUG"))

// Test when GODEBUG is already set
os.Setenv("GODEBUG", "existing_value")
setGODEBUG()
assert.Equal(t, "tlsrsakex=1,existing_value", os.Getenv("GODEBUG"))
}
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/TykTechnologies/tyk

go 1.21.0

toolchain go1.21.4
go 1.22.3

require (
github.com/Jeffail/tunny v0.1.4
Expand Down
Loading