Skip to content

Commit

Permalink
Update Go to v1.19
Browse files Browse the repository at this point in the history
Most notables changes:
* we remove all uses of the io/ioutil package, which has been deprecated
* gofmt now reformats doc comments (e.g., lists inside comment blocks),
  which is why some comments have been reformatted automatically
* the codegen image has been updated to kubernetes-1.24.0-build.1 to
  include the updated version of Go. "go get: no longer builds or
  installs packages in module-aware mode, so "go get" has been replaced
  with "go install" in the Dockerfile.
* we now use the version of Go from the root go.mod file when setting up
  Go in Github workflows. This will reduce the number of changes we have
  to do in the future when updating Go.
* running "go mod tidy" with the updated Go version seems to have
  removed some stale entries from go.sum files.

Signed-off-by: Antonin Bas <[email protected]>
  • Loading branch information
antoninbas committed Aug 11, 2022
1 parent 173ef52 commit 856679b
Show file tree
Hide file tree
Showing 93 changed files with 394 additions and 694 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
name: GoBenchmark
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'

- name: Check out code into the Go module directory
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clair.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Scan Antrea Docker image for vulnerabilities
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_SES }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
if: ${{ github.actor == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'dependencies') && contains(github.event.pull_request.labels.*.name, 'go') }}
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- uses: actions/checkout@v3
with:
# Check out the pull request HEAD
Expand Down
40 changes: 20 additions & 20 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ jobs:
name: Unit test (ubuntu-latest)
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Check-out code
uses: actions/checkout@v3
- uses: actions/cache@v3
Expand Down Expand Up @@ -74,10 +74,10 @@ jobs:
name: Unit test (windows-2019)
runs-on: [windows-2019]
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Check-out code
uses: actions/checkout@v3
- uses: actions/cache@v3
Expand Down Expand Up @@ -110,10 +110,10 @@ jobs:
name: Integration test
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Check-out code
uses: actions/checkout@v3
- uses: actions/cache@v3
Expand Down Expand Up @@ -155,10 +155,10 @@ jobs:
name: Golangci-lint (ubuntu-latest)
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Check-out code
uses: actions/checkout@v3
- uses: actions/cache@v3
Expand Down Expand Up @@ -187,10 +187,10 @@ jobs:
name: Golangci-lint (macos-latest)
runs-on: [macos-latest]
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Check-out code
uses: actions/checkout@v3
- uses: actions/cache@v3
Expand Down Expand Up @@ -219,10 +219,10 @@ jobs:
name: Build Antrea and antctl binaries
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Check-out code
uses: actions/checkout@v3
- uses: actions/cache@v3
Expand Down Expand Up @@ -258,10 +258,10 @@ jobs:
name: Build Antrea Windows binaries
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Check-out code
uses: actions/checkout@v3
- uses: actions/cache@v3
Expand All @@ -287,10 +287,10 @@ jobs:
name: Check tidy, code generation and manifest
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Check-out code
uses: actions/checkout@v3
# tidy check need to be run before code generation which will regenerate codes.
Expand All @@ -307,10 +307,10 @@ jobs:
name: Verify docs and spelling
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Check-out code
uses: actions/checkout@v3
- name: Run verify scripts
Expand Down Expand Up @@ -343,10 +343,10 @@ jobs:
name: Go benchmark test
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Check-out code
uses: actions/checkout@v3
- name: Run Go benchmark test
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golicense.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
if: ${{ needs.check-changes.outputs.has_changes == 'yes' || github.event_name != 'pull_request' }}
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- uses: actions/checkout@v3
- name: Cache licensing information for dependencies
uses: actions/cache@v3
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Download Antrea image from previous job
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Download Antrea image from previous job
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -194,7 +194,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Download Antrea image from previous job
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -253,7 +253,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Download Antrea image from previous job
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -311,7 +311,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Download Antrea image from previous job
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -369,7 +369,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Download Antrea image from previous job
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -434,7 +434,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Download Antrea image from previous job
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -477,7 +477,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Download Antrea image from previous job
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -520,7 +520,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Download Antrea image from previous job
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -563,7 +563,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Download Antrea image from previous job
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -606,7 +606,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Download Antrea image from previous job
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -641,7 +641,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Download Antrea image from previous job
uses: actions/download-artifact@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/process_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
upload-release-assets:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- uses: actions/checkout@v3
- name: Build assets
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/verify_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
name: Verify docs and spelling
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.17
- name: Set up Go using version from go.mod
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: 'go.mod'
- name: Check-out code
uses: actions/checkout@v3
- name: Run verify scripts
Expand Down
5 changes: 3 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ linters-settings:
ignore-generated-header: false
severity: warning
confidence: 0.8
# errorf, var-declaration temporarily disabled because of https://github.com/golangci/golangci-lint/issues/2997
rules:
- name: unreachable-code
- name: errorf
# - name: errorf
- name: range
- name: superfluous-else
- name: var-declaration
# - name: var-declaration

linters:
disable-all: true
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ the `$GOPATH`.

To develop locally, you can follow these steps:

1. [Install Go 1.17](https://golang.org/doc/install)
1. [Install Go 1.19](https://golang.org/doc/install)
2. Checkout your feature branch and `cd` into it.
3. To build all Go files and install them under `bin`, run `make bin`
4. To run all Go unit tests, run `make test-unit`
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ DOCKER_ENV := \
-v $(DOCKER_CACHE)/gopath:/tmp/gopath \
-v $(DOCKER_CACHE)/gocache:/tmp/gocache \
-v $(CURDIR):/usr/src/antrea.io/antrea \
golang:1.17
golang:$(GO_VERSION)

.PHONY: docker-bin
docker-bin: $(DOCKER_CACHE)
Expand Down Expand Up @@ -258,7 +258,7 @@ fmt:

.golangci-bin:
@echo "===> Installing Golangci-lint <==="
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $@ v1.41.1
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $@ v1.48.0

.PHONY: golangci
golangci: .golangci-bin
Expand Down
24 changes: 12 additions & 12 deletions build/images/codegen/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ ARG K8S_VERSION=1.24.0
# correct K8s version).
ARG KUBEOPENAPI_VERSION=v0.0.0-20220328201542-3ee0da9b0b42

RUN go get k8s.io/code-generator/cmd/client-gen@kubernetes-$K8S_VERSION && \
go get k8s.io/code-generator/cmd/deepcopy-gen@kubernetes-$K8S_VERSION && \
go get k8s.io/code-generator/cmd/conversion-gen@kubernetes-$K8S_VERSION && \
go get k8s.io/code-generator/cmd/lister-gen@kubernetes-$K8S_VERSION && \
go get k8s.io/code-generator/cmd/informer-gen@kubernetes-$K8S_VERSION && \
go get k8s.io/kube-openapi/cmd/openapi-gen@$KUBEOPENAPI_VERSION && \
go get k8s.io/code-generator/cmd/go-to-protobuf@kubernetes-$K8S_VERSION && \
go get k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo@kubernetes-$K8S_VERSION && \
go get github.com/golang/mock/[email protected] && \
go get github.com/golang/protobuf/[email protected] && \
go get golang.org/x/tools/cmd/goimports && \
go get sigs.k8s.io/controller-tools/cmd/[email protected]
RUN go install k8s.io/code-generator/cmd/client-gen@kubernetes-$K8S_VERSION && \
go install k8s.io/code-generator/cmd/deepcopy-gen@kubernetes-$K8S_VERSION && \
go install k8s.io/code-generator/cmd/conversion-gen@kubernetes-$K8S_VERSION && \
go install k8s.io/code-generator/cmd/lister-gen@kubernetes-$K8S_VERSION && \
go install k8s.io/code-generator/cmd/informer-gen@kubernetes-$K8S_VERSION && \
go install k8s.io/kube-openapi/cmd/openapi-gen@$KUBEOPENAPI_VERSION && \
go install k8s.io/code-generator/cmd/go-to-protobuf@kubernetes-$K8S_VERSION && \
go install k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo@kubernetes-$K8S_VERSION && \
go install github.com/golang/mock/[email protected] && \
go install github.com/golang/protobuf/[email protected] && \
go install golang.org/x/tools/cmd/goimports@latest && \
go install sigs.k8s.io/controller-tools/cmd/[email protected]

COPY --from=protoc /tmp/protoc/bin /usr/local/bin
COPY --from=protoc /tmp/protoc/include /usr/local/include
Expand Down
1 change: 1 addition & 0 deletions build/images/codegen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Here is the table of codegen images that have been uploaded:

| Tag | Change |
| :----------------------------- | --------------------------------------- |
| kubernetes-1.24.0-build.1 | Upgraded Go to v1.19 |
| kubernetes-1.24.0-build.0 | Add controller-gen v0.9.0 |
| kubernetes-1.24.0 | Upgraded K8s libraries to v1.24.0 |
| kubernetes-1.21.0-build.1 | Upgraded protoc-gen-go to v1.5.2 |
Expand Down
2 changes: 1 addition & 1 deletion build/images/deps/go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.17
1.19
Loading

0 comments on commit 856679b

Please sign in to comment.