kcl-lang / konfig

KCL Kubernetes Config Abstraction & Composition Module
https://kcl-lang.io
Apache License 2.0
7 stars 6 forks source link

[Doc] How to use `env`? #11

Closed east4ming closed 2 months ago

east4ming commented 2 months ago

Bug Report

konfig.md 如下:

import models.kube.frontend
import models.kube.frontend.container
import models.kube.templates.resource as res_tpl

appConfiguration: frontend.Server {
    mainContainer = container.Main {
        name = "php-redis"
        env = [
            {
                name = "GET_HOSTS_FROM"
                value = "dns"
            }
        ]
        ports = [{containerPort = 80}]
    }
    selector = {
        tier = "frontend"
    }
    podMetadata.labels: {
        tier = "frontend"
    }
    schedulingStrategy.resource = res_tpl.tiny
}

但是实际执行报错:

expected EnvMap, got [{str(name) | str(value):str(GET_HOSTS_FROM) | str(dns)}](TypeError)
container.k(68, 5): variable is defined here, its type is EnvMap, but got [{str(name) | str(value):str(GET_HOSTS_FROM) | str(dns)}]

1. Minimal reproduce step (Required)

如上

2. What did you expect to see? (Required)

按照文档可以正确使用

3. What did you see instead (Required)

如上

4. What is your KCL components version? (Required)

  1. kcl 0.9.0 beta
  2. konfig 0.5.0
Peefy commented 2 months ago

Here's an example: https://github.com/kcl-lang/konfig/blob/01ca24c02ea25c8093e515754388ab97981d9a3d/models/kube/frontend/server.k#L80

east4ming commented 2 months ago

Got it. Tks