Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
* Bump Go from 1.19 to 1.23
* Use UBI9 instead of UBI8 for operator base image
* Bump some minor Go module dependencies
* Adopt best practices in Dockerfile for building Go code
* Fix typo in README

Signed-off-by: Antonin Bas <[email protected]>
  • Loading branch information
antoninbas committed Sep 13, 2024
1 parent 2ab02ab commit 27043ab
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 53 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build antrea-operator Docker image
run: make docker-build
- name: Build antrea-operator-bundle Docker image
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
needs: get-version
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build antrea-operator Docker image
env:
VERSION: ${{ needs.get-version.outputs.version }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
name: Build binary and run unit tests
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.19
uses: actions/setup-go@v4
- name: Set up Go using version from go.mod
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- name: Check-out code
uses: actions/checkout@v4
- name: Build antrea-operator binary
Expand All @@ -25,10 +25,10 @@ jobs:
name: Check tidy
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.19
uses: actions/setup-go@v4
- name: Set up Go using version from go.mod
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- name: Check-out code
uses: actions/checkout@v4
- name: Check tidy
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ tags
.kube
.kustomize
.controller-gen

bin/
5 changes: 1 addition & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
run:
tests: true
timeout: 5m
skip-files:
- ".*\\.pb\\.go"
skip-dirs-use-default: true

linters-settings:
goimports:
Expand All @@ -19,4 +16,4 @@ linters:
- staticcheck
- gosec
- goimports
- vet
- govet
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ PKG_IS_DEFAULT_CHANNEL := --default-channel
endif
PKG_MAN_OPTS ?= $(FROM_VERSION) $(PKG_CHANNELS) $(PKG_IS_DEFAULT_CHANNEL)

GOLANGCI_LINT_VERSION := v1.51.0
GOLANGCI_LINT_VERSION := v1.60.3
GOLANGCI_LINT_BINDIR := $(CURDIR)/.golangci-bin
GOLANGCI_LINT_BIN := $(GOLANGCI_LINT_BINDIR)/$(GOLANGCI_LINT_VERSION)/golangci-lint

Expand Down Expand Up @@ -79,11 +79,11 @@ test: generate golangci manifests
# Build manager binary
manager:
@echo "===> Building antrea-operator binary <==="
go build -o bin/manager -ldflags '$(LDFLAGS)' main.go
GOOS=linux go build -o bin/manager -ldflags '$(LDFLAGS)' main.go

# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate golangci manifests
go run -ldflags '$(LDFLAGS)' ./main.go
GOOS=linux go run -ldflags '$(LDFLAGS)' ./main.go

# Install CRDs into a cluster
install: manifests kustomize
Expand All @@ -109,7 +109,7 @@ generate: controller-gen

# Build the docker image
docker-build:
docker build -f build/Dockerfile --label version="$(VERSION)" . -t ${IMG}
docker build -f build/Dockerfile --platform linux/amd64 --label version="$(VERSION)" . -t ${IMG}
docker tag ${IMG} antrea/antrea-operator

CONTROLLER_GEN_VERSION := v0.6.2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Building the antrea operator docker image is very simple. From the project root
directory simply type the following command.

```
make all
make docker-build
```

To build antrea operator binary. Run the following command.
Expand Down
19 changes: 10 additions & 9 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
FROM golang:1.19 as antrea-operator-build
FROM golang:1.23 as antrea-operator-build

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
go mod download

# Copy source files
COPY . .

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on make manager
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build/ \
CGO_ENABLED=0 make manager


FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest

LABEL name="antrea-operator-for-kubernetes"
LABEL maintainer="Antrea <[email protected]>"
Expand Down
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/vmware/antrea-operator-for-kubernetes

go 1.19
go 1.23.0

require (
antrea.io/antrea v1.6.0
github.com/containerd/go-cni v1.1.7
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/go-logr/logr v1.2.3
github.com/onsi/gomega v1.24.1
github.com/go-logr/logr v1.4.2
github.com/onsi/gomega v1.34.2
github.com/openshift/api v0.0.0-20220831183848-09c070622e2c
github.com/openshift/cluster-network-operator v0.0.0-20230126193214-327fbb6137da
github.com/openshift/library-go v0.0.0-20220922140741-7772048e4447
Expand Down Expand Up @@ -42,7 +42,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gophercloud/gophercloud v0.19.0 // indirect
Expand Down Expand Up @@ -76,16 +76,16 @@ require (
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.4.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.25.2 // indirect
Expand Down
Loading

0 comments on commit 27043ab

Please sign in to comment.