k8s.io/code-generator: Enable generate-* scripts usage as module deps

So far, the generate scripts could not be required as dependencies
with Go Modules (e.g. in tools.go) as they were installed without
proper module context.

This commit enables the generator scripts to be used as versioned
dependencies with Go Modules by forcing installation into
the fully-qualified module directory.
This commit is contained in:
Christian Glombek 2020-08-06 17:10:12 +02:00 committed by Jordan Liggitt
parent fac3dd6914
commit f174307e49
2 changed files with 9 additions and 4 deletions

View File

@ -47,10 +47,10 @@ GROUPS_WITH_VERSIONS="$4"
shift 4
(
# To support running this script from anywhere, we have to first cd into this directory
# so we can install the tools.
# To support running this script from anywhere, first cd into this directory,
# and then install with forced module mode on and fully qualified name.
cd "$(dirname "${0}")"
go install ./cmd/{defaulter-gen,client-gen,lister-gen,informer-gen,deepcopy-gen}
GO111MODULE=on go install k8s.io/code-generator/cmd/{defaulter-gen,client-gen,lister-gen,informer-gen,deepcopy-gen}
)
# Go installs the above commands to get installed in $GOBIN if defined, and $GOPATH/bin otherwise:
GOBIN="$(go env GOBIN)"

View File

@ -47,7 +47,12 @@ EXT_APIS_PKG="$4"
GROUPS_WITH_VERSIONS="$5"
shift 5
go install ./"$(dirname "${0}")"/cmd/{defaulter-gen,conversion-gen,client-gen,lister-gen,informer-gen,deepcopy-gen,openapi-gen}
(
# To support running this script from anywhere, first cd into this directory,
# and then install with forced module mode on and fully qualified name.
cd "$(dirname "${0}")"
GO111MODULE=on go install k8s.io/code-generator/cmd/{defaulter-gen,conversion-gen,client-gen,lister-gen,informer-gen,deepcopy-gen,openapi-gen}
)
function codegen::join() { local IFS="$1"; shift; echo "$*"; }