Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 26 lines (19 sloc) 693 Bytes
#!/usr/bin/env bash
set -euo pipefail
if [[ ! -z ${VERBOSE+x} ]]; then
set -x
fi
SERVICE="$1"
SERVICE_MANIFEST="$SERVICE/marathon.json"
# Marathon automatically prefixes service names with a /. We use the slash-less version in the manifest.
SERVICE_ID="/$(jq -r '.id' "$SERVICE_MANIFEST")"
# This returns true if the service currently exists in Marathon (e.g. needs to be updated instead of created)
service_exists() {
local service_id="$1"
dcos marathon app list --json | jq -r '.[].id' | grep -Eq "^$service_id$"
}
if service_exists "$SERVICE_ID"; then
dcos marathon app update "$SERVICE_ID" < "$SERVICE_MANIFEST" --force
else
dcos marathon app add < "$SERVICE_MANIFEST"
fi