sigs.k8s.io/controller-tools@v0.15.1-0.20240515195456-85686cb69316/.run-controller-gen.sh (about) 1 #!/usr/bin/env bash 2 3 # This builds and runs controller-gen in a particular context 4 # it's the equivalent of `go run sigs.k8s.io/controller-tools/cmd/controller-gen` 5 # if you could somehow do that without modifying your go.mod. 6 7 set -o errexit 8 set -o nounset 9 set -o pipefail 10 11 readlink=$(command -v readlink) 12 13 check_readlink() { 14 local test_file="$(mktemp)" 15 trap "rm -f $test_file" EXIT 16 if ! ${readlink} -f "$test_file" &>/dev/null; then 17 if [[ "${OSTYPE}" == "darwin"* ]]; then 18 if command -v greadlink; then 19 readlink=$(command -v greadlink) 20 return 21 fi 22 fi 23 echo "you're probably on OSX. Please install gnu readlink -- otherwise you're missing the most useful readlink flag." 24 exit 1 25 fi 26 } 27 current_dir=$(pwd) 28 check_readlink 29 cd $(dirname $(${readlink} -f ${BASH_SOURCE[0]})) 30 go run -v -exec "./.run-in.sh ${current_dir} " ./cmd/controller-gen $@