-
I'm new to timoni and cuelang, but I'm excited about both! However, I'm struggling with how to implement a module where a container may be configured with multiple volumes. Typically, we see something like this: #Config: persistence: {
enabled: *true | bool
storageClass: *"standard" | string
size: *"8Gi" | string
}
#Instance: {
config: #Config
objects: {
pvc: #PersistentVolumeClaim & {#config: config}
}
} For my purposes I need to have two volumes: data and config. So I model it this way: #Config: {
persistence: [Name=_]: {
enabled: *false | bool
mountPath: *"/\(Name)" | string
hostPath?: string
storageClass: *"standard" | string
size: *"1Gi" | string
}
persistence: config: {}
persistence: data: {}
} Then in my volumeMounts: [
for k, v in #config.persistence if v.enabled {
{name: k, mountPath: v.mountPath}
},
] What I'm struggling with is how to loop to create the for k, v in config.persistence if v.enabled {
"\(k)": #PersistentVolumeClaim & {
#config: config
#name: k
#spec: {
resources: requests: storage: v.size
storageClassName: v.storageClass
volumeName: "\(config.metadata.name)-\(k)"
}
}
} But I can't use that
How do I do this? Since |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Never mind, I guess I solved my problem after finding #369 Now I'm doing this and it works for me: #PersistentVolumeClaim: corev1.#PersistentVolumeClaim & {
#config: #Config
#pvcName: string
#spec: corev1.#PersistentVolumeClaimSpec
apiVersion: "core/v1"
kind: "PersistentVolumeClaim"
metadata: {name: #pvcName} & {
for k, v in #config.metadata if k != "name" {
"\(k)": v
}
} |
Beta Was this translation helpful? Give feedback.
Never mind, I guess I solved my problem after finding #369
Now I'm doing this and it works for me: