From 0ec147dab605456e780ff808887cb167c6c34ad5 Mon Sep 17 00:00:00 2001 From: Chris Allen Date: Mon, 25 Sep 2023 10:50:35 -0500 Subject: [PATCH] Fix env variable encoding when the base64 encoding flag is set --- tfworker/commands/terraform.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tfworker/commands/terraform.py b/tfworker/commands/terraform.py index aae6021..4d5f268 100644 --- a/tfworker/commands/terraform.py +++ b/tfworker/commands/terraform.py @@ -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 @@ -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: @@ -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