go-jsonnet/testdata/builtinObjectRemoveKey_super_assert.jsonnet
John Bartholomew 8d4b3b72ab reimplement builtinObjectRemoveKey to support inheritance
This follows the same pattern as I used for the C++ implementation.
Flattening the object is probably also possible, but I think it would
involve binding references to 'super' iff they are satisfied by fields
in existing ancestors and leaving them unbound if they're unsatisfied
so that they can be late-bound by extending the output object.

That seems at least as complicated as defining a new form of
uncachedObject to represent a key-removal operation.

For https://github.com/google/go-jsonnet/issues/830
2026-01-29 20:12:46 +00:00

12 lines
207 B
Jsonnet

local o1 = {
assert self.x : 'x',
assert super.y : 'y',
b: super.a,
};
local o2 = {
x: true,
y: true,
a: 'one',
};
{ a: 'begin' } + std.objectRemoveKey({ y: std.isString('yyy') } + o1 + o2, 'x')