From 50672d66b949f037e5d4a7a1656487d0008ca4bf Mon Sep 17 00:00:00 2001 From: Michel Loiseleur Date: Thu, 22 Aug 2024 09:10:10 +0200 Subject: [PATCH 1/4] chore: upgrade ExternalDNS to go 1.23 --- .github/workflows/ci.yaml | 2 +- .github/workflows/codeql-analysis.yaml | 2 +- .github/workflows/docs.yaml | 4 ---- .github/workflows/lint.yaml | 4 ++-- .github/workflows/staging-image-tester.yaml | 2 +- Makefile | 2 +- cloudbuild.yaml | 2 +- docs/contributing/getting-started.md | 2 +- go.mod | 2 +- 9 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0645e1baf9..7e3bef4b9b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,7 +23,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v5 with: - go-version: '1.22.4' + go-version-file: go.mod id: go - name: Check out code into the Go module directory diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml index 29eceecca2..0db3d20ff7 100644 --- a/.github/workflows/codeql-analysis.yaml +++ b/.github/workflows/codeql-analysis.yaml @@ -30,7 +30,7 @@ jobs: - name: Install go version uses: actions/setup-go@v5 with: - go-version: '^1.22.4' + go-version-file: go.mod # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 967062ca03..213b82d362 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -25,10 +25,6 @@ jobs: cache: "pip" cache-dependency-path: "./docs/scripts/requirements.txt" - - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 - with: - go-version-file: 'go.mod' - - run: | pip install -r docs/scripts/requirements.txt diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 1e3cebf940..c5cfdcdb2e 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -23,7 +23,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v5 with: - go-version: '1.22.4' + go-version-file: go.mod id: go - name: Check out code into the Go module directory @@ -31,5 +31,5 @@ jobs: - name: Lint run: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.57.2 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.1 make lint diff --git a/.github/workflows/staging-image-tester.yaml b/.github/workflows/staging-image-tester.yaml index e8e6277d36..30493a803d 100644 --- a/.github/workflows/staging-image-tester.yaml +++ b/.github/workflows/staging-image-tester.yaml @@ -23,7 +23,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v5 with: - go-version: '1.22.4' + go-version-file: go.mod id: go - name: Check out code into the Go module directory diff --git a/Makefile b/Makefile index be24ff476e..5db43d8672 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ CONTROLLER_GEN=$(shell which controller-gen) endif golangci-lint: - @command -v golangci-lint > /dev/null || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.57.2 + @command -v golangci-lint > /dev/null || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.1 # Run the golangci-lint tool .PHONY: go-lint diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 63f96d0768..5f5ecb08d6 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -4,7 +4,7 @@ options: substitution_option: ALLOW_LOOSE machineType: 'N1_HIGHCPU_8' steps: - - name: 'docker.io/library/golang:1.22.4-bookworm' + - name: 'docker.io/library/golang:1.23-bookworm' entrypoint: make env: - VERSION=$_GIT_TAG diff --git a/docs/contributing/getting-started.md b/docs/contributing/getting-started.md index 3f09c927f3..d656d65169 100644 --- a/docs/contributing/getting-started.md +++ b/docs/contributing/getting-started.md @@ -1,7 +1,7 @@ # Quick Start - [Git](https://git-scm.com/downloads) -- [Go 1.22+](https://golang.org/dl/) +- [Go 1.23+](https://golang.org/dl/) - [Go modules](https://github.com/golang/go/wiki/Modules) - [golangci-lint](https://github.com/golangci/golangci-lint) - [ko](https://ko.build/) diff --git a/go.mod b/go.mod index e4fe1a4c3d..c75b7d536e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module sigs.k8s.io/external-dns -go 1.22.4 +go 1.23 require ( cloud.google.com/go/compute/metadata v0.5.0 From 4a48a0a3556a0a4f335c49e30caabb50f6d60d4e Mon Sep 17 00:00:00 2001 From: Michel Loiseleur Date: Thu, 22 Aug 2024 15:23:01 +0200 Subject: [PATCH 2/4] fix linter --- provider/tencentcloud/cloudapi/mockapi.go | 2 +- provider/tencentcloud/cloudapi/tencentapi.go | 6 +++--- provider/tencentcloud/dnspod.go | 4 ++-- provider/tencentcloud/privatedns.go | 4 ++-- provider/vinyldns/vinyldns.go | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/provider/tencentcloud/cloudapi/mockapi.go b/provider/tencentcloud/cloudapi/mockapi.go index 3484ddc120..df5e64b469 100644 --- a/provider/tencentcloud/cloudapi/mockapi.go +++ b/provider/tencentcloud/cloudapi/mockapi.go @@ -71,7 +71,7 @@ func (api *mockAPIService) DeletePrivateZoneRecord(request *privatedns.DeletePri } for _, privateZoneRecord := range api.privateZoneRecords[*request.ZoneId] { deleteflag := false - if request.RecordIdSet != nil && len(request.RecordIdSet) != 0 { + if len(request.RecordIdSet) != 0 { for _, recordId := range request.RecordIdSet { if *privateZoneRecord.RecordId == *recordId { deleteflag = true diff --git a/provider/tencentcloud/cloudapi/tencentapi.go b/provider/tencentcloud/cloudapi/tencentapi.go index 5997cb67f6..1c8338e07c 100644 --- a/provider/tencentcloud/cloudapi/tencentapi.go +++ b/provider/tencentcloud/cloudapi/tencentapi.go @@ -258,16 +258,16 @@ func dealWithError(action Action, request string, err error) bool { } func APIErrorRecord(apiAction Action, request string, response string, err error) { - log.Infof(fmt.Sprintf("APIError API: %s/%s Request: %s, Response: %s, Error: %s", apiAction.Service, apiAction.Name, request, response, err.Error())) + log.Infof("APIError API: %s/%s Request: %s, Response: %s, Error: %s", apiAction.Service, apiAction.Name, request, response, err.Error()) } func APIRecord(apiAction Action, request string, response string) { message := fmt.Sprintf("APIRecord API: %s/%s Request: %s, Response: %s", apiAction.Service, apiAction.Name, request, response) if apiAction.ReadOnly { - // log.Infof(message) + // log.Info(message) } else { - log.Infof(message) + log.Info(message) } } diff --git a/provider/tencentcloud/dnspod.go b/provider/tencentcloud/dnspod.go index f2e714cf89..30fb81ac0a 100644 --- a/provider/tencentcloud/dnspod.go +++ b/provider/tencentcloud/dnspod.go @@ -89,7 +89,7 @@ func (p *TencentCloudProvider) getDomainList() ([]*dnspod.DomainListItem, error) if err != nil { return nil, err } - if response.Response.DomainList != nil && len(response.Response.DomainList) > 0 { + if len(response.Response.DomainList) > 0 { if !p.domainFilter.IsConfigured() { domainList = append(domainList, response.Response.DomainList...) } else { @@ -119,7 +119,7 @@ func (p *TencentCloudProvider) getDomainRecordList(domain string) ([]*dnspod.Rec if err != nil { return nil, err } - if response.Response.RecordList != nil && len(response.Response.RecordList) > 0 { + if len(response.Response.RecordList) > 0 { for _, record := range response.Response.RecordList { if *record.Name == "@" && *record.Type == "NS" { // Special Record, Skip it. continue diff --git a/provider/tencentcloud/privatedns.go b/provider/tencentcloud/privatedns.go index 7bfc9d326f..e209f535fc 100644 --- a/provider/tencentcloud/privatedns.go +++ b/provider/tencentcloud/privatedns.go @@ -110,7 +110,7 @@ func (p *TencentCloudProvider) getPrivateZones() ([]*privatedns.PrivateZone, err if err != nil { return nil, err } - if response.Response.PrivateZoneSet != nil && len(response.Response.PrivateZoneSet) > 0 { + if len(response.Response.PrivateZoneSet) > 0 { privateZones = append(privateZones, response.Response.PrivateZoneSet...) } totalCount = *response.Response.TotalCount @@ -140,7 +140,7 @@ func (p *TencentCloudProvider) getPrivateZoneRecords(zoneId string) ([]*privated if err != nil { return nil, err } - if response.Response.RecordSet != nil && len(response.Response.RecordSet) > 0 { + if len(response.Response.RecordSet) > 0 { privateZoneRecords = append(privateZoneRecords, response.Response.RecordSet...) } totalCount = *response.Response.TotalCount diff --git a/provider/vinyldns/vinyldns.go b/provider/vinyldns/vinyldns.go index 7dc98c2d73..fefc56e6ed 100644 --- a/provider/vinyldns/vinyldns.go +++ b/provider/vinyldns/vinyldns.go @@ -92,7 +92,7 @@ func (p *vinyldnsProvider) Records(ctx context.Context) (endpoints []*endpoint.E continue } - log.Infof(fmt.Sprintf("Zone: [%s:%s]", zone.ID, zone.Name)) + log.Infof("Zone: [%s:%s]", zone.ID, zone.Name) records, err := p.client.RecordSets(zone.ID) if err != nil { return nil, err @@ -101,7 +101,7 @@ func (p *vinyldnsProvider) Records(ctx context.Context) (endpoints []*endpoint.E for _, r := range records { if provider.SupportedRecordType(r.Type) { recordsCount := len(r.Records) - log.Debugf(fmt.Sprintf("%s.%s.%d.%s", r.Name, r.Type, recordsCount, zone.Name)) + log.Debugf("%s.%s.%d.%s", r.Name, r.Type, recordsCount, zone.Name) // TODO: AAAA Records if len(r.Records) > 0 { From 35cb2494d5947a18f04d09f6538a3c2fb2c8dced Mon Sep 17 00:00:00 2001 From: Michel Loiseleur Date: Fri, 23 Aug 2024 09:11:03 +0200 Subject: [PATCH 3/4] fix ordering --- .github/workflows/ci.yaml | 6 +++--- .github/workflows/lint.yaml | 13 +++++++------ .github/workflows/staging-image-tester.yaml | 6 +++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7e3bef4b9b..48fc93b063 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,15 +20,15 @@ jobs: runs-on: ubuntu-latest steps: + - name: Check out code into the Go module directory + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: Set up Go 1.x uses: actions/setup-go@v5 with: go-version-file: go.mod id: go - - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - name: Install CI run: | go get -v -t -d ./... diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index c5cfdcdb2e..72aa83d636 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -8,6 +8,7 @@ on: permissions: contents: read # to fetch code (actions/checkout) + checks: write jobs: @@ -20,16 +21,16 @@ jobs: runs-on: ubuntu-latest steps: + - name: Check out code into the Go module directory + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: Set up Go 1.x uses: actions/setup-go@v5 with: go-version-file: go.mod id: go - - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - name: Lint - run: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.1 - make lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.60 diff --git a/.github/workflows/staging-image-tester.yaml b/.github/workflows/staging-image-tester.yaml index 30493a803d..dd3d5e450d 100644 --- a/.github/workflows/staging-image-tester.yaml +++ b/.github/workflows/staging-image-tester.yaml @@ -20,15 +20,15 @@ jobs: runs-on: ubuntu-latest steps: + - name: Check out code into the Go module directory + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: Set up Go 1.x uses: actions/setup-go@v5 with: go-version-file: go.mod id: go - - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - name: Install CI run: | go get -v -t -d ./... From 0ec66ee66922715e094c5de114b22388d4cbd3e8 Mon Sep 17 00:00:00 2001 From: Michel Loiseleur Date: Fri, 23 Aug 2024 09:24:28 +0200 Subject: [PATCH 4/4] fix linter --- .github/workflows/lint.yaml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 72aa83d636..b547756b28 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -28,9 +28,9 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: go.mod - id: go - name: Lint uses: golangci/golangci-lint-action@v6 with: + args: --timeout=30m version: v1.60 diff --git a/Makefile b/Makefile index 5db43d8672..5ffdfd0fc5 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ CONTROLLER_GEN=$(shell which controller-gen) endif golangci-lint: - @command -v golangci-lint > /dev/null || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.1 + @command -v golangci-lint > /dev/null || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.3 # Run the golangci-lint tool .PHONY: go-lint