From a9006e017ee00a0485fa6fb80feb1f7f19735dd2 Mon Sep 17 00:00:00 2001 From: Fiachra Corcoran Date: Mon, 25 Mar 2024 14:07:48 +0000 Subject: [PATCH] Clean up code gen scripts --- go.mod | 2 +- scripts/_env | 12 ------------ scripts/_functions | 21 --------------------- scripts/_trap | 13 ++++++++++--- scripts/generate-api.sh | 14 ++++++++------ 5 files changed, 19 insertions(+), 43 deletions(-) delete mode 100644 scripts/_env delete mode 100644 scripts/_functions diff --git a/go.mod b/go.mod index 377c6a83..8edc0e23 100644 --- a/go.mod +++ b/go.mod @@ -58,7 +58,6 @@ require ( k8s.io/component-base v0.29.2 k8s.io/klog/v2 v2.120.1 k8s.io/kube-aggregator v0.29.2 - k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 k8s.io/kubectl v0.29.2 k8s.io/utils v0.0.0-20230726121419-3b25d923346b sigs.k8s.io/cli-utils v0.35.0 @@ -189,6 +188,7 @@ require ( gopkg.in/warnings.v0 v0.1.2 // indirect k8s.io/apiextensions-apiserver v0.29.0 // indirect k8s.io/kms v0.29.2 // indirect + k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect diff --git a/scripts/_env b/scripts/_env deleted file mode 100644 index d05522fa..00000000 --- a/scripts/_env +++ /dev/null @@ -1,12 +0,0 @@ -_HERE=$(dirname "$(readlink --canonicalize "$BASH_SOURCE")") - -. "$_HERE/_functions" - -MODULE=github.com/nephio-project/porch/api - -ROOT=$(readlink --canonicalize "$_HERE/..") - -# GOPATH=${GOPATH:-$HOME/go} -# export PATH=$GOPATH/bin:$ROOT:$PATH - -KUBERNETES_VERSION=0.29.2 \ No newline at end of file diff --git a/scripts/_functions b/scripts/_functions deleted file mode 100644 index 1c500f05..00000000 --- a/scripts/_functions +++ /dev/null @@ -1,21 +0,0 @@ - -RED='\033[0;31m' -GREEN='\033[0;32m' -BLUE='\033[0;34m' -CYAN='\033[0;36m' -RESET='\033[0m' - -# Colored messages (blue is the default) -# Examples: -# m "hello world" -# m "hello world" "$GREEN" -function m () { - local COLOR=${2:-$BLUE} - echo -e "$COLOR$1$RESET" -} - -function copy_function () { - local ORIG_FUNC=$(declare -f $1) - local NEWNAME_FUNC="$2${ORIG_FUNC#$1}" - eval "$NEWNAME_FUNC" -} diff --git a/scripts/_trap b/scripts/_trap index 4818bf6a..3f2a719a 100644 --- a/scripts/_trap +++ b/scripts/_trap @@ -4,14 +4,21 @@ function goodbye () { local CODE=$1 cd "$TRAP_DIR" if [ "$CODE" == 0 ]; then - m "$(realpath --relative-to="$ROOT" "$0") succeeded! $DURATION" "$GREEN" + echo "$(realpath --relative-to="$ROOT" "$0") succeeded! $DURATION" elif [ "$CODE" == abort ]; then - m "Aborted $(realpath --relative-to="$ROOT" "$0")! $DURATION" "$RED" + echo "Aborted $(realpath --relative-to="$ROOT" "$0")! $DURATION" else - m "Oh no! $(realpath --relative-to="$ROOT" "$0") failed! $DURATION" "$RED" + echo "Oh no! $(realpath --relative-to="$ROOT" "$0") failed! $DURATION" fi } + +function copy_function () { + local ORIG_FUNC=$(declare -f $1) + local NEWNAME_FUNC="$2${ORIG_FUNC#$1}" + eval "$NEWNAME_FUNC" +} + function trap_EXIT () { local ERR=$? goodbye "$ERR" diff --git a/scripts/generate-api.sh b/scripts/generate-api.sh index 04b0be44..5c5897df 100755 --- a/scripts/generate-api.sh +++ b/scripts/generate-api.sh @@ -2,9 +2,10 @@ set -e HERE=$(dirname "$(readlink --canonicalize "$BASH_SOURCE")") -. "$HERE/_env" . "$HERE/_trap" +ROOT=$(readlink --canonicalize "$HERE/..") + ORG=github.com/nephio-project REPO=$ORG/porch API_PKG=$REPO/api @@ -14,6 +15,7 @@ CLIENT_PKG=$API_PKG/generated BOILERPLATE=$HERE/boilerplate.go.txt OPENAPI_REPORT=$ROOT/gen_openapi.report +KUBERNETES_VERSION=0.29.2 go get -d "k8s.io/code-generator@v$KUBERNETES_VERSION" CODE_GENERATOR=$(go list -f '{{.Dir}}' -m "k8s.io/code-generator@v$KUBERNETES_VERSION") # . "${CODE_GENERATOR}/kube_codegen.sh" @@ -23,11 +25,11 @@ CODE_GENERATOR=$(go list -f '{{.Dir}}' -m "k8s.io/code-generator@v$KUBERNETES_VE WORK=$(mktemp --directory) -m "work directory: $WORK" +echo "work directory: $WORK" copy_function goodbye old_goodbye function goodbye () { - m "deleting work directory: $WORK" + echo "deleting work directory: $WORK" rm --recursive "$WORK" old_goodbye $1 } @@ -35,7 +37,7 @@ function goodbye () { mkdir --parents "$WORK/$ORG" ln --symbolic "$ROOT" "$WORK/$REPO" -m 'gen_helpers...' +echo 'gen_helpers...' kube::codegen::gen_helpers \ --output-base "$WORK" \ @@ -45,7 +47,7 @@ kube::codegen::gen_helpers \ --extra-peer-dir "k8s.io/apimachinery/pkg/runtime" \ --extra-peer-dir "k8s.io/apimachinery/pkg/version" -m 'gen_openapi...' +echo 'gen_openapi...' rm --recursive --force "$CLIENT_PKG/openapi" @@ -58,7 +60,7 @@ kube::codegen::gen_openapi \ --report-filename "$OPENAPI_REPORT" \ --update-report -m 'gen_client...' +echo 'gen_client...' #rm --recursive --force "$ROOT/api/kubernetes-client"