Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

sonobuoy: add custom update script

+56 -1
+6 -1
pkgs/applications/networking/cluster/sonobuoy/default.nix
··· 1 1 { lib, buildGoModule, fetchFromGitHub }: 2 2 3 3 # SHA of ${version} for the tool's help output. Unfortunately this is needed in build flags. 4 - let rev = "6f9e27f1795f10475c9f6f5decdff692e1e228da"; 4 + # The update script can update this automatically, the comment is used to find the line. 5 + let rev = "6f9e27f1795f10475c9f6f5decdff692e1e228da"; # update-commit-sha 5 6 in 6 7 buildGoModule rec { 7 8 pname = "sonobuoy"; ··· 26 27 vendorHash = "sha256-HE53eIEyhOI9ksEx1EKmv/txaTa7KDrNUMEVRMi4Wuo="; 27 28 28 29 subPackages = [ "." ]; 30 + 31 + passthru = { 32 + updateScript = ./update.sh; 33 + }; 29 34 30 35 meta = with lib; { 31 36 description = "Diagnostic tool that makes it easier to understand the state of a Kubernetes cluster";
+50
pkgs/applications/networking/cluster/sonobuoy/update.sh
··· 1 + #!/usr/bin/env nix-shell 2 + #!nix-shell -i bash -p nix-update curl jq gnused 3 + 4 + set -euo pipefail 5 + 6 + # Do the actual update. 7 + nix-update "${UPDATE_NIX_ATTR_PATH}" 8 + 9 + # Get the src metadata. 10 + src=$( 11 + nix-instantiate --json --eval --strict --expr ' 12 + with import ./. {}; 13 + { 14 + owner = '"${UPDATE_NIX_ATTR_PATH}"'.src.owner; 15 + repo = '"${UPDATE_NIX_ATTR_PATH}"'.src.repo; 16 + tag = '"${UPDATE_NIX_ATTR_PATH}"'.src.rev; 17 + }' 18 + ) 19 + owner=$(jq -r '.owner' <<< "${src}") 20 + repo=$(jq -r '.repo' <<< "${src}") 21 + tag=$(jq -r '.tag' <<< "${src}") 22 + 23 + # Curl the release to get the commit sha. 24 + curlFlags=("-fsSL") 25 + curlFlags+=(${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"}) 26 + 27 + read -r type tag_sha < <( 28 + curl "${curlFlags[@]}" "https://api.github.com/repos/${owner}/${repo}/git/ref/tags/${tag}" | 29 + jq -j '.object.type, " ", .object.sha, "\n"' 30 + ) 31 + 32 + if [[ "${type}" == "commit" ]]; then 33 + sha="${tag_sha}" 34 + else 35 + sha=$( 36 + curl "${curlFlags[@]}" "https://api.github.com/repos/${owner}/${repo}/git/tags/${tag_sha}" | 37 + jq '.object.sha' 38 + ) 39 + fi 40 + 41 + if [[ -z "${sha}" ]]; then 42 + echo "failed to get commit sha of ${owner}/${repo} @ ${tag}" >&2 43 + exit 1 44 + fi 45 + 46 + echo "updating commit hash of ${owner}/${repo} @ ${tag} to ${sha}" >&2 47 + 48 + cd "$(dirname "$(readlink -f "$0")")" 49 + 50 + sed -i "s|\".*\"; # update-commit-sha|${sha}; # update-commit-sha|" default.nix