Closed liangyuanpeng closed 3 weeks ago
Hello @liangyuanpeng Perhaps what you want is this piece of code.
kind = "Cluster"
apiVersion = "kind.x-k8s.io/v1alpha4"
networking = {
#https://kcl-lang.io/docs/user_docs/support/faq-kcl#39-how-to-set-default-value-for-option-function-in-kcl
apiServerAddress = option("apiaddress",default="127.0.0.1")
}
nodes=[{
role = "control-plane",
image = option("kindimage",default="kindest/node:v1.30.0")
kubeadmConfigPatches = [
"""\
kind: ClusterConfiguration
apiServer:
extraArgs:
runtime-config: api/all=true
storage-media-type: option("storageMediaType",default="application/json")
"""
]
}]
qqq="""\
kind: ClusterConfiguration
apiServer:
extraArgs:
runtime-config: api/all=true
storage-media-type: option("storageMediaType",default="application/json")
"""
qqq2="""\
hello
"""
Please note that my additional task is to remove trailing spaces in multiple line strings
@Peefy Awesome!! Thanks for quickly reply, and do you want to support set param on multiple line strings? I'm not sure if this is a reasonable request. Anyway, now it does what I want.
kind = "Cluster"
apiVersion = "kind.x-k8s.io/v1alpha4"
networking = {
#https://kcl-lang.io/docs/user_docs/support/faq-kcl#39-how-to-set-default-value-for-option-function-in-kcl
apiServerAddress = option("apiaddress",default="127.0.0.1")
}
nodes=[{
role = "control-plane",
image = option("kindimage",default="kindest/node:v1.30.0")
kubeadmConfigPatches = [
"""\
kind: ClusterConfiguration
apiServer:
extraArgs:
runtime-config: api/all=true
storage-media-type: ${REALLY_STORAGE_MEDIA_TYPE}
"""
]
}]
run command with:
REALLY_STORAGE_MEDIA_TYPE=application/json envsubst < main.k > main2.k
kcl main2.k
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
I'm try to using kcl to manage kind config files and have not get the
|
fromkubeadmConfigPatches
.2. What did you expect to see? (Required)
I'm not sure kcl does support this case? remind me if i missed something,Thanks.
3. What did you see instead (Required)
4. What is your KCL components version? (Required)