Add environment schema and secret rendering for application configuration

This commit is contained in:
suyiiyii 2025-03-14 11:11:59 +08:00
parent c4a1f3aefd
commit 1993029144
Signed by: suyiiyii
GPG Key ID: 044704CB29B8AD85
3 changed files with 28 additions and 2 deletions

17
base/env.k Normal file
View File

@ -0,0 +1,17 @@
import k8s.api.core.v1 as corev1
schema Envs:
"""Env schema"""
envs: {str:str}
envSecretRender = lambda e: Envs {
secret = corev1.Secret {
apiVersion = "v1"
kind = "Secret"
metadata = {
name = "app-sevret"
}
data = e.envs
}
secret
}

11
main.k
View File

@ -15,6 +15,15 @@ base.App {
port = 8080
}
base.Envs {
envs = {
"key1": "value1"
"key2": "value2"
}
}
apps_manifests = [base.appRender(a) for a in base.App.instances()]
env_manifests = [base.envSecretRender(a) for a in base.Envs.instances()]
# base.appRender(a)
manifests.yaml_stream([base.appRender(a) for a in base.App.instances()])
manifests.yaml_stream([apps_manifests, env_manifests])

View File

@ -1 +1 @@
exit status 1exit status 2exit 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 1