#!/usr/bin/env bash # Copyright (c) HashiCorp, Inc. # SPDX-License-Identifier: MPL-2.0 set -e help() { cat < /dev/null run_tests() { run bash script.sh $@ } run_shell() { run bash $@ } run() { exec docker run -it --rm \ -v $(pwd):/src \ -w /src \ -e NOMAD_ADDR=$NOMAD_ADDR \ -e NOMAD_TOKEN=$NOMAD_TOKEN \ --ipc=host \ --net=host \ "$IMAGE" \ $@ } run_proxy() { nomad namespace apply proxy nomad job run "./input/proxy.nomad" IP=$(nomad node status -json -verbose \ $(nomad operator api '/v1/allocations?namespace=proxy' | jq -r '.[] | select(.JobID == "nomad-proxy") | .NodeID') \ | jq -r '.Attributes."unique.platform.aws.public-ipv4"') echo "NOMAD_ADDR=https://$IP:6464" exit 0 } opt="$1" case $opt in help|--help|-h) help ;; proxy|--proxy) run_proxy ;; test|--test) shift ; run_tests "$@" ;; shell) shift ; run_shell ;; *) run_tests "$@" ;; esac run_tests