From f6e0602096d78336dbd218878b5b98aaca005b20 Mon Sep 17 00:00:00 2001 From: superherointj <5861043+superherointj@users.noreply.github.com> Date: Thu, 30 Sep 2021 21:40:47 -0300 Subject: [PATCH] linkerd: add updateScript --- .../networking/cluster/linkerd/default.nix | 77 ++----------------- .../networking/cluster/linkerd/edge.nix | 8 ++ .../networking/cluster/linkerd/generic.nix | 59 ++++++++++++++ .../networking/cluster/linkerd/update-edge.sh | 35 +++++++++ .../cluster/linkerd/update-stable.sh | 35 +++++++++ pkgs/top-level/all-packages.nix | 6 +- 6 files changed, 147 insertions(+), 73 deletions(-) create mode 100644 pkgs/applications/networking/cluster/linkerd/edge.nix create mode 100644 pkgs/applications/networking/cluster/linkerd/generic.nix create mode 100755 pkgs/applications/networking/cluster/linkerd/update-edge.sh create mode 100755 pkgs/applications/networking/cluster/linkerd/update-stable.sh diff --git a/pkgs/applications/networking/cluster/linkerd/default.nix b/pkgs/applications/networking/cluster/linkerd/default.nix index 6d5d5d1bd4a3..ac85ef8a6a33 100644 --- a/pkgs/applications/networking/cluster/linkerd/default.nix +++ b/pkgs/applications/networking/cluster/linkerd/default.nix @@ -1,71 +1,8 @@ -{ lib, fetchFromGitHub, buildGoModule, installShellFiles }: +{ callPackage }: -let generic = { channel, version, sha256, vendorSha256 }: - buildGoModule rec { - pname = "linkerd-${channel}"; - inherit version vendorSha256; - - src = fetchFromGitHub { - owner = "linkerd"; - repo = "linkerd2"; - rev = "${channel}-${version}"; - inherit sha256; - }; - - subPackages = [ "cli" ]; - runVend = true; - - preBuild = '' - env GOFLAGS="" go generate ./pkg/charts/static - env GOFLAGS="" go generate ./jaeger/static - env GOFLAGS="" go generate ./multicluster/static - env GOFLAGS="" go generate ./viz/static - ''; - - tags = [ - "prod" - ]; - - ldflags = [ - "-s" "-w" - "-X github.com/linkerd/linkerd2/pkg/version.Version=${src.rev}" - ]; - - nativeBuildInputs = [ installShellFiles ]; - - postInstall = '' - mv $out/bin/cli $out/bin/linkerd - installShellCompletion --cmd linkerd \ - --bash <($out/bin/linkerd completion bash) \ - --zsh <($out/bin/linkerd completion zsh) \ - --fish <($out/bin/linkerd completion fish) - ''; - - doInstallCheck = true; - installCheckPhase = '' - $out/bin/linkerd version --client | grep ${src.rev} > /dev/null - ''; - - meta = with lib; { - description = "A simple Kubernetes service mesh that improves security, observability and reliability"; - downloadPage = "https://github.com/linkerd/linkerd2/"; - homepage = "https://linkerd.io/"; - license = licenses.asl20; - maintainers = with maintainers; [ Gonzih bryanasdev000 superherointj ]; - }; - }; -in - { - stable = generic { - channel = "stable"; - version = "2.10.2"; - sha256 = "sha256-dOD0S4FJ2lXE+1VZooi8tKvC8ndGEHAxmAvSqoWI/m0="; - vendorSha256 = "sha256-Qb0FZOvKL9GgncfUl538PynkYbm3V8Q6lUpApUoIp5s="; - }; - edge = generic { - channel = "edge"; - version = "21.9.3"; - sha256 = "0swqx4myvr24visj39icg8g90kj325pvf22bq447rnm0whq3cnyz"; - vendorSha256 = "sha256-fMtAR66TwMNR/HCVQ9Jg3sJ0XBx2jUKDG7/ts0lEZM4="; - }; - } +(callPackage ./generic.nix { }) { + channel = "stable"; + version = "2.10.2"; + sha256 = "sha256-dOD0S4FJ2lXE+1VZooi8tKvC8ndGEHAxmAvSqoWI/m0="; + vendorSha256 = "sha256-Qb0FZOvKL9GgncfUl538PynkYbm3V8Q6lUpApUoIp5s="; +} diff --git a/pkgs/applications/networking/cluster/linkerd/edge.nix b/pkgs/applications/networking/cluster/linkerd/edge.nix new file mode 100644 index 000000000000..8f2b9cda0b9d --- /dev/null +++ b/pkgs/applications/networking/cluster/linkerd/edge.nix @@ -0,0 +1,8 @@ +{ callPackage }: + +(callPackage ./generic.nix { }) { + channel = "edge"; + version = "21.9.3"; + sha256 = "0swqx4myvr24visj39icg8g90kj325pvf22bq447rnm0whq3cnyz"; + vendorSha256 = "sha256-fMtAR66TwMNR/HCVQ9Jg3sJ0XBx2jUKDG7/ts0lEZM4="; +} diff --git a/pkgs/applications/networking/cluster/linkerd/generic.nix b/pkgs/applications/networking/cluster/linkerd/generic.nix new file mode 100644 index 000000000000..82172ebb9925 --- /dev/null +++ b/pkgs/applications/networking/cluster/linkerd/generic.nix @@ -0,0 +1,59 @@ +{ lib, fetchFromGitHub, buildGoModule, installShellFiles }: + +{ channel, version, sha256, vendorSha256 }: + +buildGoModule rec { + pname = "linkerd-${channel}"; + inherit version vendorSha256; + + src = fetchFromGitHub { + owner = "linkerd"; + repo = "linkerd2"; + rev = "${channel}-${version}"; + inherit sha256; + }; + + subPackages = [ "cli" ]; + runVend = true; + + preBuild = '' + env GOFLAGS="" go generate ./pkg/charts/static + env GOFLAGS="" go generate ./jaeger/static + env GOFLAGS="" go generate ./multicluster/static + env GOFLAGS="" go generate ./viz/static + ''; + + tags = [ + "prod" + ]; + + ldflags = [ + "-s" "-w" + "-X github.com/linkerd/linkerd2/pkg/version.Version=${src.rev}" + ]; + + nativeBuildInputs = [ installShellFiles ]; + + postInstall = '' + mv $out/bin/cli $out/bin/linkerd + installShellCompletion --cmd linkerd \ + --bash <($out/bin/linkerd completion bash) \ + --zsh <($out/bin/linkerd completion zsh) \ + --fish <($out/bin/linkerd completion fish) + ''; + + doInstallCheck = true; + installCheckPhase = '' + $out/bin/linkerd version --client | grep ${src.rev} > /dev/null + ''; + + passthru.updateScript = (./. + "/update-${channel}.sh"); + + meta = with lib; { + description = "A simple Kubernetes service mesh that improves security, observability and reliability"; + downloadPage = "https://github.com/linkerd/linkerd2/"; + homepage = "https://linkerd.io/"; + license = licenses.asl20; + maintainers = with maintainers; [ Gonzih bryanasdev000 superherointj ]; + }; +} diff --git a/pkgs/applications/networking/cluster/linkerd/update-edge.sh b/pkgs/applications/networking/cluster/linkerd/update-edge.sh new file mode 100755 index 000000000000..0ad960edebdd --- /dev/null +++ b/pkgs/applications/networking/cluster/linkerd/update-edge.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl gnugrep gnused jq + +set -eu -o pipefail + +cd $(dirname "$0") + +TAG=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} \ + --silent https://api.github.com/repos/linkerd/linkerd2/releases | \ + jq 'map(.tag_name)' | grep edge | sed 's/["|,| ]//g' | sort -r | head -n1) + +VERSION=$(echo ${TAG} | sed 's/^edge-//') + +SHA256=$(nix-prefetch-url --quiet --unpack https://github.com/linkerd/linkerd2/archive/refs/tags/${TAG}.tar.gz) + +setKV () { + sed -i "s|$1 = \".*\"|$1 = \"$2\"|" ./edge.nix +} + +setKV version ${VERSION} +setKV sha256 ${SHA256} +setKV vendorSha256 "" # Necessary to force clean build. + +cd ../../../../../ +set +e +VENDOR_SHA256=$(nix-build --no-out-link -A linkerd_edge 2>&1 | grep "got:" | cut -d':' -f2 | sed 's| ||g') +set -e + +if [ -n "${VENDOR_SHA256:-}" ]; then + cd - > /dev/null + setKV vendorSha256 ${VENDOR_SHA256} +else + echo "Update failed. VENDOR_SHA256 is empty." + exit 1 +fi diff --git a/pkgs/applications/networking/cluster/linkerd/update-stable.sh b/pkgs/applications/networking/cluster/linkerd/update-stable.sh new file mode 100755 index 000000000000..96280b507160 --- /dev/null +++ b/pkgs/applications/networking/cluster/linkerd/update-stable.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl gnugrep gnused jq + +set -eu -o pipefail + +cd $(dirname "$0") + +TAG=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} \ + --silent https://api.github.com/repos/linkerd/linkerd2/releases/latest | \ + jq -r '.tag_name') + +VERSION=$(echo ${TAG} | sed 's/^stable-//') + +SHA256=$(nix-prefetch-url --quiet --unpack https://github.com/linkerd/linkerd2/archive/refs/tags/${TAG}.tar.gz) + +setKV () { + sed -i "s|$1 = \".*\"|$1 = \"$2\"|" ./default.nix +} + +setKV version ${VERSION} +setKV sha256 ${SHA256} +setKV vendorSha256 "" # Necessary to force clean build. + +cd ../../../../../ +set +e +VENDOR_SHA256=$(nix-build --no-out-link -A linkerd 2>&1 | grep "got:" | cut -d':' -f2 | sed 's| ||g') +set -e + +if [ -n "${VENDOR_SHA256:-}" ]; then + cd - > /dev/null + setKV vendorSha256 ${VENDOR_SHA256} +else + echo "Update failed. VENDOR_SHA256 is empty." + exit 1 +fi diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8fe9d3850fd2..e74ba95b5959 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -25621,9 +25621,9 @@ with pkgs; fluxcd = callPackage ../applications/networking/cluster/fluxcd { }; - linkerd_edge = (callPackage ../applications/networking/cluster/linkerd { }).edge; - linkerd_stable = (callPackage ../applications/networking/cluster/linkerd { }).stable; - linkerd = linkerd_stable; + linkerd = callPackage ../applications/networking/cluster/linkerd { }; + linkerd_edge = callPackage ../applications/networking/cluster/linkerd/edge.nix { }; + linkerd_stable = linkerd; kile-wl = callPackage ../applications/misc/kile-wl { };