github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/test/apiv2/12-imagesMore.at (about)

     1  # -*- sh -*-
     2  #
     3  # Tests for more image-related endpoints
     4  #
     5  
     6  red='\e[31m'
     7  nc='\e[0m'
     8  
     9  start_registry
    10  
    11  podman pull -q $IMAGE
    12  
    13  t GET libpod/images/json 200 \
    14    .[0].Id~[0-9a-f]\\{64\\}
    15  iid=$(jq -r '.[0].Id' <<<"$output")
    16  
    17  # Retrieve the image tree
    18  t GET libpod/images/$IMAGE/tree 200 \
    19    .Tree~^Image
    20  
    21  # Tag nonesuch image
    22  t POST "libpod/images/nonesuch/tag?repo=myrepo&tag=mytag" 404
    23  
    24  # Tag the image
    25  t POST "libpod/images/$IMAGE/tag?repo=localhost:$REGISTRY_PORT/myrepo&tag=mytag" 201
    26  
    27  t GET libpod/images/$IMAGE/json 200 \
    28    .RepoTags[1]=localhost:$REGISTRY_PORT/myrepo:mytag
    29  
    30  # Push to local registry and check output
    31  while read -r LINE
    32  do
    33    if echo "${LINE}" | jq --exit-status 'select( .status != null) | select ( .status | contains("digest: sha256:"))' &>/dev/null; then
    34      GOT_DIGEST="1"
    35    fi
    36  done < <(curl -sL "http://$HOST:$PORT/images/localhost:$REGISTRY_PORT/myrepo/push?tlsVerify=false&tag=mytag" -XPOST -H "X-Registry-Config: $REGISTRY_CONFIG_HEADER")
    37  if [ -z "${GOT_DIGEST}" ] ; then
    38    echo -e "${red}not ok: did not found digest in output${nc}"  1>&2;
    39  fi
    40  
    41  # Push to local registry
    42  t POST "images/localhost:$REGISTRY_PORT/myrepo/push?tlsVerify=false&tag=mytag" 200
    43  
    44  # Untag the image
    45  t POST "libpod/images/$iid/untag?repo=localhost:$REGISTRY_PORT/myrepo&tag=mytag" 201
    46  
    47  # Try to push non-existing image
    48  t POST "images/localhost:$REGISTRY_PORT/idonotexist/push?tlsVerify=false" 404
    49  
    50  t GET libpod/images/$IMAGE/json 200 \
    51    .RepoTags[-1]=$IMAGE
    52  
    53  # Remove image
    54  t DELETE libpod/images/$IMAGE 200 \
    55    .ExitCode=0