cluster/services/storage: take over existing buckets and keys

This commit is contained in:
Max Headroom 2024-08-16 21:55:02 +02:00
parent 85916bda54
commit c3d0c07276

View file

@ -179,9 +179,13 @@ in
key = { key = {
destroyAfterDays = 0; destroyAfterDays = 0;
create = key: '' create = key: ''
# don't print secret key if [[ "$(garage key info ${lib.escapeShellArg key}) 2>&1 >/dev/null)" == "Error: 0 matching keys" ]]; then
garage key new --name ${lib.escapeShellArg key} >/dev/null # don't print secret key
echo Key ${lib.escapeShellArg key} was created. garage key new --name ${lib.escapeShellArg key} >/dev/null
echo Key ${lib.escapeShellArg key} was created.
else
echo "Key already exists, assuming ownership"
fi
''; '';
destroy = '' destroy = ''
garage key delete --yes "$OBJECT" garage key delete --yes "$OBJECT"
@ -196,7 +200,11 @@ in
deps = [ "key" ]; deps = [ "key" ];
destroyAfterDays = 30; destroyAfterDays = 30;
create = bucket: '' create = bucket: ''
garage bucket create ${lib.escapeShellArg bucket} if [[ "$(garage bucket info ${lib.escapeShellArg bucket} 2>&1 >/dev/null)" == "Error: Bucket not found" ]]; then
garage bucket create ${lib.escapeShellArg bucket}
else
echo "Bucket already exists, assuming ownership"
fi
''; '';
destroy = '' destroy = ''
garage bucket delete --yes "$OBJECT" garage bucket delete --yes "$OBJECT"