Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
2.3 kB · 68 lines
Shell
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869#!/usr/bin/env bash# Emit an ephemeral Maestro workspace config; never maintain a scenario list.# Optional arguments select flow files (relative to the repo, or absolute).set -euo pipefailexport LC_ALL=CREPO="$(cd "$(dirname "$0")/.." && pwd)"cd "$REPO/.maestro"shopt -s nullglob
logged_out=(logged-out/*.yaml)logged_in=()for file in logged-in/*.yaml; do # Opt-in topologies cannot run against the default single-node harness. if grep -q '^ - upstream-station$' "$file" && [ "${SP_E2E_UPSTREAM_STATION:-false}" != true ]; then continue fi logged_in+=("$file")doneif [ $# -gt 0 ]; then logged_out=() logged_in=() for file in "$@"; do file="${file#"$REPO/"}" file="${file#.maestro/}" [ -f "$file" ] || { echo "missing Maestro flow: $file" >&2; exit 1; } if grep -q '^ - upstream-station$' "$file" && [ "${SP_E2E_UPSTREAM_STATION:-false}" != true ]; then echo "upstream-station flow requires SP_E2E_UPSTREAM_STATION=true" >&2 exit 1 fi case "$file" in logged-out/*.yaml) logged_out+=("$file") ;; logged-in/*.yaml) logged_in+=("$file") ;; setup/server-setup.yaml) ;; setup/oauth-login.yaml) login=true ;; *) echo "select a flow in .maestro/{logged-out,logged-in,setup}: $file" >&2; exit 1 ;; esac donefi
# Subset argument order must not change the phase's reporting order.if [ ${#logged_out[@]} -gt 1 ]; then mapfile -t logged_out < <(printf '%s\n' "${logged_out[@]}" | sort)fiif [ ${#logged_in[@]} -gt 1 ]; then mapfile -t logged_in < <(printf '%s\n' "${logged_in[@]}" | sort)fi
flows=(setup/server-setup.yaml "${logged_out[@]}")if [ $# -eq 0 ] || [ ${#logged_in[@]} -gt 0 ] || [ "${login:-false}" = true ]; then flows+=(setup/oauth-login.yaml "${logged_in[@]}")fi
declare -A names=()for file in "${flows[@]}"; do name="${file##*/}" name="${name%.yaml}" [[ "$name" =~ ^[a-z0-9]+(-[a-z0-9]+)*$ ]] || { echo "use a lowercase kebab-case Maestro filename: $file" >&2; exit 1; } [ -z "${names[$name]:-}" ] || { echo "duplicate Maestro flow name: $name" >&2; exit 1; } names[$name]=1done
printf 'flows:\n'printf ' - "%s"\n' "${flows[@]}"printf 'executionOrder:\n continueOnFailure: false\n flowsOrder:\n'for file in "${flows[@]}"; do name="${file##*/}" printf ' - "%s"\n' "${name%.yaml}"done