diff --git a/apis/test/example/v1alpha1/doc.go b/apis/test/example/v1alpha1/doc.go index fa5248c074..e3b0d4ddb8 100644 --- a/apis/test/example/v1alpha1/doc.go +++ b/apis/test/example/v1alpha1/doc.go @@ -15,5 +15,5 @@ limitations under the License. */ // +k8s:deepcopy-gen=package -// +groupName=sample.knative.dev +// +groupName=example.knative.dev package v1alpha1 diff --git a/apis/test/example/v1alpha1/zz_generated.deepcopy.go b/apis/test/example/v1alpha1/zz_generated.deepcopy.go index 3f3022004c..80d979adb4 100644 --- a/apis/test/example/v1alpha1/zz_generated.deepcopy.go +++ b/apis/test/example/v1alpha1/zz_generated.deepcopy.go @@ -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. diff --git a/apis/test/pub/v1alpha1/doc.go b/apis/test/pub/v1alpha1/doc.go index fa5248c074..b17817b28a 100644 --- a/apis/test/pub/v1alpha1/doc.go +++ b/apis/test/pub/v1alpha1/doc.go @@ -15,5 +15,5 @@ limitations under the License. */ // +k8s:deepcopy-gen=package -// +groupName=sample.knative.dev +// +groupName=pub.knative.dev package v1alpha1 diff --git a/apis/test/pub/v1alpha1/zz_generated.deepcopy.go b/apis/test/pub/v1alpha1/zz_generated.deepcopy.go index ef838bbfa4..b23519b695 100644 --- a/apis/test/pub/v1alpha1/zz_generated.deepcopy.go +++ b/apis/test/pub/v1alpha1/zz_generated.deepcopy.go @@ -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. diff --git a/hack/generate-knative.sh b/hack/generate-knative.sh index 931e0a425c..f48966789f 100755 --- a/hack/generate-knative.sh +++ b/hack/generate-knative.sh @@ -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 diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 4f9ffea2a6..a50b18f594 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -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 diff --git a/injection/README.md b/injection/README.md index d7c80adaed..cbc204f95e 100644 --- a/injection/README.md +++ b/injection/README.md @@ -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): diff --git a/test/test-reconciler-codegen.sh b/test/test-reconciler-codegen.sh index c6bb3e20c1..ad0dd88f59 100755 --- a/test/test-reconciler-codegen.sh +++ b/test/test-reconciler-codegen.sh @@ -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