Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate the gopath hacks to allow for codegen anywhere. #10245

Merged
merged 1 commit into from
Dec 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@ set -o errexit
set -o nounset
set -o pipefail

export GO111MODULE=on
source $(dirname $0)/../vendor/knative.dev/hack/codegen-library.sh

# If we run with -mod=vendor here, then generate-groups.sh looks for vendor files in the wrong place.
export GOFLAGS=-mod=

if [ -z "${GOPATH:-}" ]; then
export GOPATH=$(go env GOPATH)
fi

source $(dirname $0)/../vendor/knative.dev/hack/library.sh

boilerplate="${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt"

echo "=== Update Codegen for $MODULE_NAME"

# Parse flags to determine if we should generate protobufs.
generate_protobufs=0
while [[ $# -ne 0 ]]; do
Expand All @@ -43,7 +40,7 @@ done
readonly generate_protobufs

if (( generate_protobufs )); then
echo "Generating protocol buffer code"
group "Generating protocol buffer code"
protos=$(find "${REPO_ROOT_DIR}/pkg" "${REPO_ROOT_DIR}/test" -name '*.proto')
for proto in $protos
do
Expand All @@ -57,14 +54,11 @@ if (( generate_protobufs )); then
done
fi

echo "Generating checksums for configmap _example keys"
${REPO_ROOT_DIR}/hack/update-checksums.sh
group "Generating checksums for configmap _example keys"

CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 $(dirname $0)/../vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}
KNATIVE_CODEGEN_PKG=${KNATIVE_CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 $(dirname $0)/../vendor/knative.dev/pkg 2>/dev/null || echo ../pkg)}
${REPO_ROOT_DIR}/hack/update-checksums.sh

chmod +x ${CODEGEN_PKG}/generate-groups.sh
chmod +x ${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh
group "Kubernetes Codegen"

# generate the code with:
# --output-base because this script should also be able to run inside the vendor dir of
Expand All @@ -75,12 +69,16 @@ ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
"serving:v1 serving:v1alpha1 autoscaling:v1alpha1" \
--go-header-file "${boilerplate}"

group "Knative Codegen"

# Knative Injection
${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh "injection" \
knative.dev/serving/pkg/client knative.dev/serving/pkg/apis \
"serving:v1 serving:v1alpha1 autoscaling:v1alpha1" \
--go-header-file "${boilerplate}"

group "Deepcopy Gen"

# Depends on generate-groups.sh to install bin/deepcopy-gen
${GOPATH}/bin/deepcopy-gen \
-O zz_generated.deepcopy \
Expand All @@ -98,5 +96,7 @@ ${GOPATH}/bin/deepcopy-gen \
-i knative.dev/serving/pkg/logging \
-i knative.dev/serving/pkg/metrics

group "Update deps post-codegen"

# Make sure our dependencies are up-to-date
${REPO_ROOT_DIR}/hack/update-deps.sh