github.com/verrazzano/verrazzano@v1.7.0/cluster-operator/hack/update-codegen.sh (about) 1 #!/bin/bash 2 # Copyright (c) 2020, 2022, Oracle and/or its affiliates. 3 # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 4 5 set -o errexit 6 set -o nounset 7 set -o pipefail 8 9 API_GROUP_VERSION=$1 10 GO_HEADER_BOILERPLATE=$2 11 12 CODEGEN_PATH=k8s.io/code-generator 13 14 SCRIPT_ROOT=$(dirname $0)/.. 15 echo "script_root = ${SCRIPT_ROOT}" 16 17 # Obtain k8s.io/code-generator version 18 codeGenVer=$(go list -m -f '{{.Version}}' k8s.io/code-generator) 19 20 # ensure code-generator has been downloaded 21 go get -d k8s.io/code-generator@${codeGenVer} 22 23 CODEGEN_PKG=${CODEGEN_PKG:-${GOPATH:-${HOME}/go}/pkg/mod/${CODEGEN_PATH}@${codeGenVer}} 24 echo "codegen_pkg = ${CODEGEN_PKG}" 25 chmod +x ${CODEGEN_PKG}/generate-groups.sh 26 27 GENERATED_CLIENT_DIR=$SCRIPT_ROOT/clientset 28 echo Remove $GENERATED_CLIENT_DIR dir if exist 29 rm -rf $GENERATED_CLIENT_DIR 30 31 # generate the code with: 32 # --output-base because this script should also be able to run inside the vendor dir of 33 # k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir 34 # instead of the $GOPATH directly. For normal projects this can be dropped. 35 ${CODEGEN_PKG}/generate-groups.sh "client" \ 36 github.com/verrazzano/verrazzano/cluster-operator github.com/verrazzano/verrazzano/cluster-operator/apis \ 37 "${API_GROUP_VERSION}" \ 38 --output-base "${GOPATH:-${HOME}/go}/src" \ 39 --go-header-file ${SCRIPT_ROOT}/hack/${GO_HEADER_BOILERPLATE}