#!/usr/bin/env bash

set -x

image="$(cat Dockerfile.rhel7 | grep -m 1 '^FROM' | awk '{print $2;}')"
go_module="$(go list -m)"
cp Makefile Makefile.backup
trap 'mv Makefile.backup Makefile' EXIT
sed -i 's/ASSETS go test/ASSETS go test -count=1 -failfast/g' Makefile
commit="$(git rev-parse --short HEAD)"
set -o pipefail
podman run -it --rm -v "$PWD:/go/src/$go_module" -w "/go/src/$go_module" "$image" make bootstrap-e2e 2>&1 | tee "e2e-bootstrap-$commit.log"
