Skip to content

Commit

Permalink
Use a fork of code-generator. (#1359)
Browse files Browse the repository at this point in the history
This is implementing a workaround as discussed in
#1326

The logic in update-codegen.sh is changed to deal with the replace.

We can just remove the replace once we upgrade to upstream
code-generator which has the change, i.e.
v0.18.0-alpha.1.0.20191220033320-6b257a9d6f46 or later.

Signed-off-by: Marcin Owsiany <mowsiany@D2iQ.com>
Co-authored-by: Andreas Neumann <aneumann@mesosphere.com>
  • Loading branch information
porridge and ANeumann82 committed Feb 28, 2020
1 parent 0620095 commit ef9a786
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ require (
sigs.k8s.io/kind v0.6.1
sigs.k8s.io/yaml v1.1.0
)

replace k8s.io/code-generator v0.16.6 => github.com/kudobuilder/code-generator v0.16.6-beta.0.0.20200221140535-0ef46f1228ff
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kudobuilder/code-generator v0.16.6-beta.0.0.20200221140535-0ef46f1228ff h1:nWmLr2OacKLJDzTc0RQ+icPZnYXwM/eY2rgsOrTUekQ=
github.com/kudobuilder/code-generator v0.16.6-beta.0.0.20200221140535-0ef46f1228ff/go.mod h1:2aiDuxDU7RQK2PVypXAXHo6+YwOlF33iezHQbSmKSA4=
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc=
github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a h1:weJVJJRzAJBFRlAiJQROKQs8oC9vOxvm4rZmBBk0ONw=
Expand Down Expand Up @@ -666,8 +668,6 @@ k8s.io/client-go v0.0.0-20190918160344-1fbdaa4c8d90/go.mod h1:J69/JveO6XESwVgG53
k8s.io/client-go v0.16.6 h1:OR6ZaSlIn9dUdpiN4r5mAvMv5aCupUJUiDJZdrrvmhw=
k8s.io/client-go v0.16.6/go.mod h1:xIQ44uaAH4SD1EHMtCHsB9By7D0qblbv1ADeGyXpZUQ=
k8s.io/code-generator v0.0.0-20190912054826-cd179ad6a269/go.mod h1:V5BD6M4CyaN5m+VthcclXWsVcT1Hu+glwa1bi3MIsyE=
k8s.io/code-generator v0.16.6 h1:wykZVkEDQd/BcOZxcQMEW6uFgoM4ZmvjIhxkbmEJ3WA=
k8s.io/code-generator v0.16.6/go.mod h1:2aiDuxDU7RQK2PVypXAXHo6+YwOlF33iezHQbSmKSA4=
k8s.io/component-base v0.0.0-20190918160511-547f6c5d7090/go.mod h1:933PBGtQFJky3TEwYx4aEPZ4IxqhWh3R6DCmzqIn1hA=
k8s.io/component-base v0.16.6 h1:1qIWVKni+gqRkN8vvaGYJk+R8tRtKDv0XvvDuYEBD1w=
k8s.io/component-base v0.16.6/go.mod h1:8+4lrSEgLQ9wqOzHVYx4GLSCU6sus8wqg8bfaTdXTwg=
Expand Down
7 changes: 5 additions & 2 deletions hack/update_codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ set -o pipefail
# borrowed and modified from https://github.com/heptio/contour/pull/1010.
# it has been modified to enable caching.
export GO111MODULE=on
VERSION=$(go list -m all | grep k8s.io/code-generator | rev | cut -d"-" -f1 | cut -d" " -f1 | rev)
version_and_repo=$(go list -f '{{if .Replace}}{{.Replace.Version}} {{.Replace.Path}}{{else}}{{.Version}} {{.Path}}{{end}}' -m k8s.io/code-generator)
VERSION="$(echo "${version_and_repo}" | cut -d' ' -f 1 | rev | cut -d"-" -f1 | rev)"
CODEGEN_REPO="$(echo "${version_and_repo}" | cut -d' ' -f 2)"
REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel)}"
CODE_GEN_DIR="${REPO_ROOT}/hack/code-gen/$VERSION"

if [[ -d ${CODE_GEN_DIR} ]]; then
echo "Using cached code generator version: $VERSION"
else
git clone https://github.com/kubernetes/code-generator.git "${CODE_GEN_DIR}"
echo "Cloning code-generator from ${CODEGEN_REPO}"
git clone https://${CODEGEN_REPO}.git "${CODE_GEN_DIR}"
git -C "${CODE_GEN_DIR}" reset --hard "${VERSION}"
fi

Expand Down

0 comments on commit ef9a786

Please sign in to comment.