Skip to content
quarry Artifact [c8a6838111]
Login

Artifact [c8a6838111]

Artifact c8a68381113da0dff33c6c4462c3c6d33bb0f3202155ded879c168a27c20ef55:


#!/bin/sh
# quarry-land — accept a landing THROUGH THE FORGE, so the gates apply.
#
# A stock zit client can accept against the shared store directly, and
# nothing will stop it — required checks, override-with-reason and
# supersede all live in the forge's one write path, not the store's.
# This script makes the gated path the easy path.
#
# usage: quarry-land <repo> <landing-id-or-prefix>            accept now
#        quarry-land <repo> <landing-id-or-prefix> --when-green  arm auto-land
#
# environment: QUARRY_URL (default http://127.0.0.1:8950),
#              QUARRY_USER, QUARRY_PASSWORD (or a ~/.netrc entry).
set -e
REPO=$1; LANDING=$2; MODE=${3:-now}
if [ -z "$REPO" ] || [ -z "$LANDING" ]; then
  echo "usage: quarry-land <repo> <landing> [--when-green]" >&2; exit 2
fi
URL=${QUARRY_URL:-http://127.0.0.1:8950}
AUTH=""
if [ -n "$QUARRY_USER" ]; then AUTH="-u $QUARRY_USER:$QUARRY_PASSWORD"; else AUTH="-n"; fi
if [ "$MODE" = "--when-green" ]; then
  # Arm auto-land: the record accepts itself once every required check
  # on its target is green; protection re-applies when it fires.
  curl -sS $AUTH -X POST -d "on=true" "$URL/api/v1/r/$REPO/landing/$LANDING/auto" >/dev/null \
    && echo "armed: $LANDING lands itself when its checks go green"
else
  curl -sS $AUTH -X POST "$URL/api/v1/r/$REPO/landing/$LANDING/accept"
fi