Skip to content

Commit

Permalink
Merge pull request #298 from xrstf/bump-controller-tools
Browse files Browse the repository at this point in the history
Update code-generator to 1.30.1
  • Loading branch information
k8s-ci-robot authored Nov 8, 2024
2 parents a04a366 + 3c46998 commit 06ad3b6
Show file tree
Hide file tree
Showing 19 changed files with 4,832 additions and 5,286 deletions.
8,859 changes: 4,282 additions & 4,577 deletions config/prow/cluster/prowjob-crd/prowjob_customresourcedefinition.yaml

Large diffs are not rendered by default.

150 changes: 29 additions & 121 deletions hack/make-rules/update/codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ listergen=${REPO_ROOT}/_bin/lister-gen
go build -o "${listergen}" k8s.io/code-generator/cmd/lister-gen
go_bindata=${REPO_ROOT}/_bin/go-bindata
go build -o "${go_bindata}" github.com/go-bindata/go-bindata/v3/go-bindata
controller_gen=${REPO_ROOT}/_bin/controller-gen
go build -o "${controller_gen}" sigs.k8s.io/controller-tools/cmd/controller-gen
controllergen=${REPO_ROOT}/_bin/controller-gen
go build -o "${controllergen}" sigs.k8s.io/controller-tools/cmd/controller-gen
protoc_gen_go="${REPO_ROOT}/_bin/protoc-gen-go" # golang protobuf plugin
GOBIN="${REPO_ROOT}/_bin" go install google.golang.org/protobuf/cmd/[email protected]
GOBIN="${REPO_ROOT}/_bin" go install google.golang.org/grpc/cmd/[email protected]

cd "${REPO_ROOT}"
ensure-protoc-deps(){
ensure-protoc-deps() {
# Install protoc
if [[ ! -f "_bin/protoc/bin/protoc" ]]; then
mkdir -p _bin/protoc
Expand Down Expand Up @@ -90,163 +90,82 @@ ensure-protoc-deps(){
ensure-protoc-deps

echo "Finished installations."
do_clean=${1:-}

# FAKE_GOPATH is for mimicking GOPATH layout.
# K8s code-generator tools all assume the structure of ${GOPATH}/src/k8s.io/...,
# faking GOPATH so that the output are dropped correctly.
# All the clean/copy functions below are for transferring output to this repo.
FAKE_GOPATH=""

cleanup() {
if [[ -n ${FAKE_GOPATH:-} ]]; then chmod -R u+rwx $FAKE_GOPATH && rm -rf $FAKE_GOPATH; fi
if [[ -n ${TEMP_GOCACHE:-} ]]; then rm -rf $TEMP_GOCACHE; fi
}
trap cleanup EXIT

ensure-in-gopath() {
FAKE_GOPATH=$(mktemp -d -t codegen.gopath.XXXX)

fake_repopath=$FAKE_GOPATH/src/sigs.k8s.io/prow
mkdir -p "$(dirname "$fake_repopath")"
if [[ -n "$do_clean" ]]; then
cp -LR "${REPO_ROOT}/" "$fake_repopath"
else
cp -R "${REPO_ROOT}/" "$fake_repopath"
fi

export GOPATH=$FAKE_GOPATH
cd "$fake_repopath"
}

gen-prow-config-documented() {
go run ./hack/gen-prow-documented
}

# copyfiles will copy all files in 'path' in the fake gopath over to the
# workspace directory as the code generators output directly into GOPATH,
# meaning without this function the generated files are left in /tmp
copyfiles() {
path=$1
name=$2
if [[ ! -d "$path" ]]; then
return 0
fi
(
cd "$GOPATH/src/sigs.k8s.io/prow/$path"
find "." -name "$name" -exec cp {} "$REPO_ROOT/$path/{}" \;
)
}

# clean will delete files matching name in path.
#
# When inside bazel test the files are read-only.
# Any attempts to write a file that already exists will fail.
# So resolve by deleting the files before generating them.
clean() {
path=$1
name=$2
if [[ ! -d "$path" || -z "$do_clean" ]]; then
return 0
fi
find "$path" -name "$name" -delete
find "${REPO_ROOT}"/"$path" -name "$name" -delete
}

gen-deepcopy() {
clean pkg/apis 'zz_generated.deepcopy.go'
clean pkg/config 'zz_generated.deepcopy.non_k8s.go'
echo "Generating DeepCopy() methods..." >&2
"$deepcopygen" \
--go-header-file hack/boilerplate/boilerplate.generated.go.txt \
--input-dirs sigs.k8s.io/prow/pkg/apis/prowjobs/v1 \
--output-file-base zz_generated.deepcopy \
--bounding-dirs sigs.k8s.io/prow/pkg/apis
copyfiles "pkg/apis" "zz_generated.deepcopy.go"

"$deepcopygen" \
"$deepcopygen" ./... \
--go-header-file hack/boilerplate/boilerplate.generated.go.txt \
--input-dirs sigs.k8s.io/prow/pkg/config \
--output-file-base zz_generated.deepcopy
copyfiles "pkg/config" "zz_generated.deepcopy.go"

--output-file zz_generated.deepcopy.go \
--bounding-dirs sigs.k8s.io/prow/pkg/apis,sigs.k8s.io/prow/pkg/config
}

gen-client() {
clean pkg/client/clientset '*.go'
echo "Generating client..." >&2
"$clientgen" \
--go-header-file hack/boilerplate/boilerplate.generated.go.txt \
--clientset-name versioned \
--input-base "" \
--input sigs.k8s.io/prow/pkg/apis/prowjobs/v1 \
--output-package sigs.k8s.io/prow/pkg/client/clientset
copyfiles "./pkg/client/clientset" "*.go"
--output-dir pkg/client/clientset \
--output-pkg sigs.k8s.io/prow/pkg/client/clientset

clean pkg/pipeline/clientset '*.go'
echo "Generating client for pipeline..." >&2
"$clientgen" \
--go-header-file hack/boilerplate/boilerplate.generated.go.txt \
--clientset-name versioned \
--input-base "" \
--input github.com/tektoncd/pipeline/pkg/apis/pipeline/v1 \
--output-package sigs.k8s.io/prow/pkg/pipeline/clientset
copyfiles "./pkg/pipeline/clientset" "*.go"
--output-dir pkg/pipeline/clientset \
--output-pkg sigs.k8s.io/prow/pkg/pipeline/clientset
}

gen-lister() {
clean pkg/client/listers '*.go'
echo "Generating lister..." >&2
"$listergen" \
"$listergen" sigs.k8s.io/prow/pkg/apis/prowjobs/v1 \
--go-header-file hack/boilerplate/boilerplate.generated.go.txt \
--input-dirs sigs.k8s.io/prow/pkg/apis/prowjobs/v1 \
--output-package sigs.k8s.io/prow/pkg/client/listers
copyfiles "./pkg/client/listers" "*.go"
--output-dir pkg/client/listers \
--output-pkg sigs.k8s.io/prow/pkg/client/listers

clean pkg/pipeline/listers '*.go'
echo "Generating lister for pipeline..." >&2
"$listergen" \
"$listergen" github.com/tektoncd/pipeline/pkg/apis/pipeline/v1 \
--go-header-file hack/boilerplate/boilerplate.generated.go.txt \
--input-dirs github.com/tektoncd/pipeline/pkg/apis/pipeline/v1 \
--output-package sigs.k8s.io/prow/pkg/pipeline/listers
copyfiles "./pkg/pipeline/listers" "*.go"
--output-dir pkg/pipeline/listers \
--output-pkg sigs.k8s.io/prow/pkg/pipeline/listers
}

gen-informer() {
clean pkg/client/informers '*.go'
echo "Generating informer..." >&2
"$informergen" \
"$informergen" sigs.k8s.io/prow/pkg/apis/prowjobs/v1 \
--go-header-file hack/boilerplate/boilerplate.generated.go.txt \
--input-dirs sigs.k8s.io/prow/pkg/apis/prowjobs/v1 \
--versioned-clientset-package sigs.k8s.io/prow/pkg/client/clientset/versioned \
--listers-package sigs.k8s.io/prow/pkg/client/listers \
--output-package sigs.k8s.io/prow/pkg/client/informers
copyfiles "./pkg/client/informers" "*.go"
--output-dir pkg/client/informers \
--output-pkg sigs.k8s.io/prow/pkg/client/informers

clean pkg/pipeline/informers '*.go'
echo "Generating informer for pipeline..." >&2
"$informergen" \
"$informergen" github.com/tektoncd/pipeline/pkg/apis/pipeline/v1 \
--go-header-file hack/boilerplate/boilerplate.generated.go.txt \
--input-dirs github.com/tektoncd/pipeline/pkg/apis/pipeline/v1 \
--versioned-clientset-package sigs.k8s.io/prow/pkg/pipeline/clientset/versioned \
--listers-package sigs.k8s.io/prow/pkg/pipeline/listers \
--output-package sigs.k8s.io/prow/pkg/pipeline/informers
copyfiles "./pkg/pipeline/informers" "*.go"
--output-dir pkg/pipeline/informers \
--output-pkg sigs.k8s.io/prow/pkg/pipeline/informers
}

gen-spyglass-bindata(){
gen-spyglass-bindata() {
cd pkg/spyglass/lenses/common/
echo "Generating spyglass bindata..." >&2
$go_bindata -pkg=common static/
gofmt -s -w ./
cd - >/dev/null
}

gen-prowjob-crd(){
clean "./config/prow/cluster" "prowjob_customresourcedefinition.yaml"
gen-prowjob-crd() {
echo "Generating prowjob crd..." >&2
if [[ -z ${HOME:-} ]]; then export HOME=$PWD; fi
$controller_gen crd:preserveUnknownFields=false,crdVersions=v1 paths=./pkg/apis/prowjobs/v1 output:stdout \
"$controllergen" crd:crdVersions=v1 paths=./pkg/apis/prowjobs/v1 output:stdout \
| $SED '/^$/d' \
| $SED '/^spec:.*/a \ preserveUnknownFields: false' \
| $SED '/^ annotations.*/a \ api-approved.kubernetes.io: https://github.com/kubernetes/test-infra/pull/8669' \
Expand All @@ -263,12 +182,10 @@ gen-prowjob-crd(){
- completionTime
EOF
) > ./config/prow/cluster/prowjob-crd/prowjob_customresourcedefinition.yaml
copyfiles "./config/prow/cluster/prowjob-crd" "prowjob_customresourcedefinition.yaml"
unset HOME
}

# Generate gRPC stubs for a given protobuf file.
gen-proto-stubs(){
gen-proto-stubs() {
local dir
dir="$(dirname "$1")"

Expand All @@ -285,7 +202,7 @@ gen-proto-stubs(){
"$1"
}

gen-all-proto-stubs(){
gen-all-proto-stubs() {
echo >&2 "Generating proto stubs"

# Expose the golang protobuf plugin binaries (protoc-gen-go,
Expand All @@ -303,7 +220,7 @@ gen-all-proto-stubs(){
-print0 | sort -z)
}

gen-gangway-apidescriptorpb-for-cloud-endpoints(){
gen-gangway-apidescriptorpb-for-cloud-endpoints() {
echo >&2 "Generating self-describing proto stub (gangway_api_descriptor.pb) for gangway.proto"

"${REPO_ROOT}/_bin/protoc/bin/protoc" \
Expand All @@ -318,24 +235,15 @@ gen-gangway-apidescriptorpb-for-cloud-endpoints(){

gen-prow-config-documented

export GO111MODULE=off
ensure-in-gopath
old=${GOCACHE:-}
export TEMP_GOCACHE=$(mktemp -d -t codegen.gocache.XXXX)
export GOCACHE=$TEMP_GOCACHE
export GO111MODULE=on
export GOPROXY=https://proxy.golang.org
export GOSUMDB=sum.golang.org
go mod vendor
export GO111MODULE=off
export GOCACHE=$old

gen-deepcopy
gen-client
gen-lister
gen-informer
gen-spyglass-bindata
gen-prowjob-crd
export GO111MODULE=on

gen-all-proto-stubs
gen-gangway-apidescriptorpb-for-cloud-endpoints
45 changes: 22 additions & 23 deletions hack/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ go 1.22.3
// packages: https://github.com/golang/go/issues/44840#issuecomment-1651863470

require (
github.com/bazelbuild/buildtools v0.0.0-20211007154642-8dd79e56e98e
github.com/client9/misspell v0.3.4
github.com/go-bindata/go-bindata/v3 v3.1.3
github.com/golang/protobuf v1.5.3
github.com/golang/protobuf v1.5.4
github.com/golangci/golangci-lint v1.57.2
github.com/google/ko v0.14.1
github.com/sethvargo/gcs-cacher v0.1.3
gotest.tools/gotestsum v1.7.0
k8s.io/code-generator v0.21.4
sigs.k8s.io/controller-tools v0.6.3-0.20210827222652-7b3a8699fa04
k8s.io/code-generator v0.30.1
sigs.k8s.io/controller-tools v0.15.0
)

require (
Expand Down Expand Up @@ -104,11 +103,11 @@ require (
github.com/fatih/color v1.16.0 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/firefart/nonamedreturns v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fzipp/gocyclo v0.6.0 // indirect
github.com/ghostiam/protogetter v0.3.5 // indirect
github.com/go-critic/go-critic v0.11.2 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
Expand All @@ -128,7 +127,7 @@ require (
github.com/go-toolsmith/typep v1.1.0 // indirect
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
github.com/go-xmlfmt/xmlfmt v1.1.2 // indirect
github.com/gobuffalo/flect v0.2.3 // indirect
github.com/gobuffalo/flect v1.0.2 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand Down Expand Up @@ -236,7 +235,7 @@ require (
github.com/sourcegraph/go-diff v0.7.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.16.0 // indirect
Expand Down Expand Up @@ -269,20 +268,20 @@ require (
go.opencensus.io v0.24.0 // indirect
go.uber.org/automaxprocs v1.5.3 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect
golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.19.0 // indirect
golang.org/x/tools v0.20.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.152.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
Expand All @@ -297,16 +296,16 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.4.7 // indirect
k8s.io/api v0.27.3 // indirect
k8s.io/apiextensions-apiserver v0.21.4 // indirect
k8s.io/apimachinery v0.28.1 // indirect
k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/api v0.30.0 // indirect
k8s.io/apiextensions-apiserver v0.30.0 // indirect
k8s.io/apimachinery v0.30.1 // indirect
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
mvdan.cc/gofumpt v0.6.0 // indirect
mvdan.cc/unparam v0.0.0-20240104100049-c549a3470d14 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kind v0.20.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit 06ad3b6

Please sign in to comment.