#!/usr/bin/env bash
# fake juju for the phase-05 verify harness.
#   status ...        -> $FIX_JUJU_STATUS (octavia status JSON)
#   config <app> <key> -> env-driven value (CFG_* with sane defaults)
#   exec ... o-hm0    -> $OHM0_OUT (the 'ip -br addr show o-hm0' line)
sub="${1:-}"
case "$sub" in
  status) cat "${FIX_JUJU_STATUS:?FIX_JUJU_STATUS not set}" ;;
  config)
    app="${2:-}"; key="${3:-}"
    case "$app/$key" in
      octavia-diskimage-retrofit/use-internal-endpoints) printf '%s\n' "${CFG_UIE:-true}" ;;
      octavia-diskimage-retrofit/image-format)           printf '%s\n' "${CFG_IMGFMT:-raw}" ;;
      octavia-diskimage-retrofit/amp-image-tag)          printf '%s\n' "${CFG_RTAG:-octavia-amphora}" ;;
      octavia/amp-image-tag)                             printf '%s\n' "${CFG_OTAG:-octavia-amphora}" ;;
    esac ;;
  exec) printf '%s\n' "${OHM0_OUT:-}" ;;
esac
