diff --git a/build/crds/crds.go b/build/crds/crds.go index 1bcaee88b..01bee7092 100644 --- a/build/crds/crds.go +++ b/build/crds/crds.go @@ -1,3 +1,4 @@ +//go:build crds // +build crds /* diff --git a/build/makelib/golang.mk b/build/makelib/golang.mk index 697ea293d..fed6de033 100644 --- a/build/makelib/golang.mk +++ b/build/makelib/golang.mk @@ -156,7 +156,10 @@ go.vet: .PHONY: go.fmt go.fmt: $(GOFMT) - @gofmt_out=$$($(GOFMT) -s -d -e $(GO_SUBDIRS) $(GO_INTEGRATION_TESTS_SUBDIRS) 2>&1) && [ -z "$${gofmt_out}" ] || (echo "$${gofmt_out}" 1>&2; exit 1) + # ignore deepcopy generated files since the tool hardcoded the header with a "// +build" which in Golang 1.17 makes it fail gofmt since "////go:build" is preferred + # see: https://github.com/kubernetes/gengo/blob/master/examples/deepcopy-gen/generators/deepcopy.go#L136 + # https://github.com/kubernetes/gengo/pull/210 + @gofmt_out=$$(find . -name "*.go" -not -name "*.deepcopy.go" | xargs $(GOFMT) -s -d -e 2>&1) && [ -z "$${gofmt_out}" ] || (echo "$${gofmt_out}" 1>&2; exit 1) go.validate: go.vet go.fmt