From 948594f5d30bd5badf4fe0eca97db37d231845fe Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sun, 13 Oct 2024 01:02:15 +0200 Subject: [PATCH] Diff changes between manifests --- applyset-deploy.sh | 21 +++++++++++++++++++++ flake.lock | 25 +++++++++++++------------ kubenix.nix | 1 + 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/applyset-deploy.sh b/applyset-deploy.sh index 07a09c0..adaea82 100644 --- a/applyset-deploy.sh +++ b/applyset-deploy.sh @@ -2,6 +2,27 @@ set -euo pipefail +first_server="${SERVERS%% *}" +previous_manifest=$(ssh -T "root@$first_server" << EOF +if [[ -f "$GCROOTDIR/${NAME}.yml" ]]; then + cat "$GCROOTDIR/${NAME}.yml" +fi +EOF +) + +set +e +if [ -z "$previous_manifest" ]; then + echo No previous manifest found! +else + $DYFF between --set-exit-code <(echo $previous_manifest) $MANIFEST + if [ $? -eq 0 ]; then + exit 0 + fi +fi +set -e + +read -r -p "Continue? " response + echo Uploading closure... for server in $SERVERS; do echo Uploading closure to $server... diff --git a/flake.lock b/flake.lock index d41e80d..862f6bf 100644 --- a/flake.lock +++ b/flake.lock @@ -13,6 +13,7 @@ "locked": { "lastModified": 1715503080, "narHash": "sha256-/VnzHTpTq3u0z2Vgu/vKU0SHwOUIu8olHDORWT0IofM=", + "ref": "refs/heads/master", "rev": "7296f7f5bf5f089a5137036dcbd8058cf3e4a9e5", "revCount": 21, "type": "git", @@ -73,11 +74,11 @@ ] }, "locked": { - "lastModified": 1719459426, - "narHash": "sha256-4Kn9Pb3lvsik/VYsEAYgXpkcmLhrr0tTE6oIT2PMSPA=", + "lastModified": 1726867691, + "narHash": "sha256-IK3r16N9pizf53AipOmrcrcyjVsPJwC4PI5hIqEyKwQ=", "owner": "kirelagin", "repo": "dns.nix", - "rev": "e6693931023206f1f3c2bfc57d2c98b5f27f52e6", + "rev": "a3196708a56dee76186a9415c187473b94e6cbae", "type": "github" }, "original": { @@ -282,11 +283,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "type": "github" }, "original": { @@ -451,11 +452,11 @@ "poetry2nix": "poetry2nix" }, "locked": { - "lastModified": 1725758289, - "narHash": "sha256-7Och9QDZx5i7yNJYo/l3z46vYB7c6Hg5/XPyxMGX5mM=", + "lastModified": 1728695719, + "narHash": "sha256-0BJrse7b2jwKQ0oqBKWK7qmH+Km1ENAGzrsIG+yYGbY=", "owner": "farcaller", "repo": "nixhelm", - "rev": "f5e54a73ff511396e0262f82d34933c8745bda05", + "rev": "8784378fb80a27fd874e91c3c60106958036ec45", "type": "github" }, "original": { @@ -573,11 +574,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1725634671, - "narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=", + "lastModified": 1728492678, + "narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "574d1eac1c200690e27b8eb4e24887f8df7ac27c", + "rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7", "type": "github" }, "original": { diff --git a/kubenix.nix b/kubenix.nix index debc874..8c1c7fd 100644 --- a/kubenix.nix +++ b/kubenix.nix @@ -71,6 +71,7 @@ inputs@{ self, servers, flutils, nixpkgs, kubenix, ... }: flutils.lib.eachDefaul --set NAME '${name}' \ --set NAMESPACE '${namespace}' \ --set SERVERS '${k8sServerNames}' \ + --set DYFF '${lib.getExe pkgs.dyff}' \ --set GCROOTDIR '/nix/var/nix/gcroots/kubernetes-manifests' ''; };