Skip to content
Snippets Groups Projects
Commit f9a6bdd8 authored by Tiger Watson's avatar Tiger Watson
Browse files

Merge branch 'init-lockfile-readonly' into 'master'

Add variable TF_INIT_FLAGS

See merge request gitlab-org/terraform-images!128
parents 396db5b5 0c88d066
No related branches found
No related tags found
No related merge requests found
...@@ -147,6 +147,35 @@ test-init: ...@@ -147,6 +147,35 @@ test-init:
- export DEBUG_OUTPUT=true - export DEBUG_OUTPUT=true
- gitlab-terraform init - gitlab-terraform init
test-init-with-args:
extends:
- .test
- .versions
stage: test-init
script:
- export DEBUG_OUTPUT=true
- gitlab-terraform init -get=false -no-color
test-init-with-flags:
extends:
- .test
- .versions
stage: test-init
script:
- export DEBUG_OUTPUT=true
- export TF_INIT_FLAGS="-get=false -no-color"
- gitlab-terraform init
test-init-with-flags-and-args:
extends:
- .test
- .versions
stage: test-init
script:
- export DEBUG_OUTPUT=true
- export TF_INIT_FLAGS="-get=false"
- gitlab-terraform init -no-color
test-init-tf-root: test-init-tf-root:
extends: extends:
- .test-tf-root - .test-tf-root
...@@ -166,6 +195,35 @@ test-init-tf-root-with-cd: ...@@ -166,6 +195,35 @@ test-init-tf-root-with-cd:
- export DEBUG_OUTPUT=true - export DEBUG_OUTPUT=true
- gitlab-terraform init - gitlab-terraform init
test-init-tf-root-with-args:
extends:
- .test-tf-root
- .versions
stage: test-init
script:
- export DEBUG_OUTPUT=true
- gitlab-terraform init -get=false -no-color
test-init-tf-root-with-flags:
extends:
- .test-tf-root
- .versions
stage: test-init
script:
- export DEBUG_OUTPUT=true
- export TF_INIT_FLAGS="-get=false -no-color"
- gitlab-terraform init
test-init-tf-root-with-flags-and-args:
extends:
- .test-tf-root
- .versions
stage: test-init
script:
- export DEBUG_OUTPUT=true
- export TF_INIT_FLAGS="-get=false"
- gitlab-terraform init -no-color
test-fmt: test-fmt:
extends: extends:
- .test - .test
......
...@@ -55,6 +55,10 @@ variable "CI_PROJECT_NAME" { ...@@ -55,6 +55,10 @@ variable "CI_PROJECT_NAME" {
} }
``` ```
## Terraform lockfile handling
If you commit the `.terraform.lock.hcl` file to your repository we recommend setting `TF_INIT_FLAGS` to `-lockfile=readonly` to prevent changes to the lockfile.
# How to contribute? # How to contribute?
Contributions are always welcome. Don't be shy! Contributions are always welcome. Don't be shy!
......
...@@ -75,7 +75,9 @@ EOF ...@@ -75,7 +75,9 @@ EOF
fi fi
init() { init() {
terraform "${TF_CHDIR_OPT}" init "${@}" -input=false -reconfigure # We want to allow word splitting here for TF_INIT_FLAGS
# shellcheck disable=SC2086
terraform "${TF_CHDIR_OPT}" init "${@}" -input=false -reconfigure ${TF_INIT_FLAGS}
} }
case "${1}" in case "${1}" in
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment