From 98f4a28860762cb2660638e6ed66cb1b25ab6eb4 Mon Sep 17 00:00:00 2001 From: apollorion Date: Thu, 6 Jun 2024 16:47:55 -0400 Subject: [PATCH] feat: check for opentofu during import --- .../commands/import_state_files_to_spacelift.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/spacemk/commands/import_state_files_to_spacelift.py b/spacemk/commands/import_state_files_to_spacelift.py index dd47cd3..0b85d40 100644 --- a/spacemk/commands/import_state_files_to_spacelift.py +++ b/spacemk/commands/import_state_files_to_spacelift.py @@ -44,7 +44,20 @@ def _create_context(spacelift: Spacelift, space_id: str, token: str): --show-error \ --silent \ "${STATE_DOWNLOAD_URL}" -terraform state push -force state.tfstate + +set +e +binary="terraform" +if ! command $binary; then + echo "Terraform is not installed" + binary="tofu" + if ! command $binary; then + echo "OpenTofu is not installed" + exit 1 + fi +fi +set -euo pipefail + +$binary state push -force state.tfstate """ variables = {