From bfd072d91b09d38053c93971f29c47b56488a72e Mon Sep 17 00:00:00 2001
From: Timo Furrer <tfurrer@gitlab.com>
Date: Thu, 18 Jan 2024 16:46:53 +0100
Subject: [PATCH] Fix needs

---
 Makefile                                                | 2 +-
 backports/OpenTofu/Base.gitlab-ci.yml                   | 1 -
 tests/integration-tests/BackportTemplates.gitlab-ci.yml | 1 +
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index d8c7ff9..04e5122 100644
--- a/Makefile
+++ b/Makefile
@@ -51,5 +51,5 @@ backports:
 	@sed -i $(BACKPORTS_BASE_FILE) -e 's/^plan:$$/.opentofu:plan:/'
 	@sed -i $(BACKPORTS_BASE_FILE) -e 's/^apply:$$/.opentofu:apply:/'
 	@sed -i $(BACKPORTS_BASE_FILE) -e 's/destroy:/.opentofu:destroy:/'
-	@sed -i $(BACKPORTS_BASE_FILE) -e 's/\[destroy\]/[.opentofu:destroy]/'
+	@sed -i $(BACKPORTS_BASE_FILE) -e '/needs: \[destroy\]/d'
 	@sed -i $(BACKPORTS_BASE_FILE) -e 's/^delete-state:$$/.opentofu:delete-state:/'
diff --git a/backports/OpenTofu/Base.gitlab-ci.yml b/backports/OpenTofu/Base.gitlab-ci.yml
index 96f6f50..8fc6e5a 100644
--- a/backports/OpenTofu/Base.gitlab-ci.yml
+++ b/backports/OpenTofu/Base.gitlab-ci.yml
@@ -101,7 +101,6 @@ variables:
 .opentofu:delete-state:
   extends: .opentofu:default
   stage: cleanup
-  needs: [.opentofu:destroy]
   resource_group: $TF_STATE_NAME
   rules:
     - when: never
diff --git a/tests/integration-tests/BackportTemplates.gitlab-ci.yml b/tests/integration-tests/BackportTemplates.gitlab-ci.yml
index b8964cb..a6e872b 100644
--- a/tests/integration-tests/BackportTemplates.gitlab-ci.yml
+++ b/tests/integration-tests/BackportTemplates.gitlab-ci.yml
@@ -27,5 +27,6 @@ destroy:
 
 delete-state:
   extends: .opentofu:delete-state
+  needs: [destroy]
   rules: [{when: always}]
 
-- 
GitLab