Skip to content

Commit

Permalink
INF-4840: support skipping plan
Browse files Browse the repository at this point in the history
  • Loading branch information
rmaynardap committed Feb 6, 2023
1 parent 7d0e072 commit c96ca0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions tfworker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ def version():
default=False,
help="apply the terraform configuration",
)
@click.option(
"--plan/--no-plan",
"tf_plan",
default=True,
help="toggle running a plan, plan will still be skipped if using a saved plan file with apply",
)
@click.option(
"--force/--no-force",
"force",
Expand Down
7 changes: 4 additions & 3 deletions tfworker/commands/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, rootc, **kwargs):

self._destroy = self._resolve_arg("destroy")
self._tf_apply = self._resolve_arg("tf_apply")
self._tf_plan = self._resolve_arg("tf_plan")
self._plan_file_path = self._resolve_arg("plan_file_path")
if self._tf_apply and self._destroy:
click.secho("can not apply and destroy at the same time", fg="red")
Expand Down Expand Up @@ -144,7 +145,7 @@ def exec(self):
execute = True
skip_plan = True

if skip_plan is False:
if skip_plan is False and self._tf_plan:
# run terraform plan
try:
self._run(
Expand All @@ -167,8 +168,8 @@ def exec(self):
)
raise SystemExit(2)

if not execute:
click.secho(f"no plan changes for {definition.tag}", fg="yellow")
if not execute:
click.secho(f"no plan changes for {definition.tag}", fg="yellow")

if self._force and (self._tf_apply or self._destroy):
execute = True
Expand Down

0 comments on commit c96ca0d

Please sign in to comment.