github.com/verrazzano/verrazzano-monitoring-operator@v0.0.30/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  CODEGEN_PATH=k8s.io/code-generator
    10  GOPATH=$(go env GOPATH)
    11  SCRIPT_ROOT=$(dirname $0)/..
    12  # Obtain k8s.io/code-generator version
    13  codeGenVer=$(go list -m -f '{{.Version}}' k8s.io/code-generator)
    14  # ensure code-generator has been downloaded
    15  go get -d k8s.io/code-generator@${codeGenVer}
    16  CODEGEN_PKG=${CODEGEN_PKG:-${GOPATH}/pkg/mod/${CODEGEN_PATH}@${codeGenVer}}
    17  echo "codegen_pkg = ${CODEGEN_PKG}"
    18  chmod +x ${CODEGEN_PKG}/generate-groups.sh
    19  
    20  GENERATED_ZZ_FILE=$SCRIPT_ROOT/pkg/apis/vmcontroller/v1/zz_generated.deepcopy.go
    21  echo Remove $GENERATED_ZZ_FILE file if exist
    22  rm -f $GENERATED_ZZ_FILE
    23  
    24  GENERATED_CLIENT_DIR=$SCRIPT_ROOT/pkg/client
    25  echo Remove $GENERATED_CLIENT_DIR dir if exist
    26  rm -rf $GENERATED_CLIENT_DIR
    27  
    28  # generate the code with:
    29  # --output-base    because this script should also be able to run inside the vendor dir of
    30  #                  k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir
    31  #                  instead of the $GOPATH directly. For normal projects this can be dropped.
    32  ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
    33    github.com/verrazzano/verrazzano-monitoring-operator/pkg/client github.com/verrazzano/verrazzano-monitoring-operator/pkg/apis \
    34    vmcontroller:v1 \
    35    --output-base "${GOPATH}/src" \
    36    --go-header-file ${SCRIPT_ROOT}/hack/custom-header.txt