mirror of https://github.com/knative/pkg.git
drop use of code-generator/generate-groups.sh (#3136)
* drop use of code-generator/generate-groups.sh * fix script * single injection invocation
This commit is contained in:
parent
c43477f005
commit
a37a847cd3
|
@ -15,5 +15,5 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +groupName=sample.knative.dev
|
||||
// +groupName=example.knative.dev
|
||||
package v1alpha1
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2020 The Knative Authors
|
||||
Copyright 2022 The Knative Authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -15,5 +15,5 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +groupName=sample.knative.dev
|
||||
// +groupName=pub.knative.dev
|
||||
package v1alpha1
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2020 The Knative Authors
|
||||
Copyright 2022 The Knative Authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -18,7 +18,7 @@ set -o errexit
|
|||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
# generate-groups generates everything for a project with external types only, e.g. a project based
|
||||
# generate-knative generates everything for a project with external types only, e.g. a project based
|
||||
# on CustomResourceDefinitions.
|
||||
|
||||
if [ "$#" -lt 4 ] || [ "${1}" == "--help" ]; then
|
||||
|
|
|
@ -20,16 +20,8 @@ set -o pipefail
|
|||
|
||||
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=
|
||||
|
||||
echo "=== Update Codegen for $MODULE_NAME"
|
||||
|
||||
# generate the code with:
|
||||
# --output-base because this script should also be able to run inside the vendor dir of
|
||||
# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir
|
||||
# instead of the $GOPATH directly. For normal projects this can be dropped.
|
||||
|
||||
group "Kubernetes Codegen"
|
||||
|
||||
# Knative Injection
|
||||
|
|
|
@ -257,15 +257,6 @@ To make generating stubs simple, we have harnessed the Kubernetes
|
|||
code-generation tooling to produce `injection-gen`. Similar to how you might
|
||||
ordinarily run the other `foo-gen` processed:
|
||||
|
||||
```shell
|
||||
CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${REPO_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}
|
||||
|
||||
${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
|
||||
github.com/knative/sample-controller/pkg/client github.com/knative/sample-controller/pkg/apis \
|
||||
"samples:v1alpha1" \
|
||||
--go-header-file ${REPO_ROOT}/hack/boilerplate/boilerplate.go.txt
|
||||
```
|
||||
|
||||
To run `injection-gen` you run the following (replacing the import path and api
|
||||
group):
|
||||
|
||||
|
|
|
@ -30,30 +30,25 @@ rm -rf $(dirname $0)/genclient
|
|||
|
||||
header "Test Generated Reconciler Builds."
|
||||
|
||||
chmod +x ${CODEGEN_PKG}/generate-groups.sh
|
||||
source "${CODEGEN_PKG}/kube_codegen.sh"
|
||||
|
||||
${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
|
||||
${GENCLIENT_PKG} knative.dev/pkg/apis/test \
|
||||
"example:v1alpha1" \
|
||||
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt
|
||||
kube::codegen::gen_helpers \
|
||||
--boilerplate "${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt" \
|
||||
"${REPO_ROOT_DIR}/apis/test"
|
||||
|
||||
kube::codegen::gen_client \
|
||||
--boilerplate "${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt" \
|
||||
--output-dir "${REPO_ROOT_DIR}/test/genclient" \
|
||||
--output-pkg "${GENCLIENT_PKG}" \
|
||||
--with-watch \
|
||||
"${REPO_ROOT_DIR}/apis/test"
|
||||
|
||||
# Knative Injection
|
||||
${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh "injection" \
|
||||
${GENCLIENT_PKG} knative.dev/pkg/apis/test \
|
||||
"example:v1alpha1" \
|
||||
"example:v1alpha1,pub:v1alpha1" \
|
||||
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt \
|
||||
--force-genreconciler-kinds "Foo"
|
||||
|
||||
${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
|
||||
${GENCLIENT_PKG}/pub knative.dev/pkg/apis/test \
|
||||
"pub:v1alpha1" \
|
||||
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt
|
||||
|
||||
# Knative Injection
|
||||
${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh "injection" \
|
||||
${GENCLIENT_PKG}/pub knative.dev/pkg/apis/test \
|
||||
"pub:v1alpha1" \
|
||||
--go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt
|
||||
--force-genreconciler-kinds "Foo,Bar"
|
||||
|
||||
if ! go build -v $(dirname $0)/genclient/... ; then
|
||||
exit 1
|
||||
|
|
Loading…
Reference in New Issue