|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright 2022 The Serverless Workflow Specification Authors |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +# retrieved from https://github.com/kubernetes/code-generator/blob/master/generate-internal-groups.sh |
| 17 | +# and adapted to only install and run the deepcopy-gen |
| 18 | + |
| 19 | +set -o errexit |
| 20 | +set -o nounset |
| 21 | +set -o pipefail |
| 22 | + |
| 23 | +SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. |
| 24 | +echo "Script root is $SCRIPT_ROOT" |
| 25 | + |
| 26 | +GENS="$1" |
| 27 | +shift 1 |
| 28 | + |
| 29 | +( |
| 30 | + # To support running this script from anywhere, first cd into this directory, |
| 31 | + # and then install with forced module mode on and fully qualified name. |
| 32 | + # make sure your GOPATH env is properly set. |
| 33 | + # it will go under $GOPATH/bin |
| 34 | + cd "$(dirname "${0}")" |
| 35 | + GO111MODULE=on go install k8s.io/code-generator/cmd/deepcopy-gen@latest |
| 36 | +) |
| 37 | + |
| 38 | +function codegen::join() { local IFS="$1"; shift; echo "$*"; } |
| 39 | + |
| 40 | +if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then |
| 41 | + echo "Generating deepcopy funcs" |
| 42 | + export GO111MODULE=on |
| 43 | + # for debug purposes, increase the log level by updating the -v flag to higher numbers, e.g. -v 4 |
| 44 | + "${GOPATH}/bin/deepcopy-gen" -v 1 \ |
| 45 | + --input-dirs ./model -O zz_generated.deepcopy \ |
| 46 | + --go-header-file "${SCRIPT_ROOT}/hack/boilerplate.txt" \ |
| 47 | + "$@" |
| 48 | +fi |
0 commit comments