Skip to content

Commit

Permalink
feat: change the env from list to map and bump the konfig version to …
Browse files Browse the repository at this point in the history
…0.5.0

Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Mar 26, 2024
1 parent cd5d6be commit 10cd890
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion konfig/kcl.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "konfig"
version = "0.4.0"
version = "0.5.0"
description = "Konfig provides users with an out-of-the-box, highly abstract configuration interface. The original starting point of the model library is to improve the efficiency and experience of YAML users. We hope to simplify the writing of user-side configuration code by abstracting and encapsulating the model with more complex code into a unified model."

[dependencies]
Expand Down
6 changes: 0 additions & 6 deletions konfig/models/kube/backend/server_backend.k
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ schema ServerBackend[inputConfig: server.Server]:
if config.initContainers:
initContainers = utils.VolumePatch(config.volumes, [utils.ContainerFrontend2Kube(_s) for _s in config.initContainers])

if config.storage:
provider = [*provider, *StorageBackend(config).provider]

if config.database:
provider = [*provider, *DatabaseBackend(config).provider]

_applicationLabel: {str: str} = {
"app.k8s.io/component": workloadName
}
Expand Down
4 changes: 2 additions & 2 deletions konfig/models/kube/frontend/container/container.k
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ schema Main:
args: [str], default is Undefined, optional.
A Container-level attribute.
The startup arguments of main process. The image's cmd is used if this is not provided.
env: [e.Env], default is Undefined, optional.
env: e.EnvMap, default is Undefined, optional.
A Container-level attribute.
List of environment variables in the container.
envFrom: [e.EnvFromSource], default is Undefined, optional.
Expand Down Expand Up @@ -65,7 +65,7 @@ schema Main:
command?: [str]
args?: [str]
useBuiltInEnv?: bool = False
env?: [e.Env]
env?: e.EnvMap
envFrom?: [e.EnvFromSource]
ports?: [cp.ContainerPort]

Expand Down
5 changes: 5 additions & 0 deletions konfig/models/kube/frontend/container/env/env.k
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import regex
import units

schema EnvMap:
[name: str]: Env = {
name = name
}

schema Env:
""" Env represents an environment variable present in a Container.

Expand Down
9 changes: 3 additions & 6 deletions konfig/models/kube/frontend/server.k
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,9 @@ schema Server:
appConfiguration: frontend.Server {
mainContainer = container.Main {
name = "php-redis"
env = [
{
name = "GET_HOSTS_FROM"
value = "dns"
}
]
env: {
"GET_HOSTS_FROM": {value = "dns"}
}
ports = [{containerPort = 80}]
}
selector = {
Expand Down
2 changes: 1 addition & 1 deletion konfig/models/kube/frontend/sidecar/sidecar.k
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ schema Sidecar:
name: str
command?: [str]
args?: [str]
env?: [e.Env]
env?: e.EnvMap
envFrom?: [e.EnvFromSource]
ports?: [cp.ContainerPort]
resource: str | res.Resource
Expand Down
2 changes: 1 addition & 1 deletion konfig/models/kube/utils/container_frontend2kube.k
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ContainerFrontend2Kube = lambda c -> {str:} {
divisor: str(e.valueFrom.resourceFieldRef.divisor)
} if e.valueFrom.resourceFieldRef else Undefined
} if e.valueFrom else Undefined
} for e in c.env
} for _, e in c.env
]

# Convert frontend envFrom to kube envFrom
Expand Down

0 comments on commit 10cd890

Please sign in to comment.