From af189ec1c3386f81594a31e9732757d409b08005 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 12 Aug 2024 02:34:35 +0200 Subject: [PATCH] cluster/services/storage: register existing keys and buckets in incandescence --- cluster/services/storage/default.nix | 1 + .../storage/incandescence-ascensions.nix | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 cluster/services/storage/incandescence-ascensions.nix diff --git a/cluster/services/storage/default.nix b/cluster/services/storage/default.nix index 7d7b723..a5ca16b 100644 --- a/cluster/services/storage/default.nix +++ b/cluster/services/storage/default.nix @@ -39,6 +39,7 @@ in ./garage.nix ./garage-options.nix ./garage-layout.nix + ./incandescence-ascensions.nix ] ++ lib.optionals config.simulacrum [ ./simulacrum/snakeoil-rpc-secret.nix ]; diff --git a/cluster/services/storage/incandescence-ascensions.nix b/cluster/services/storage/incandescence-ascensions.nix new file mode 100644 index 0000000..9011fb7 --- /dev/null +++ b/cluster/services/storage/incandescence-ascensions.nix @@ -0,0 +1,18 @@ +{ config, lib, ... }: + +{ + system.ascensions = { + incandescence-garage = lib.mkIf (config.services.incandescence.providers ? garage) { + incantations = i: [ + (i.runGarage /*bash*/ '' + garage bucket list | tail -n +2 | cut -d' ' -f3 | while read bucket; do + ${i.runConsul /*bash*/ ''consul kv put "services/incandescence/providers/garage/formulae/bucket/$1/alive" true''} "$bucket" + done + garage key list | tail -n +2 | cut -d' ' -f5 | while read key; do + ${i.runConsul /*bash*/ ''consul kv put "services/incandescence/providers/garage/formulae/key/$1/alive" true''} "$key" + done + '') + ]; + }; + }; +}