From 6d04bd3ef388f8df19348054a38edaa40591c054 Mon Sep 17 00:00:00 2001
From: Timo Furrer <tuxtimo@gmail.com>
Date: Wed, 26 Feb 2025 08:24:02 +0100
Subject: [PATCH] Implement delete-state command in gitlab-tofu script

---
 src/gitlab-tofu.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/gitlab-tofu.sh b/src/gitlab-tofu.sh
index 672c02d..e5ecfc1 100644
--- a/src/gitlab-tofu.sh
+++ b/src/gitlab-tofu.sh
@@ -107,7 +107,7 @@ fi
 # Dependencies
 # ============
 # Defines all the external dependencies and checks if they exist, if not, abort with an error.
-dependencies="dirname basename pwd sed idn2 jq tofu"
+dependencies="dirname basename pwd sed idn2 jq tofu curl"
 
 if [ -n "$ZSH_VERSION" ]; then
   # ZSH is the only supported SHELL that does not split by word by default,
@@ -428,6 +428,9 @@ if [ $sourced -eq 0 ]; then
       # shellcheck disable=SC2086
       tofu "${tf_chdir_opt}" "${@}" ${var_file_args}
     ;;
+    "delete-state")
+      curl --request DELETE -u "${backend_username}:${backend_password}" "${backend_address}"
+    ;;
     --)
       shift
       tofu "${tf_chdir_opt}" "${@}"
-- 
GitLab