Loading tf.py +17 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
tf.py +17 −0 Original line number Diff line number Diff line Loading @@ -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 Loading