Refactor environment injection and secret rendering for improved deployment handling
This commit is contained in:
+13
-7
@@ -14,20 +14,26 @@ envSecretRender = lambda e: Envs {
|
||||
}
|
||||
data = e.envs
|
||||
}
|
||||
secret
|
||||
[secret]
|
||||
}
|
||||
|
||||
envInjector = lambda envs: Envs, deploy: appsv1.Deployment {
|
||||
envInjector = lambda envs: Envs, deploy {
|
||||
"""Inject envs to Deployment"""
|
||||
_result: [appsv1.Deployment] = []
|
||||
_result = {}
|
||||
if deploy.kind != "Deployment":
|
||||
_result = [deploy]
|
||||
_result = deploy
|
||||
else:
|
||||
secretEnv = [{
|
||||
secretEnv: [corev1.EnvVar] = [{
|
||||
name = k
|
||||
secret = v
|
||||
valueFrom = {
|
||||
secretKeyRef = {
|
||||
name = "app-secret"
|
||||
key = k
|
||||
}
|
||||
}
|
||||
} for k, v in envs.envs]
|
||||
print(secretEnv)
|
||||
deploy.spec.template.spec.containers[0].env = secretEnv
|
||||
_result = [deploy]
|
||||
_result = deploy
|
||||
_result
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import base
|
||||
|
||||
import yaml
|
||||
import manifests
|
||||
|
||||
base.App {
|
||||
@@ -17,15 +17,16 @@ base.App {
|
||||
|
||||
envs = base.Envs {
|
||||
envs = {
|
||||
"key1": "value1"
|
||||
"key2": "value2"
|
||||
"APP_VAR": "varvalue"
|
||||
"APP_SECRET": "secretvalue"
|
||||
}
|
||||
}
|
||||
|
||||
apps_manifests = [base.envInjector(envs,base.appRender(a)) for a in base.App.instances()]
|
||||
deploys = sum([base.appRender(a) for a in base.App.instances()], [])
|
||||
print(yaml.encode(deploys))
|
||||
|
||||
apps_manifests = [base.envInjector(envs, deploy) for deploy in deploys]
|
||||
|
||||
env_manifests = [base.envSecretRender(a) for a in base.Envs.instances()]
|
||||
|
||||
|
||||
# base.appRender(a)
|
||||
manifests.yaml_stream([apps_manifests, env_manifests])
|
||||
|
||||
@@ -1 +1 @@
|
||||
exit status 1exit status 2exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1
|
||||
exit status 1exit status 2exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1
|
||||
Reference in New Issue
Block a user