GitLab YAML Docker Registry client

Have you written a Docker Registry API client in GitLab CI/CD YAML? I have.

# Delete candidate image from CI repository.
  stage: .post
    - main

    AUTH_API: "$CI_SERVER_URL/jwt/auth"
    SCOPE: "repository:$CI_PROJECT_PATH"

    - >
      which jq >/dev/null
      || (sudo apt-get update
      && sudo apt-get -y install jq)

    - echo "Deleting $CANDIDATE_IMAGE"
    - >
      TOKEN=$(curl -s
      | jq -r .token)
    - >
      DIGEST=$(curl -s -I
      -H "Authorization: Bearer $TOKEN"
      -H "Accept: application/vnd.docker.distribution.manifest.v2+json"
      | tr -d "\r"
      | grep -i "^docker-content-digest: "
      | sed "s/^[^:]*: *//")
    - >
      curl -s
      -X DELETE
      -H "Authorization: Bearer $TOKEN"
      "$REGISTRY_API/manifests/"$(echo $DIGEST | sed "s/:/%3A/g")

Use stdbuf to tee without buffering

Do you want to tee the output of a command to a file, but see it in your terminal too, without buffering? The stdbuf command can do this for you:

$ sudo stdbuf --output=L tcpdump -i any -tttt -n 'udp port 5353' | tee -a tcpdump-mdns
tcpdump: data link type LINUX_SLL2
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
2023-06-15 11:55:16.637670 eth0 M   IP > 0 A (QM)? winnebago.local. (28)
2023-06-15 11:55:16.744660 eth0 M   IP > 0*- [0q] 1/0/0 (Cache flush) A (38)