Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
tf
Commits
a570218e
Commit
a570218e
authored
3 months ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
Address different cases with apply.
We can't add -var-file to an apply command if a plan is specified.
parent
0f2f1181
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tf.py
+17
-0
17 additions, 0 deletions
tf.py
with
17 additions
and
0 deletions
tf.py
+
17
−
0
View file @
a570218e
...
...
@@ -83,6 +83,23 @@ def wrapper():
print
(
f
"
Can
'
t find
{
TF_CLI
}
.
"
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
# We can't add -var-file to an apply command with a plan. So we check all
# of the args after the apply arg and if all of them are switches we assume
# that a plan isn't specified (technically the plan file can also start
# with a "-" and look like a switch, but let's not go there).
if
command
==
"
apply
"
:
apply_index
=
sys
.
argv
.
index
(
"
apply
"
)
if
not
all
(
map
(
lambda
x
:
x
.
startswith
(
"
-
"
),
sys
.
argv
[
apply_index
+
1
:])
):
# No all args are switches, so a plan is specified and we don't add
# the -var-file switch.
try
:
os
.
execvp
(
TF_CLI
,
args
)
# nosec
except
FileNotFoundError
:
print
(
f
"
Can
'
t find
{
TF_CLI
}
.
"
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
# We need to add the var files after the Terraform command (if we add it
# before Terraform doesn't accept them) but not at the end (not to modify
# other argument that accept optional values). So we add them right after
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment