#!/usr/bin/env bash # refuse-lab-binary.sh BIN...: refuse to publish a lab build. Each BIN must # answer -version, and its answer must not carry the lab marker # (internal/buildinfo LabMarker, set by the swblock_lab_bigvol tag). A binary # that cannot answer is refused too (fail closed). Run by every image # Dockerfile right after its go build, so no image holding a lab binary is # built, and so none is pushed. set -euo pipefail [ "$#" -gt 0 ] || { echo "refuse-lab-binary: no binary given" >&2; exit 2; } for bin in "$@"; do out=$("$bin" -version 2>&1) || { echo "refuse-lab-binary: $bin -version failed: $out" >&2; exit 1; } [ -n "$out" ] || { echo "refuse-lab-binary: $bin -version printed nothing" >&2; exit 1; } case "$out" in *"LAB BUILD"*) echo "refuse-lab-binary: $bin is a lab build ($out); not published" >&2; exit 1 ;; esac echo "refuse-lab-binary: $bin ok: $out" done