Vendor yq program
This commit is contained in:
parent
00c8a988e1
commit
3b59adfe34
41
abra
41
abra
@ -4,6 +4,8 @@ GIT_URL="https://git.autonomic.zone/coop-cloud/"
|
|||||||
ABRA_DIR="${ABRA_DIR:-$HOME/.abra}"
|
ABRA_DIR="${ABRA_DIR:-$HOME/.abra}"
|
||||||
ABRA_VERSION="0.5.0"
|
ABRA_VERSION="0.5.0"
|
||||||
ABRA_BACKUP_DIR="${ABRA_BACKUP_DIR:-$ABRA_DIR/backups}"
|
ABRA_BACKUP_DIR="${ABRA_BACKUP_DIR:-$ABRA_DIR/backups}"
|
||||||
|
ABRA_VENDOR_DIR="$ABRA_DIR/vendor"
|
||||||
|
YQ="$ABRA_VENDOR_DIR/yq"
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Global help
|
# Global help
|
||||||
@ -403,9 +405,9 @@ require_pwqgen() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
require_pwgen() {
|
require_wget() {
|
||||||
if ! type pwgen > /dev/null 2>&1; then
|
if ! type wget > /dev/null 2>&1; then
|
||||||
error "pwgen program is not installed"
|
error "wget program is not installed"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,6 +415,10 @@ require_abra_dir() {
|
|||||||
mkdir -p "$ABRA_DIR"
|
mkdir -p "$ABRA_DIR"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require_vendor_dir() {
|
||||||
|
mkdir -p "$ABRA_VENDOR_DIR"
|
||||||
|
}
|
||||||
|
|
||||||
require_app_latest() {
|
require_app_latest() {
|
||||||
APP="$1"
|
APP="$1"
|
||||||
APP_DIR="$ABRA_DIR/apps/$APP"
|
APP_DIR="$ABRA_DIR/apps/$APP"
|
||||||
@ -436,6 +442,32 @@ require_app_latest() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require_yq() {
|
||||||
|
require_vendor_dir
|
||||||
|
require_wget
|
||||||
|
|
||||||
|
YQ_VERSION="4.6.1"
|
||||||
|
YQ_BINARY="yq_linux_amd64"
|
||||||
|
YQ_RELEASE_URL="https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/${YQ_BINARY}"
|
||||||
|
|
||||||
|
if [ -f "$YQ" ]; then
|
||||||
|
debug "yq is already vendored"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
case $(uname -m) in
|
||||||
|
x86_64)
|
||||||
|
warning "Attempting to download the yq binary into $ABRA_VENDOR_DIR"
|
||||||
|
wget -q "$YQ_RELEASE_URL" && chmod +x "$YQ_BINARY" && mv "$YQ_BINARY" "$YQ"
|
||||||
|
success "yq is now vendored ☮"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "Unable to automatically vendor yq, you'll have to manually manage this\n
|
||||||
|
Please see https://mikefarah.gitbook.io/yq/#install and place the yq binary in the $YQ path"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# FIXME 3wc: update or remove
|
# FIXME 3wc: update or remove
|
||||||
if [ -z "$ABRA_ENV" ] && [ -f .env ] && type direnv > /dev/null 2>&1 && ! direnv status | grep -q 'Found RC allowed true'; then
|
if [ -z "$ABRA_ENV" ] && [ -f .env ] && type direnv > /dev/null 2>&1 && ! direnv status | grep -q 'Found RC allowed true'; then
|
||||||
error "direnv is blocked, run direnv allow"
|
error "direnv is blocked, run direnv allow"
|
||||||
@ -465,7 +497,7 @@ output_version_summary() {
|
|||||||
echo " Versions:"
|
echo " Versions:"
|
||||||
IFS=':' read -ra COMPOSE_FILES <<< "$COMPOSE_FILE"
|
IFS=':' read -ra COMPOSE_FILES <<< "$COMPOSE_FILE"
|
||||||
for COMPOSE in "${COMPOSE_FILES[@]}"; do
|
for COMPOSE in "${COMPOSE_FILES[@]}"; do
|
||||||
SERVICES=$(yq e '.services | keys | .[]' "${APP_DIR}/${COMPOSE_FILE}")
|
SERVICES=$($YQ e '.services | keys | .[]' "${APP_DIR}/${COMPOSE_FILE}")
|
||||||
for SERVICE in $SERVICES; do
|
for SERVICE in $SERVICES; do
|
||||||
filter="{{index .Spec.Labels \"coop-cloud.$STACK_NAME.$SERVICE.version\" }}"
|
filter="{{index .Spec.Labels \"coop-cloud.$STACK_NAME.$SERVICE.version\" }}"
|
||||||
label=$(docker service inspect -f "$filter" "${STACK_NAME}_${SERVICE}" 2>/dev/null)
|
label=$(docker service inspect -f "$filter" "${STACK_NAME}_${SERVICE}" 2>/dev/null)
|
||||||
@ -934,6 +966,7 @@ POWERED BY
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub_app_deploy (){
|
sub_app_deploy (){
|
||||||
|
require_yq
|
||||||
require_app_latest "$TYPE"
|
require_app_latest "$TYPE"
|
||||||
|
|
||||||
echo "About to deploy:"
|
echo "About to deploy:"
|
||||||
|
Loading…
Reference in New Issue
Block a user