halkyon.io/api@v1.0.0-rc.6/generate-deepcopy.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -o errexit
     4  set -o nounset
     5  set -o pipefail
     6  
     7  TMP_DIR=$(mktemp -d)
     8  
     9  cleanup() {
    10    rm -rf "${TMP_DIR}"
    11  }
    12  trap "cleanup" EXIT SIGINT
    13  
    14  cleanup
    15  
    16  # The following solution for making code generation work with go modules is
    17  # borrowed and modified from https://github.com/heptio/contour/pull/1010.
    18  #export GO111MODULE=on
    19  VERSION=$(go list -m all | grep k8s.io/code-generator | rev | cut -d"-" -f1 | cut -d" " -f1 | rev)
    20  echo "Using ${VERSION} of k8s code generator"
    21  git clone https://github.com/kubernetes/code-generator.git "${TMP_DIR}"
    22  (cd "${TMP_DIR}" && git reset --hard "${VERSION}" && go mod init)
    23  
    24  # Usage: generate-groups.sh <generators> <output-package> <apis-package> <groups-versions> ...
    25  #
    26  #   <generators>        the generators comma separated to run (deepcopy,defaulter,client,lister,informer) or "all".
    27  #   <output-package>    the output package name (e.g. github.com/example/project/pkg/generated).
    28  #   <apis-package>      the external types dir (e.g. github.com/example/api or github.com/example/project/pkg/apis).
    29  #   <groups-versions>   the groups and their versions in the format "groupA:v1,v2 groupB:v1 groupC:v2", relative
    30  #                       to <api-package>.
    31  #   ...                 arbitrary flags passed to all generator binaries.
    32  #
    33  #
    34  # Examples:
    35  #   generate-groups.sh all             github.com/example/project/pkg/client github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1"
    36  #   generate-groups.sh deepcopy,client github.com/example/project/pkg/client github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1"
    37  
    38  for group in capability component runtime capability-info; do
    39    "${TMP_DIR}"/generate-groups.sh "deepcopy,client" \
    40      halkyon.io/api/${group} \
    41      halkyon.io/api \
    42      "${group}:v1beta1" \
    43      --go-header-file "${TMP_DIR}"/hack/boilerplate.go.txt
    44  done