From 5f7a99c0b49cf9252384e7e7bd959a9fab361146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Fri, 15 Sep 2023 08:32:43 +0200 Subject: [PATCH 1/2] feat: test with Go 1.21 --- .github/workflows/ci.yml | 2 +- .gitlab-ci.yml | 2 +- .golangci.yaml | 3 +++ go.mod | 4 ++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0290b56d..4fdcf5af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: ["1.19", "1.20"] + go-version: ["1.19", "1.20", "1.21"] steps: - name: Set up Go ${{ matrix.go-version }} uses: actions/setup-go@v4 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 364bde00..afb49f13 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,7 +20,7 @@ test:golangci-lint: test:tests: stage: test - image: golang:1.20 + image: golang:1.21 script: - go test -v -race ./... except: diff --git a/.golangci.yaml b/.golangci.yaml index 6eb4c6cb..5519cc01 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -60,3 +60,6 @@ issues: linters: - gosec - errcheck + - path: hcloud/error.go + # False-positive in error codes + text: "G101: Potential hardcoded credentials" # gosec \ No newline at end of file diff --git a/go.mod b/go.mod index 6a40d466..788905e6 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,9 @@ module github.com/hetznercloud/hcloud-go/v2 +// This is being kept at a lower value on purpose as raising this would require +// all dependends to update to the new version. +// As long as we do not depend on any newer language feature this can be kept at the current value. +// It should never be higher than the lowest currently supported version of Go. go 1.19 require ( From 8f6e77ff9c437bc8336894af52c450a06c0e03a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Fri, 15 Sep 2023 08:32:43 +0200 Subject: [PATCH 2/2] chore: bump golangci-lint to v1.54.2 Added testcase verifies that the nolint directive is actually true. --- .github/workflows/golangci-lint.yml | 2 +- hcloud/schema.go | 2 +- hcloud/schema_test.go | 52 +++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 960c5304..9a6e5c9b 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -17,7 +17,7 @@ jobs: uses: golangci/golangci-lint-action@v3 with: # Required: the version of golangci-lint is required and must be specified without patch version - version: v1.53.2 + version: v1.54.2 # Optional: working directory, useful for monorepos # working-directory: somedir diff --git a/hcloud/schema.go b/hcloud/schema.go index bdd5a54e..3855c692 100644 --- a/hcloud/schema.go +++ b/hcloud/schema.go @@ -970,7 +970,7 @@ func loadBalancerCreateOptsToSchema(opts LoadBalancerCreateOpts) schema.LoadBala TLS: service.HealthCheck.HTTP.TLS, } if service.HealthCheck.HTTP.StatusCodes != nil { - schemaHealthCheckHTTP.StatusCodes = &service.HealthCheck.HTTP.StatusCodes + schemaHealthCheckHTTP.StatusCodes = &service.HealthCheck.HTTP.StatusCodes //nolint:gosec // does not result in bug } schemaHealthCheck.HTTP = schemaHealthCheckHTTP } diff --git a/hcloud/schema_test.go b/hcloud/schema_test.go index 667f72cf..070415e7 100644 --- a/hcloud/schema_test.go +++ b/hcloud/schema_test.go @@ -2403,6 +2403,32 @@ func TestLoadBalancerCreateOptsToSchema(t *testing.T) { }, }, }, + { + Protocol: LoadBalancerServiceProtocolHTTP, + DestinationPort: Ptr(443), + Proxyprotocol: Ptr(true), + HTTP: &LoadBalancerCreateOptsServiceHTTP{ + CookieName: Ptr("keks"), + CookieLifetime: Ptr(5 * time.Minute), + RedirectHTTP: Ptr(true), + StickySessions: Ptr(true), + Certificates: []*Certificate{{ID: 1}, {ID: 2}}, + }, + HealthCheck: &LoadBalancerCreateOptsServiceHealthCheck{ + Protocol: LoadBalancerServiceProtocolHTTP, + Port: Ptr(443), + Interval: Ptr(5 * time.Second), + Timeout: Ptr(1 * time.Second), + Retries: Ptr(3), + HTTP: &LoadBalancerCreateOptsServiceHealthCheckHTTP{ + Domain: Ptr("example.com"), + Path: Ptr("/health"), + Response: Ptr("ok"), + StatusCodes: []string{"4??", "5??"}, + TLS: Ptr(true), + }, + }, + }, }, Targets: []LoadBalancerCreateOptsTarget{ { @@ -2457,6 +2483,32 @@ func TestLoadBalancerCreateOptsToSchema(t *testing.T) { }, }, }, + { + Protocol: string(LoadBalancerServiceProtocolHTTP), + DestinationPort: Ptr(443), + Proxyprotocol: Ptr(true), + HTTP: &schema.LoadBalancerCreateRequestServiceHTTP{ + CookieName: Ptr("keks"), + CookieLifetime: Ptr(5 * 60), + RedirectHTTP: Ptr(true), + StickySessions: Ptr(true), + Certificates: Ptr([]int64{1, 2}), + }, + HealthCheck: &schema.LoadBalancerCreateRequestServiceHealthCheck{ + Protocol: string(LoadBalancerServiceProtocolHTTP), + Port: Ptr(443), + Interval: Ptr(5), + Timeout: Ptr(1), + Retries: Ptr(3), + HTTP: &schema.LoadBalancerCreateRequestServiceHealthCheckHTTP{ + Domain: Ptr("example.com"), + Path: Ptr("/health"), + Response: Ptr("ok"), + StatusCodes: Ptr([]string{"4??", "5??"}), + TLS: Ptr(true), + }, + }, + }, }, Targets: []schema.LoadBalancerCreateRequestTarget{ {