-
Using I'm trying to provide a "new default value" for a nested definition and the error message is slightly confusing. Is there a more natural way to achieve this? E.g.: I want a new definition package foobar
#AB: {
"a"
} | {
b: #B
}
#B: {
bf: string | *"default"
}
#Foo: {
// This works:
//bar: {b: #B & {bf: "newDefault"}}
// $ cue eval foo.cue --out yaml
// bar:
// b:
// bf: newDefault
// This also works:
//bar: #AB
//
// $ cue eval foo.cue --out yaml
// bar:
// b:
// bf: default
//
// Doesn't work:
bar: #AB | {
b: #B & {bf: "newDefault"}
}
// $ cue vet -c foo.cue
// bar: incomplete value {b:{bf:*"default" | string}} | {b:{bf:"newDefault"}}
//
}
// I want to enforce a default value for "bf" via "& #Foo"
{
bar: b: #B
} & #Foo |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
In general, a good approach is to not have any defaults in the base template, and then add them later as one desires. In this case, the issue is that
|
Beta Was this translation helpful? Give feedback.
-
This discussion has been migrated to cue-lang/cue#989. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
Beta Was this translation helpful? Give feedback.
In general, a good approach is to not have any defaults in the base template, and then add them later as one desires.
In this case, the issue is that
bar
introduces a disjunction without a default. To ensure it "reaches" thenewDefault
value, you could write