Skip to content

Commit c24b929

Browse files
committed
logic/check fixes
1 parent 9f3f154 commit c24b929

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

deploy.sh

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -269,28 +269,25 @@ EOF
269269
fi
270270

271271

272-
# check the container related `driver` value(s).
273-
# scan entire complex project JSON for any key named `Driver` and write to a file
274-
nomad run -output -var-file=env.env project.hcl |jq '.. | .Driver? | select(. != null)' >| drivers.txt
275-
# there should be exactly one of these drivers in the HCL
276-
NUM=$(grep -icE '^"DRIVER_SET_AT_RUNTIME"$' drivers.txt |cat)
277-
if [ "$NUM" -ne 1 ]; then echo 'bad drivers setup'; exit 1; fi
272+
if [ "$NOMAD_TOKEN" = test ]; then
273+
nomad run -output -var-file=env.env project.hcl >| project.json
274+
exit 0
275+
fi
276+
277+
278+
# check the `driver` value for all specified containers.
279+
# scan entire complex project JSON for any key named `Driver` and write to a file.
280+
nomad run -output project.hcl |jq '.. | .Driver? | select(. != null)' >| drivers.txt
278281
# there should be 1+ of either of these drivers in the HCL
279282
NUM=$(grep -icE '^"(docker|podman)"$' drivers.txt |cat)
280-
if [ "$NUM" -lt 1 ]; then echo 'drivers not located?'; exit 1; fi
281-
# there should be 0 of either of these drivers in the HCL
283+
if [ "$NUM" -lt 1 ]; then echo 'drivers not found?'; exit 1; fi
284+
# there should be 0 of either of these drivers in the HCL.
285+
# NOTE: the `raw_exec` driver used only for secrets isn't in the `drivers.txt` list since we did
286+
# *NOT* use `-var-file=env.env` (so the entire kv related `task` gets removed in `nomad run`).
282287
NUM=$(grep -icE '^"(exec|raw_exec)"$' drivers.txt |cat)
283288
if [ "$NUM" -ne 0 ]; then echo 'bad drivers in project'; exit 1; fi
284289
rm drivers.txt
285290

286-
# Now swap in the 'raw_exec' driver for the 'kv' task
287-
sed -ix 's/driver = "DRIVER_SET_AT_RUNTIME"/driver = "raw_exec"/' project.hcl
288-
289-
290-
if [ "$NOMAD_TOKEN" = test ]; then
291-
nomad run -output -var-file=env.env project.hcl >| project.json
292-
exit 0
293-
fi
294291

295292
set -x
296293
nomad validate -var-file=env.env project.hcl

project.nomad

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ CI_COMMIT_SHA=${var.CI_COMMIT_SHA}
392392
for_each = slice(keys(var.NOMAD_SECRETS), 0, min(1, length(keys(var.NOMAD_SECRETS))))
393393
labels = ["kv"]
394394
content {
395-
driver = "DRIVER_SET_AT_RUNTIME"
395+
driver = "raw_exec"
396396
config {
397397
command = "/usr/bin/consul"
398398
args = [ "kv", "put", var.SLUG, local.kv ]

0 commit comments

Comments
 (0)