#!/bin/sh set -eu : "${FAKE_DOCKER_LOG:?}" : "${FAKE_DB_STATE:?}" printf '%s\n' "$*" >> "$FAKE_DOCKER_LOG" if [ "${1:-}" = compose ]; then shift args=$* case "$args" in *' version'*) exit 0 ;; *' ps -q postgres'*) printf 'fake-postgres\n'; exit 0 ;; *' ps -q control-proxy'*) printf 'fake-control-proxy\n'; exit 0 ;; *' exec '*product_e*) if [ "$(cat "$FAKE_DB_STATE")" = mismatch ]; then printf 'FATAL: password authentication failed for user product_e\n' >&2 exit 2 fi if [ "$(cat "$FAKE_DB_STATE")" = reset-once ]; then printf 'FATAL: password authentication failed for user product_e\n' >&2 exit 2 fi if [ "$(cat "$FAKE_DB_STATE")" = wrong-role ]; then printf 'product_s\n' exit 0 fi printf 'product_e\n'; exit 0 ;; *' exec '*product_s*) if [ "$(cat "$FAKE_DB_STATE")" = wrong-role ]; then printf 'product_e\n' exit 0 fi if [ "$(cat "$FAKE_DB_STATE")" = s-mismatch ]; then printf 'FATAL: password authentication failed for user product_s\n' >&2 exit 2 fi printf 'product_s\n'; exit 0 ;; *) exit 0 ;; esac fi case "${1:-}" in network|pull|image) exit 0 ;; save) output='' previous='' for argument do if [ "$previous" = -o ]; then output=$argument; fi previous=$argument done [ -n "$output" ] && : > "$output" exit 0 ;; inspect) format=${3:-} case "$format" in *State.Health.Status*) printf 'healthy\n' ;; *var/lib/postgresql/data*) printf 'fake-e-postgres\n' ;; *) printf '\n' ;; esac exit 0 ;; volume) case "${2:-}" in inspect) case "${4:-}" in *com.docker.compose.project*) printf 'overcooked-e\n' ;; *com.docker.compose.volume*) printf 'e-postgres\n' ;; esac exit 0 ;; rm) printf 'ok\n' > "$FAKE_DB_STATE" exit 0 ;; esac ;; esac exit 0