Skip to content
Snippets Groups Projects
Commit 5a44d366 authored by Timo Furrer's avatar Timo Furrer
Browse files

Merge branch 'remove-ff-auto-urlencode-state-name' into 'main'

Remove `TF_FF_AUTO_URLENCODE_STATE_NAME` feature flag

See merge request components/opentofu!187
parents 67a8ff85 300f345e
No related branches found
No related tags found
No related merge requests found
...@@ -11,9 +11,7 @@ fi ...@@ -11,9 +11,7 @@ fi
# ============= # =============
# Below are a bunch of variables that we use as "feature flags". # Below are a bunch of variables that we use as "feature flags".
if [ -z "$TF_FF_AUTO_URLENCODE_STATE_NAME" ]; then # There are no feature flags at the moment.
TF_FF_AUTO_URLENCODE_STATE_NAME=true
fi
# Helpers # Helpers
...@@ -78,11 +76,8 @@ fi ...@@ -78,11 +76,8 @@ fi
# If TF_ADDRESS is unset but TF_STATE_NAME is provided, then default to GitLab backend in current project # If TF_ADDRESS is unset but TF_STATE_NAME is provided, then default to GitLab backend in current project
if [ -n "${TF_STATE_NAME}" ] && [ -z "${TF_ADDRESS}" ]; then if [ -n "${TF_STATE_NAME}" ] && [ -z "${TF_ADDRESS}" ]; then
# auto url-encode TF_STATE_NAME when FF is enabled # auto url-encode TF_STATE_NAME
if $TF_FF_AUTO_URLENCODE_STATE_NAME; then TF_STATE_NAME="$(jq -rn --arg x "${TF_STATE_NAME}" '$x|@uri')"
TF_STATE_NAME="$(jq -rn --arg x "${TF_STATE_NAME}" '$x|@uri')"
fi
TF_ADDRESS="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/${TF_STATE_NAME}" TF_ADDRESS="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/${TF_STATE_NAME}"
fi fi
......
...@@ -84,13 +84,13 @@ EOF ...@@ -84,13 +84,13 @@ EOF
@test "gitlab-tofu plan" { @test "gitlab-tofu plan" {
export TF_PLAN_CACHE="test-plan.cache" export TF_PLAN_CACHE="test-plan.cache"
gitlab-tofu plan gitlab-tofu plan
if [ ! -f "$TF_ROOT/$TF_PLAN_CACHE" ]; then if [ ! -f "$TF_ROOT/$TF_PLAN_CACHE" ]; then
echo "expected to find a plan.cache file" echo "expected to find a plan.cache file"
exit 1 exit 1
fi fi
gitlab-tofu plan-json gitlab-tofu plan-json
if [ ! -f "$TF_ROOT/plan.json" ]; then if [ ! -f "$TF_ROOT/plan.json" ]; then
echo "expected to find a plan.json file" echo "expected to find a plan.json file"
exit 1 exit 1
fi fi
...@@ -111,28 +111,28 @@ EOF ...@@ -111,28 +111,28 @@ EOF
@test "gitlab-tofu validate without implicit init" { @test "gitlab-tofu validate without implicit init" {
export TF_IMPLICIT_INIT=false export TF_IMPLICIT_INIT=false
run ! gitlab-tofu validate -no-color run ! gitlab-tofu validate -no-color
assert_output --partial 'This module is not yet installed' assert_output --partial 'This module is not yet installed'
} }
@test "gitlab-tofu plan without implicit init" { @test "gitlab-tofu plan without implicit init" {
export TF_IMPLICIT_INIT=false export TF_IMPLICIT_INIT=false
run ! gitlab-tofu plan -no-color run ! gitlab-tofu plan -no-color
assert_output --partial 'Error: Backend initialization required' assert_output --partial 'Error: Backend initialization required'
} }
@test "gitlab-tofu apply without implicit init" { @test "gitlab-tofu apply without implicit init" {
export TF_IMPLICIT_INIT=false export TF_IMPLICIT_INIT=false
run ! gitlab-tofu apply -no-color run ! gitlab-tofu apply -no-color
assert_output --partial 'Error: Failed to load ' assert_output --partial 'Error: Failed to load '
} }
@test "gitlab-tofu destroy without implicit init" { @test "gitlab-tofu destroy without implicit init" {
export TF_IMPLICIT_INIT=false export TF_IMPLICIT_INIT=false
run ! gitlab-tofu destroy -no-color run ! gitlab-tofu destroy -no-color
assert_output --partial 'Error: Backend initialization required' assert_output --partial 'Error: Backend initialization required'
} }
...@@ -195,21 +195,6 @@ EOF ...@@ -195,21 +195,6 @@ EOF
$SHELL test.sh $SHELL test.sh
} }
# bats test_tags=source
@test "gitlab-tofu source state name auto urlencode FF disabled" {
test -n "$SHELL"
cat <<'EOF' > test.sh
set -x
export TF_FF_AUTO_URLENCODE_STATE_NAME=false
export TF_STATE_NAME=production/europe
. $(which gitlab-tofu)
test "$TF_STATE_NAME" = "production/europe"
EOF
$SHELL test.sh
}
# bats test_tags=source # bats test_tags=source
@test "gitlab-tofu source init with prepared registry token" { @test "gitlab-tofu source init with prepared registry token" {
test -n "$SHELL" test -n "$SHELL"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment