-
Notifications
You must be signed in to change notification settings - Fork 349
Description
Originally opened by @pblkt in cuelang/cue#40
The behavior of struct unification specified as
The successful unification of structs
aandbis a new structcwhich has all fields of bothaandb
Cannot define an upper bound for structs. Specifically, CUE cannot help us verify that the resulting expression is limited to allowed fields.
For example, the unification
base: {
onlyViableField: string | *"myDefault"
}
{
base & {onlyViableFeild: "nonDefaultValue"}
}
yields
{
onlyViableField: "myDefault"
onlyViableFeild: "nonDefaultValue"
}
In kubernetes, the existence of extraneous fields causes failure when kubectl applys the resulting YAML, whereas in other systems the expression above could use silently use the default value erroneously.
When comparing CUE to a typed configuration language (like dhall), this is a qualitative difference in capabilities, since the extraneous field would be found by explicitly typing the result.
Extraneous fields can be hard to find - especially in large, opaque, auto-generated config schemes.