Skip to content

Commit

Permalink
Fix env variable encoding when the base64 encoding flag is set
Browse files Browse the repository at this point in the history
  • Loading branch information
callenafp committed Sep 25, 2023
1 parent 1233a94 commit 0ec147d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions tfworker/commands/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,7 @@ def hook_exec(

if state_value is not None:
if b64_encode:
state_value = base64.b64encode(
state_value.encode("utf-8")
).decode()
state_value = base64.b64encode(state_value.encode("utf-8"))
local_env[f"TF_REMOTE_{state}_{item}".upper()] = state_value

# populate environment with terraform variables
Expand All @@ -581,7 +579,7 @@ def hook_exec(
tf_var[1] = tf_var[1].replace(k, v)

if b64_encode:
tf_var[1] = base64.b64encode(tf_var[1].encode("utf-8")).decode()
tf_var[1] = base64.b64encode(tf_var[1].encode("utf-8"))

local_env[f"TF_VAR_{tf_var[0].upper()}"] = tf_var[1]
else:
Expand All @@ -592,7 +590,7 @@ def hook_exec(

for k, v in extra_vars.items():
if b64_encode:
v = base64.b64encode(v.encode("utf-8")).decode()
v = base64.b64encode(v.encode("utf-8"))
local_env[f"TF_EXTRA_{k.upper()}"] = v

# execute the hook
Expand Down

0 comments on commit 0ec147d

Please sign in to comment.