feat: ignore

Implements ignoring certain keys right in Jsonnet, by adding:

  {
    '#foo': "ignore",
    foo: {}
  }

This is especially useful for objects that include `self` references,
which might otherwise recurse infinitely
This commit is contained in:
sh0rez 2020-05-12 22:48:02 +02:00
parent 14e9fc8f3f
commit 66a158a8f2
No known key found for this signature in database
GPG key ID: 87C71DF9F8181FF1
7 changed files with 85 additions and 46 deletions

View file

@ -12,6 +12,8 @@ local lib = {
local aux(old, key) =
if !std.isObject(pkg[key]) then
old
else if std.objectHasAll(pkg, '#' + key) && pkg['#' + key] == 'ignore' then
old
else if std.startsWith(key, '#') then
old { [key]: pkg[key] }
else if self.scan(pkg[key]) then
@ -21,4 +23,5 @@ local lib = {
std.foldl(aux, std.objectFieldsAll(pkg), {}),
};
lib.load(std.extVar('main'))