diff --git a/src/gitlab-tofu.sh b/src/gitlab-tofu.sh index 435b4bde8c139f8772c97232922c707dcb6528d3..075c6d212f2ead8230f186f05dde34e79b1f691e 100644 --- a/src/gitlab-tofu.sh +++ b/src/gitlab-tofu.sh @@ -11,9 +11,7 @@ fi # ============= # Below are a bunch of variables that we use as "feature flags". -if [ -z "$TF_FF_AUTO_URLENCODE_STATE_NAME" ]; then - TF_FF_AUTO_URLENCODE_STATE_NAME=true -fi +# There are no feature flags at the moment. # Helpers @@ -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 [ -n "${TF_STATE_NAME}" ] && [ -z "${TF_ADDRESS}" ]; then - # auto url-encode TF_STATE_NAME when FF is enabled - if $TF_FF_AUTO_URLENCODE_STATE_NAME; then - TF_STATE_NAME="$(jq -rn --arg x "${TF_STATE_NAME}" '$x|@uri')" - fi - + # auto url-encode TF_STATE_NAME + TF_STATE_NAME="$(jq -rn --arg x "${TF_STATE_NAME}" '$x|@uri')" TF_ADDRESS="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/${TF_STATE_NAME}" fi diff --git a/tests/unit/gitlab-tofu.bats b/tests/unit/gitlab-tofu.bats index 0770c928ff00acc5adfaafac7001006740063292..faf2d312ed717a377ccb243c4585886a5a9cb84f 100644 --- a/tests/unit/gitlab-tofu.bats +++ b/tests/unit/gitlab-tofu.bats @@ -84,13 +84,13 @@ EOF @test "gitlab-tofu plan" { export TF_PLAN_CACHE="test-plan.cache" 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" exit 1 fi 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" exit 1 fi @@ -111,28 +111,28 @@ EOF @test "gitlab-tofu validate without implicit init" { export TF_IMPLICIT_INIT=false - + run ! gitlab-tofu validate -no-color assert_output --partial 'This module is not yet installed' } @test "gitlab-tofu plan without implicit init" { export TF_IMPLICIT_INIT=false - + run ! gitlab-tofu plan -no-color assert_output --partial 'Error: Backend initialization required' } @test "gitlab-tofu apply without implicit init" { export TF_IMPLICIT_INIT=false - + run ! gitlab-tofu apply -no-color assert_output --partial 'Error: Failed to load ' } @test "gitlab-tofu destroy without implicit init" { export TF_IMPLICIT_INIT=false - + run ! gitlab-tofu destroy -no-color assert_output --partial 'Error: Backend initialization required' } @@ -195,21 +195,6 @@ EOF $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 @test "gitlab-tofu source init with prepared registry token" { test -n "$SHELL"