Skip to content

Instantly share code, notes, and snippets.

@gregwebs
Created November 17, 2019 01:16
Show Gist options
  • Save gregwebs/0fe911ac02d06bf65c66b88c4293b85e to your computer and use it in GitHub Desktop.
Save gregwebs/0fe911ac02d06bf65c66b88c4293b85e to your computer and use it in GitHub Desktop.
cue installer/runner
#!/usr/bin/env bash
set -euo pipefail
CUE_VERSION=${CUE_VERSION:-"0.0.14"}
export PATH="./bin:$PATH"
function extract() {
set -x
if ! [[ -f bin/"cue-${CUE_VERSION}" ]] ; then
mkdir -p download
pushd download
# avoid re-downloading for now if there is a mistake here in shell code
if ! test -f cue_${CUE_VERSION}_${1}.tar.gz ; then
wget "https://github.com/cuelang/cue/releases/download/v${CUE_VERSION}/cue_${CUE_VERSION}_${1}.tar.gz"
fi
gunzip cue_${CUE_VERSION}_${1}.tar.gz
tar -xvf cue_${CUE_VERSION}_${1}.tar
mkdir -p ../bin
mv cue ../bin/cue-${CUE_VERSION}
popd
rm -r download
fi
pushd bin
rm -f cue
ln -s "cue-${CUE_VERSION}" cue
popd
set +x
}
{
if ! command -v cue >/dev/null || ! [[ $(cue version | awk '{print $3}') == $CUE_VERSION ]] >/dev/null ; then
if [[ $(uname) == Linux ]] ; then
extract Linux_x86_64
else
extract Darwin_x86_64
fi
fi
# install libraries
libs=( k8s.io/api/core/v1 k8s.io/api/apps/v1 k8s.io/api/batch/v1 )
for lib in ${libs[@]} ; do
if ! test -f pkg/$lib/types_go_gen.cue ; then
echo "downloading $lib to ./pkg" >&2
GO111MODULE=on ./bin/cue get go "$lib"
fi
done
} >/dev/null
exec ./bin/cue "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment