ci/cd - fix wrong yaml edit for swarm and append LE settings for k8s

This commit is contained in:
florian 2023-03-29 22:03:24 +02:00
parent f07c0e66a3
commit 1c3f094cd9
No known key found for this signature in database
GPG Key ID: 3D80806F12602A7C
2 changed files with 12 additions and 10 deletions

View File

@ -6,7 +6,7 @@ from traceback import format_exc
from subprocess import run
from time import sleep
from logger import log
from yaml import safe_load_all, dump
from yaml import safe_load_all, dump_all
class KubernetesTest(Test):
def __init__(self, name, timeout, tests, delay=0):
@ -45,14 +45,16 @@ class KubernetesTest(Test):
mkdir("/tmp/kubernetes")
copy("./misc/integrations/k8s.mariadb.yml", "/tmp/kubernetes/bunkerweb.yml")
deploy = "/tmp/kubernetes/bunkerweb.yml"
# with open(deploy, "r") as f :
# data = safe_load_all(f.read())
# for
# if not "AUTO_LETS_ENCRYPT=yes" in data["services"]["bunkerweb"]["environment"] :
# data["services"]["bunkerweb"]["environment"].append("AUTO_LETS_ENCRYPT=yes")
# data["services"]["bunkerweb"]["environment"].append("USE_LETS_ENCRYPT_STAGING=yes")
# with open(compose, "w") as f :
# f.write(data)
yamls = []
with open(deploy, "r") as f :
data = safe_load_all(f.read())
for yaml in data :
if yaml["metadata"]["name"] == "bunkerweb" :
yaml["spec"]["template"]["spec"]["containers"][0]["env"].append({"name": "AUTO_LETS_ENCRYPT", "value": "yes"})
yaml["spec"]["template"]["spec"]["containers"][0]["env"].append({"name": "USE_LETS_ENCRYPT_STAGING", "value": "yes"})
yamls.append(yaml)
with open(deploy, "w") as f :
f.write(dump_all(yamls))
Test.replace_in_file(
deploy,
r"bunkerity/bunkerweb:.*$",

View File

@ -38,7 +38,7 @@ class SwarmTest(Test):
data["services"]["bunkerweb"]["environment"].append("AUTO_LETS_ENCRYPT=yes")
data["services"]["bunkerweb"]["environment"].append("USE_LETS_ENCRYPT_STAGING=yes")
with open(compose, "w") as f :
f.write(data)
f.write(dump(data))
Test.replace_in_file(
compose,
r"bunkerity/bunkerweb:.*$",