Format some files

This commit is contained in:
Pim Kunis 2025-01-11 22:00:22 +01:00
parent b11f4bd67a
commit 8bc6313112
2 changed files with 15 additions and 18 deletions

View file

@ -3,9 +3,10 @@
set -euo pipefail set -euo pipefail
first_server="${SERVERS%% *}" first_server="${SERVERS%% *}"
previous_manifest=$(ssh -T "root@$first_server" << EOF previous_manifest=$(
if [[ -f "$GCROOTDIR/${NAME}.yml" ]]; then envsubst <<EOF | ssh -T "root@$first_server"
cat "$GCROOTDIR/${NAME}.yml" if [[ -f "$GCROOTDIR/$NAME.yml" ]]; then
cat "$GCROOTDIR/$NAME.yml"
fi fi
EOF EOF
) )
@ -14,30 +15,26 @@ set +e
if [ -z "$previous_manifest" ]; then if [ -z "$previous_manifest" ]; then
echo No previous manifest found! echo No previous manifest found!
else else
$DYFF between <(echo $previous_manifest) $MANIFEST \ $DYFF between <(echo "$previous_manifest") "$MANIFEST" \
--exclude-regexp metadata.labels.kubenix/hash \ --exclude-regexp metadata.labels.kubenix/hash \
--exclude-regexp labels.kubenix/hash \ --exclude-regexp labels.kubenix/hash \
--set-exit-code --set-exit-code
if [ $? -eq 0 ]; then
exit 0
fi
fi fi
set -e set -e
read -r -p "Continue? " response read -r -p "Continue? " _
echo Uploading closure... echo Uploading closure...
for server in $SERVERS; do for server in $SERVERS; do
echo Uploading closure to $server... echo Uploading closure to "$server"...
nix copy --to "ssh://root@$server.dmz" $MANIFEST nix copy --to "ssh://root@$server.dmz" "$MANIFEST"
ssh "root@$server.dmz" "mkdir -p $GCROOTDIR && ln -sf $MANIFEST $GCROOTDIR/${NAME}.yml" ssh "root@$server.dmz" "mkdir -p $GCROOTDIR && ln -sf $MANIFEST $GCROOTDIR/${NAME}.yml"
done done
echo Applying Kubernetes manifest... echo Applying Kubernetes manifest...
export KUBECTL_APPLYSET=true export KUBECTL_APPLYSET=true
vals eval -fail-on-missing-key-in-map <$MANIFEST | \ vals eval -fail-on-missing-key-in-map <"$MANIFEST" |
kubectl apply -f - \ kubectl apply -f - \
--prune \ --prune \
--applyset applyset-$NAME \ --applyset applyset-"$NAME" \
--namespace $NAMESPACE --namespace "$NAMESPACE"

View file

@ -64,7 +64,7 @@ flake-utils.lib.eachDefaultSystem
pkgs.symlinkJoin pkgs.symlinkJoin
{ {
name = "applyset-deploy.sh"; name = "applyset-deploy.sh";
paths = [deployScript pkgs.vals pkgs.kubectl]; paths = [deployScript pkgs.vals pkgs.kubectl pkgs.gettext];
buildInputs = [pkgs.makeWrapper]; buildInputs = [pkgs.makeWrapper];
passthru.manifest = result; passthru.manifest = result;
meta.mainProgram = "applyset-deploy.sh"; meta.mainProgram = "applyset-deploy.sh";