-
Hello, I would like to generate k8s configuration but I fail continuously with error messages about mismatched types. cue eval .\objects\... I get kubernetes.secrets.secret1.metadata.name: 2 errors in empty disjunction:
kubernetes.secrets.secret1.metadata.name: conflicting values "secret1" and {name:(string|*Name),key:(string & !=""),value:(string & !="")} (mismatched types string and struct):
.\main.cue:14:10
.\main.cue:22:26
.\main.cue:23:19
.\main.cue:32:2
.\main.cue:32:31
kubernetes.secrets.secret1.metadata.name: conflicting values string and {name:(string|*Name),key:(string & !=""),value:(string & !="")} (mismatched types string and struct):
.\main.cue:14:10
.\main.cue:22:26
.\main.cue:23:9
.\main.cue:32:2
.\main.cue:32:31
kubernetes.secrets.secret2.metadata.name: 2 errors in empty disjunction:
kubernetes.secrets.secret2.metadata.name: conflicting values "secret2" and {name:(string|*Name),key:(string & !=""),value:(string & !="")} (mismatched types string and struct):
.\main.cue:14:10
.\main.cue:22:26
.\main.cue:23:19
.\main.cue:32:2
.\main.cue:32:31
kubernetes.secrets.secret2.metadata.name: conflicting values string and {name:(string|*Name),key:(string & !=""),value:(string & !="")} (mismatched types string and struct):
.\main.cue:14:10
.\main.cue:22:26
.\main.cue:23:9
.\main.cue:32:2
.\main.cue:32:31
What am I doing wrong/where is my misunderstanding? Here is my simplified example: main.cue main.cue #SecretConfig: [Name=_]: {
name: string | *Name
key: string & !=""
value: string & !=""
}
#Secret: {
config: #SecretConfig
kubernetes: {// todo corev1.#Secret &
apiVersion: "v1"
kind: "Secret"
metadata: {
name: config.name
}
// data: {
// "\(config.key)": config.value
// }
}
}
config: #SecretConfig
kubernetes: secrets: {
for k, v in config { "\(k)": (#Secret & {config: v}).kubernetes }
}
objects: [for set in objectSets for item in set {item}]
objectSets: [
kubernetes.secrets
]
secret1.cue config : secret1: {
key: "foo"
value: "bar"
} secret2.cue config : secret2: {
key: "foo2"
value: "bar2"
} Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Answered by
rozaliev
Feb 23, 2024
Replies: 1 comment 1 reply
-
Quick fix: #SecretConfig: [Name=_]: #SecretConfigItem & {name: Name}
#SecretConfigItem: {
name: string
key: string & !=""
value: string & !=""
}
#Secret: {
config: #SecretConfigItem
... You have a struct containing multiple items, where |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ptr1120
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quick fix:
You have a struct containing multiple items, where
#Secret
expects a single input.