diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-02 01:00:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-02 01:00:06 +0200 |
commit | a8cde905d5069d3916c56fa53a021d64a814ee48 (patch) | |
tree | f909d19cf229d04cdc2ac6a61fa717f83142061a /hack/podmanv2-retry | |
parent | 79f191cb5933ac0d3f64d123d8b8e6fec8e2a9c9 (diff) | |
parent | 108ab380f10066516e8fb4c82f0f02fdf480b003 (diff) | |
download | podman-a8cde905d5069d3916c56fa53a021d64a814ee48.tar.gz podman-a8cde905d5069d3916c56fa53a021d64a814ee48.tar.bz2 podman-a8cde905d5069d3916c56fa53a021d64a814ee48.zip |
Merge pull request #5699 from edsantiago/podmanv2-retry
podmanv2-retry - new helper for testing v2
Diffstat (limited to 'hack/podmanv2-retry')
-rwxr-xr-x | hack/podmanv2-retry | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/hack/podmanv2-retry b/hack/podmanv2-retry new file mode 100755 index 000000000..ea77486ff --- /dev/null +++ b/hack/podmanv2-retry @@ -0,0 +1,37 @@ +#!/bin/bash +# +# podman-try - try running a command via PODMAN1; use PODMAN2 as fallback +# +# Intended for use with a podmanv2 client. If a command isn't yet +# implemented, fall back to regular podman: +# +# Set PODMAN_V2 to the path to a podman v2 client +# Set PODMAN_FALLBACK to the path to regular podman +# +# THIS IS IMPERFECT. In particular, it will not work if stdin is redirected +# (e.g. 'podman ... < file' or 'something | podman'); nor for anything +# that generates continuous output ('podman logs -f'); and probably more +# situations. +# + +die() { + echo "$(basename $0): $*" >&2 + exit 1 +} + +test -n "$PODMAN_V2" || die "Please set \$PODMAN_V2 (path to podman v2)" +test -n "$PODMAN_FALLBACK" || die "Please set \$PODMAN_FALLBACK (path to podman)" + + +result=$(${PODMAN_V2} "$@" 2>&1) +rc=$? + +if [ $rc == 125 ]; then + if [[ "$result" =~ unrecognized\ command|unknown\ flag|unknown\ shorthand ]]; then + result=$(${PODMAN_FALLBACK} "$@") + rc=$? + fi +fi + +echo -n "$result" +exit $rc |