Skip to content

Commit

Permalink
feat: add argument for lock timeout (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrebask authored Oct 24, 2022
1 parent 81c0aad commit da27931
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/commands/apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ parameters:
description: Configure a custom timeout limit
type: string
default: 10m
lock-timeout:
description: Configure a custom state lock timeout
type: string
default: 30s

steps:
- run:
Expand All @@ -53,4 +57,5 @@ steps:
TF_PARAM_BACKEND_CONFIG_FILE: <<parameters.backend_config_file>>
TF_PARAM_CLI_CONFIG_FILE: <<parameters.cli_config_file>>
TF_PARAM_PLAN: <<parameters.plan>>
TF_PARAM_LOCK_TIMEOUT: << parameters.lock-timeout >>
command: <<include(scripts/apply.sh)>>
5 changes: 5 additions & 0 deletions src/commands/plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ parameters:
description: Configure a custom timeout limit
type: string
default: 10m
lock-timeout:
description: Configure a custom state lock timeout
type: string
default: 30s

steps:
- run:
Expand All @@ -53,4 +57,5 @@ steps:
TF_PARAM_BACKEND_CONFIG_FILE: <<parameters.backend_config_file>>
TF_PARAM_CLI_CONFIG_FILE: <<parameters.cli_config_file>>
TF_PARAM_OUT: << parameters.out >>
TF_PARAM_LOCK_TIMEOUT: << parameters.lock-timeout >>
command: <<include(scripts/plan.sh)>>
5 changes: 5 additions & 0 deletions src/jobs/apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ parameters:
description: "Configure a custom timeout limit"
type: "string"
default: "10m"
lock-timeout:
description: Configure a custom state lock timeout
type: string
default: 30s
resource_class:
description: "Specify the resource class for Docker Executor"
type: "string"
Expand Down Expand Up @@ -98,6 +102,7 @@ steps:
cli_config_file: << parameters.cli_config_file >>
plan: <<parameters.plan>>
timeout: <<parameters.timeout>>
lock-timeout: <<parameters.lock-timeout>>
- when:
condition: << parameters.persist-workspace >>
steps:
Expand Down
5 changes: 5 additions & 0 deletions src/jobs/plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ parameters:
description: "Configure a custom timeout limit"
type: "string"
default: "10m"
lock-timeout:
description: Configure a custom state lock timeout
type: string
default: 30s
resource_class:
description: "Specify the resource class for Docker Executor"
type: "string"
Expand Down Expand Up @@ -99,6 +103,7 @@ steps:
cli_config_file: << parameters.cli_config_file >>
out: << parameters.out >>
timeout: <<parameters.timeout>>
lock-timeout: <<parameters.lock-timeout>>
- when:
condition: << parameters.persist-workspace >>
steps:
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/apply.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ if [[ -n "${TF_PARAM_VAR_FILE}" ]]; then
fi
done
fi

if [[ -n "${TF_PARAM_LOCK_TIMEOUT}" ]]; then
PLAN_ARGS="$PLAN_ARGS -lock-timeout=${TF_PARAM_LOCK_TIMEOUT}"
fi
export PLAN_ARGS
# shellcheck disable=SC2086
terraform -chdir="$module_path" init -input=false $INIT_ARGS
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ if [[ -n "${TF_PARAM_VAR_FILE}" ]]; then
fi
done
fi

if [[ -n "${TF_PARAM_LOCK_TIMEOUT}" ]]; then
PLAN_ARGS="$PLAN_ARGS -lock-timeout=${TF_PARAM_LOCK_TIMEOUT}"
fi
export PLAN_ARGS
# shellcheck disable=SC2086
terraform -chdir="$module_path" plan -input=false -out=${TF_PARAM_OUT} $PLAN_ARGS

0 comments on commit da27931

Please sign in to comment.