#!/usr/bin/env bash
set -euo pipefail

script_dir="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
root_dir="$(builtin cd "$script_dir/../../../.." && pwd)"

image=backfill_vehicle_config_image

function tag_list_url() {
  echo https://docker-registry.zooxlabs.com/v2/data/ingest/docker_images/$1/tags/list
}

current="$(
  curl --silent "$(tag_list_url "$image")" |
  jq '.tags | map(tonumber) | max' --monochrome-output 2>/dev/null
)"

next=$(($current + 1))

"$root_dir/data/ingest/docker_images/build_and_push_ingest_job.sh" \
  "$image" prod "$next"
