use python for variable substitution
This commit is contained in:
parent
2cdbfd296d
commit
40366779f5
3 changed files with 43 additions and 18 deletions
|
@ -45,6 +45,20 @@ spec:
|
|||
labels:
|
||||
app: bridge-facebook
|
||||
spec:
|
||||
initContainers:
|
||||
- name: template-config
|
||||
image: docker.io/library/python
|
||||
command: ["python", "/init/initialize-bridge.py"]
|
||||
volumeMounts:
|
||||
- name: init
|
||||
mountPath: /init
|
||||
- name: storage
|
||||
mountPath: /data
|
||||
- name: config
|
||||
mountPath: /config
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: bridge-facebook
|
||||
containers:
|
||||
- image: dock.mau.dev/mautrix/meta:latest
|
||||
name: bridge-facebook
|
||||
|
@ -58,11 +72,6 @@ spec:
|
|||
mountPath: /data
|
||||
- name: config
|
||||
mountPath: /config
|
||||
- name: init
|
||||
mountPath: /init
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: bridge-facebook
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
|
|
@ -63,6 +63,20 @@ spec:
|
|||
labels:
|
||||
app: bridge-telegram
|
||||
spec:
|
||||
initContainers:
|
||||
- name: template-config
|
||||
image: docker.io/library/python
|
||||
command: ["python", "/init/initialize-bridge.py"]
|
||||
volumeMounts:
|
||||
- name: init
|
||||
mountPath: /init
|
||||
- name: storage
|
||||
mountPath: /data
|
||||
- name: config
|
||||
mountPath: /config
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: bridge-telegram
|
||||
containers:
|
||||
- image: dock.mau.dev/mautrix/telegram:latest
|
||||
name: bridge-telegram
|
||||
|
@ -76,11 +90,6 @@ spec:
|
|||
mountPath: /data
|
||||
- name: config
|
||||
mountPath: /config
|
||||
- name: init
|
||||
mountPath: /init
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: bridge-telegram
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
|
|
|
@ -4,11 +4,18 @@ metadata:
|
|||
name: bridge-init
|
||||
namespace: matrix
|
||||
data:
|
||||
initialize-bridge.sh: |
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
cp /config/config.yaml /data/config.yaml
|
||||
sed -i "s#AS_TOKEN#${AS_TOKEN}#g" /data/config.yaml
|
||||
sed -i "s#HS_TOKEN#${HS_TOKEN}#g" /data/config.yaml
|
||||
sed -i "s#TG_API_ID#${TG_API_ID}#g" /data/config.yaml
|
||||
sed -i "s#TG_API_HASH#${TG_API_HASH}#g" /data/config.yaml
|
||||
initialize-bridge.py: |
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
|
||||
with open("/config/config.yaml") as r:
|
||||
c = r.read()
|
||||
|
||||
for i in ["AS_TOKEN", "HS_TOKEN", "TG_API_ID", "TG_API_HASH"]:
|
||||
value = os.getenv(i)
|
||||
if value is not None:
|
||||
c = c.replace(i, value)
|
||||
print("replaced", i)
|
||||
|
||||
with open("/data/config.yaml", 'w') as w:
|
||||
w.write(c)
|
||||
|
|
Loading…
Reference in a new issue