github.com/cilium/cilium@v1.16.2/images/scripts/update-cni-version.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # Copyright Authors of Cilium
     4  # SPDX-License-Identifier: Apache-2.0
     5  
     6  set -o errexit
     7  set -o pipefail
     8  set -o nounset
     9  
    10  root_dir="$(git rev-parse --show-toplevel)"
    11  
    12  cd "${root_dir}"
    13  
    14  if [ "$#" -ne 1 ] ; then
    15    echo "$0 supports exactly 1 argument - <cni_version>"
    16    exit 1
    17  fi
    18  
    19  cni_version="${1}"
    20  
    21  # this is a simple array that assumes the order of the loop;
    22  # it's not an associative array because this script needs to
    23  # work on any version of bash, and (most notably) macOS ships
    24  # an old version that doesn't support associative arrays
    25  cni_sha512=()
    26  
    27  for arch in amd64 arm64 ; do
    28    tmpout="$(mktemp)"
    29    curl --fail --show-error --silent --location \
    30      "https://github.com/containernetworking/plugins/releases/download/v${cni_version}/cni-plugins-linux-${arch}-v${cni_version}.tgz.sha512" \
    31      --output "${tmpout}"
    32    read -ra sha512 < "${tmpout}"
    33    rm -f "${tmpout}"
    34    cni_sha512+=("${sha512[0]}")
    35  done
    36  
    37  cat > "${root_dir}/images/runtime/cni-version.sh" << EOF
    38  # Code generated by images/scripts/update-cni-version.sh; DO NOT EDIT.
    39  cni_version="${cni_version}"
    40  declare -A cni_sha512
    41  cni_sha512[amd64]="${cni_sha512[0]}"
    42  cni_sha512[arm64]="${cni_sha512[1]}"
    43  EOF