Skip to content

Instantly share code, notes, and snippets.

@mkmik
Last active July 22, 2023 00:02
Show Gist options
  • Save mkmik/1156e8bfa45b9129c592dd4a6a4b04ac to your computer and use it in GitHub Desktop.
Save mkmik/1156e8bfa45b9129c592dd4a6a4b04ac to your computer and use it in GitHub Desktop.
local to_overlay = import 'to_overlay.libsonnet';
{
a: {
b: {
c: 1,
d: self.c,
h:: 42,
},
},
} + to_overlay.toOverlay(std.parseYaml(|||
a:
b:
c: 10
|||)) + {
a+: {
b+: {
answer: self.h,
},
},
}
{
toOverlay(v):: local t = std.type(v); if t == 'object' then {
[kv.key]+: $.toOverlay(kv.value)
for kv in std.objectKeysValues(v)
if std.type(kv.value) == 'object'
} + {
[kv.key]: kv.value
for kv in std.objectKeysValues(v)
if std.type(kv.value) != 'object'
} else v,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment