Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep hidden fields in std.prune #1174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stdlib/std.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ limitations under the License.
[std.prune(x) for x in a if isContent($.prune(x))]
else if std.isObject(a) then {
[x]: $.prune(a[x])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way, every hidden field will be unhidden, and this will be a breaking change.

Also, fields referencing self/super will be frozen, and I don't think this is an useful thing after that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about these other options?

  1. std.prune(a, keep_hidden=false)
  2. std.prune(a, arrays=true, objects=true, nulls=true, hidden=true)
  3. std.pruneEx(a, arrays=true, objects=true, nulls=true, hidden=true)

Showing the default-state function headers here, users would then be able to override whatever they want to be pruned or not.

for x in std.objectFields(a)
for x in std.objectFieldsAll(a)
if isContent(std.prune(a[x]))
} else
a,
Expand Down