...

Text file src/github.com/google/go-containerregistry/cmd/registry/test.sh

Documentation: github.com/google/go-containerregistry/cmd/registry

     1#!/bin/bash
     2set -ex
     3
     4CONTAINER_OS=$(docker info -f '{{ .OSType }}')
     5
     6# crane can run on a Windows system, but doesn't currently support pulling Windows
     7# containers, so this test can only run if Docker is in Linux container mode.
     8if [[ ${CONTAINER_OS} = "windows" ]]; then
     9    set +x
    10    echo [TEST SKIPPED] Windows containers are not yet supported by crane
    11    exit
    12fi
    13
    14function cleanup {
    15    [[ -n $PID ]] && kill $PID
    16    [[ -n $CTR ]] && docker stop $CTR
    17    rm -f ubuntu.tar debiand.tar debianc.tar
    18    docker rmi -f \
    19        localhost:1338/debianc:latest \
    20        localhost:1338/debiand:latest \
    21        localhost:1338/ubuntuc:foo \
    22        localhost:1338/ubuntud:latest \
    23        || true
    24}
    25trap cleanup EXIT
    26
    27case "$OSTYPE" in
    28    # On Windows, Docker runs in a VM, so a registry running on the Windows
    29    # host is not accessible via localhost for `docker pull|push`.
    30    win*|msys*|cygwin*)
    31        docker run -d --rm -p 1338:5000 --name test-reg registry:2
    32        CTR=test-reg
    33        ;;
    34
    35    *)
    36        registry &
    37        PID=$!
    38        ;;
    39esac
    40
    41go install ./cmd/registry
    42go install ./cmd/crane
    43
    44
    45crane pull debian:latest debianc.tar
    46crane push debianc.tar localhost:1338/debianc:latest
    47docker pull localhost:1338/debianc:latest
    48docker tag localhost:1338/debianc:latest localhost:1338/debiand:latest
    49docker push localhost:1338/debiand:latest
    50crane pull localhost:1338/debiand:latest debiand.tar
    51
    52docker pull ubuntu:latest
    53docker tag ubuntu:latest localhost:1338/ubuntud:latest
    54docker push localhost:1338/ubuntud:latest
    55crane pull localhost:1338/ubuntud:latest ubuntu.tar
    56crane push ubuntu.tar localhost:1338/ubuntuc:foo
    57docker pull localhost:1338/ubuntuc:foo

View as plain text