github.com/regadas/controller-tools@v0.5.1-0.20210408091555-18885b17ff7b/.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 github.com/regadas/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 $@