Skip to content

Commit

Permalink
k8s.io/code-generator: Enable generate-* scripts usage as module deps
Browse files Browse the repository at this point in the history
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.

Kubernetes-commit: f174307e49442dacf2dfd22ffadca81a53e7377d
  • Loading branch information
LorbusChris authored and k8s-publishing-bot committed Aug 6, 2020
1 parent 96aa56d commit 04e4fe8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions generate-groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
7 changes: 6 additions & 1 deletion generate-internal-groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$*"; }

Expand Down

0 comments on commit 04e4fe8

Please sign in to comment.