diff --git a/client/hack/README.md b/client/hack/README.md index dfa7b69d0..dd5df9ef7 100644 --- a/client/hack/README.md +++ b/client/hack/README.md @@ -26,13 +26,13 @@ Make sure to run this script after making changes to /client/apis/volumesnapshot ``` * Checkout latest release version ```bash - git checkout v0.29.1 + git checkout v0.30.0 ``` -* Ensure the file `generate-groups.sh` exists +* Ensure the file `kube_codegen.sh` exists ```bash - ls ${GOPATH}/src/k8s.io/code-generator/generate-groups.sh + ls ${GOPATH}/src/k8s.io/code-generator/kube_codegen.sh ``` Update generated client code in external-snapshotter @@ -42,14 +42,13 @@ Update generated client code in external-snapshotter ./hack/update-generated-code.sh ``` -Once you run the script, you will get an output as follows: +Once you run the script, the code will be generated for volumesnapshot:v1 and volumegroupsnapshot:v1alpha1, and you will get an output as follows: ```bash - Generating deepcopy funcs - Generating clientset for volumesnapshot:v1 at github.com/kubernetes-csi/external-snapshotter/client/v7/clientset - Generating listers for volumesnapshot:v1 at github.com/kubernetes-csi/external-snapshotter/client/v7/listers - Generating informers for volumesnapshot:v1 at github.com/kubernetes-csi/external-snapshotter/client/v7/informers - +Generating deepcopy code for 2 targets +Generating client code for 2 targets +Generating lister code for 2 targets +Generating informer code for 2 targets ``` ## update-crd.sh diff --git a/client/hack/update-generated-code.sh b/client/hack/update-generated-code.sh index f61095221..ae2fbafd8 100755 --- a/client/hack/update-generated-code.sh +++ b/client/hack/update-generated-code.sh @@ -20,18 +20,15 @@ set -o pipefail SCRIPT_ROOT=$(unset CDPATH && cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd) -# 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. -${GOPATH}/src/k8s.io/code-generator/generate-groups.sh "deepcopy,client,informer,lister" \ - github.com/kubernetes-csi/external-snapshotter/client/v7 github.com/kubernetes-csi/external-snapshotter/client/v7/apis \ - "volumesnapshot:v1 volumegroupsnapshot:v1alpha1" \ - --go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt +source "${GOPATH}/src/k8s.io/code-generator/kube_codegen.sh" -# To use your own boilerplate text use: -# --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt +kube::codegen::gen_helpers \ + --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ + "${SCRIPT_ROOT}/apis" -# Move generated file from client/v7 to client folder and remove client/v7 -cp -rf v7/. . -rm -rf v7 +kube::codegen::gen_client \ + --output-dir "${SCRIPT_ROOT}" \ + --output-pkg "github.com/kubernetes-csi/external-snapshotter/client/v7" \ + --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ + --with-watch \ + "${SCRIPT_ROOT}/apis"