Skip to content

Commit

Permalink
k8s: fix generate_code.sh
Browse files Browse the repository at this point in the history
Fix "unbound variable" error if GOPATH is not set correctly.

Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit authored and David Ko committed Dec 1, 2023
1 parent 7a0c3ed commit 5c6b065
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions k8s/generate_code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ CODE_GENERATOR_VERSION="v0.18.0"
CRDS_DIR="crds"
CONTROLLER_TOOLS_VERSION="v0.7.0"
KUSTOMIZE_VERSION="kustomize/v3.10.0"
GOPATH="${GOPATH:-}"

if [[ -z "${GOPATH}" ]]; then
GOPATH=~/go

if [[ -z "$GOPATH" ]]; then
GOPATH="$(go env GOPATH)"

if [[ -z "$GOPATH" ]]; then
echo "GOPATH is not set"
exit 1
fi
fi

# https://github.com/kubernetes/code-generator/blob/v0.18.0/generate-groups.sh
Expand Down

0 comments on commit 5c6b065

Please sign in to comment.