From a51da48f6871e47b3bccd41640b7553ecece3a56 Mon Sep 17 00:00:00 2001
From: Keith Smiley <keithbsmiley@gmail.com>
Date: Thu, 10 Jun 2021 11:26:53 -0700
Subject: [PATCH] Strip quotes from stepEnv (#30)

Fixes https://github.com/EmbarkStudios/k8s-buildkite-plugin/issues/29
---
 lib/job.jsonnet | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/job.jsonnet b/lib/job.jsonnet
index 0072b26..3b82385 100644
--- a/lib/job.jsonnet
+++ b/lib/job.jsonnet
@@ -83,9 +83,11 @@ function(jobName, agentEnv={}, stepEnvFile='', patchFunc=identity) patchFunc({
   local stepEnv =
     [
       {
+        local trim(v) = if std.startsWith(v, '"') && std.endsWith(v, '"')
+          then std.substr(v, 1, std.length(v) - 2) else v,
         local kv = std.splitLimit(l, '=', 1),
         name: kv[0],
-        value: kv[1],
+        value: trim(kv[1]),
       }
       for l in std.split(stepEnvFile, '\n')
       if l != '' && !std.startsWith(l, 'BUILDKITE')