|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Move to parent folder |
| 4 | +SOURCE="${BASH_SOURCE[0]}" |
| 5 | +while [ -h "${SOURCE}" ]; do # resolve $SOURCE until the file is no longer a symlink |
| 6 | + readonly BIN_DIR="$(cd -P "$(dirname "$SOURCE}")" && pwd)" |
| 7 | + SOURCE="$(readlink "${SOURCE}")" |
| 8 | + [[ ${SOURCE} != /* ]] && SOURCE="${BIN_DIR}/${SOURCE}" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located |
| 9 | +done |
| 10 | +readonly DIR="$(cd -P "$(dirname "${SOURCE}")" && pwd)" |
| 11 | +# Move to this directory's parent |
| 12 | +cd "${DIR}/.." |
| 13 | + |
| 14 | +if ! RES=$(kubectl deprecations --input-file Pod/simple.yaml 2>&1) |
| 15 | +then |
| 16 | + echo '`kubectl deprecations` did not run ok. You may need to install the krew 'deprecations' package. See https://krew.sigs.k8s.io/' |
| 17 | + echo 'OUTPUT:' |
| 18 | + echo "${RES}" |
| 19 | + exit 1 |
| 20 | +fi |
| 21 | + |
| 22 | +if [[ $# -eq 0 ]] |
| 23 | +then |
| 24 | + while IFS= read -r line |
| 25 | + do |
| 26 | + echo "================================================================================" |
| 27 | + echo "Looking at k8s version: ${line}" |
| 28 | + echo "================================================================================" |
| 29 | + echo |
| 30 | + for f in $(find . -type f -name "*.yaml") |
| 31 | + do |
| 32 | + echo -n "${f} " |
| 33 | + if RES=$(kubectl deprecations --error-on-deleted --error-on-deprecated --k8s-version="$line" --input-file "${f}" 2>&1) |
| 34 | + then |
| 35 | + echo '....OK' |
| 36 | + else |
| 37 | + echo |
| 38 | + echo "================================================================================" |
| 39 | + echo "Problem with file: ${f} on k8s version ${line}" |
| 40 | + echo "================================================================================" |
| 41 | + echo "Output was: ${RES}" |
| 42 | + echo "================================================================================" |
| 43 | + echo |
| 44 | + echo "Checking files... " |
| 45 | + fi |
| 46 | + done |
| 47 | + done < .supported-k8s-versions |
| 48 | +else |
| 49 | + find . -type f -name "*.yaml" -exec echo {} \; -exec kubectl deprecations --error-on-deleted --error-on-deprecated --k8s-version="v$1" --input-file {} \; |
| 50 | +fi |
0 commit comments