-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 empty map in kustomize output #2805
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,8 +167,8 @@ spec: {} | |
expected: ` | ||
kind: Deployment | ||
spec: | ||
foo: bar1 | ||
baz: buz | ||
foo: bar1 | ||
`, | ||
}, | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,16 +44,17 @@ func IsMissingOrNull(node *RNode) bool { | |
return node == nil || node.YNode() == nil || node.YNode().Tag == NullNodeTag | ||
} | ||
|
||
// IsEmpty returns true if the RNode is MissingOrNull, or is either a MappingNode with | ||
// no fields. | ||
// IsEmpty returns true if the RNode is MissingOrNull | ||
func IsEmpty(node *RNode) bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It now seems we have:
This feels random. And we have this strange contest between We've not hit 1.0 yet, so we can change the API. How about we try:
with this, the tags are hidden, and we start a pattern where Translation:
The compiler can optimize away redundancy. So L54 in
becomes
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds good. But because these methods are fundamental and widely used so if we change them, we need to update a lot of files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about create another issue about this refactoring? |
||
if IsMissingOrNull(node) { | ||
return IsMissingOrNull(node) | ||
} | ||
|
||
// IsEmptyMap returns true if the RNode is an empty node or an empty map | ||
func IsEmptyMap(node *RNode) bool { | ||
if IsEmpty(node) { | ||
return true | ||
} | ||
|
||
// Empty sequence is a special case and temporarily not considered as empty here. | ||
// Some users may want to keep empty sequence for compatibility reason. | ||
// For example, use JSON 6902 patch. | ||
return node.YNode().Kind == yaml.MappingNode && len(node.YNode().Content) == 0 | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this PR also retains scalar nulls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This null is in input. Because
{}
is not considered as empty so onlynull
can be used as empty in input.