...

Text file src/github.com/docker/cli/scripts/vendor

Documentation: github.com/docker/cli/scripts

     1#!/usr/bin/env bash
     2
     3set -eu
     4
     5TYP=$1
     6
     7usage() {
     8  echo "usage: ./scripts/vendor <init|update|validate|outdated>"
     9  exit 1
    10}
    11
    12if [ -z "$TYP" ]; then
    13  usage
    14fi
    15
    16init() {
    17  # create dummy go.mod, see comment in vendor.mod
    18  cat > go.mod <<EOL
    19module github.com/docker/cli
    20
    21go 1.19
    22EOL
    23}
    24
    25update() {
    26  (set -x ; go mod tidy -compat=1.19 -modfile=vendor.mod; go mod vendor -modfile=vendor.mod)
    27}
    28
    29validate() {
    30  diff=$(git status --porcelain -- vendor.mod vendor.sum vendor)
    31  if [ -n "$diff" ]; then
    32    echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make -f docker.Makefile vendor"'
    33    echo "$diff"
    34    exit 1
    35  fi
    36}
    37
    38outdated() {
    39  if [ ! -x "$(command -v go-mod-outdated)" ]; then
    40    echo "go-mod-outdated not found. Install with 'go install github.com/psampaz/go-mod-outdated@v0.8.0'"
    41    exit 1
    42  fi
    43  (set -x ; go list -mod=vendor -mod=readonly -modfile=vendor.mod -u -m -json all | go-mod-outdated -update -direct)
    44}
    45
    46case $TYP in
    47  "init")
    48    init
    49    ;;
    50  "update")
    51    init
    52    update
    53    ;;
    54  "validate")
    55    init
    56    update
    57    validate
    58    ;;
    59  "outdated")
    60    init
    61    outdated
    62    ;;
    63  *)
    64    echo >&2 "Unknown type $TYP"
    65    exit 1
    66    ;;
    67esac

View as plain text