mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
fix: patch additions honor source key style
When a patch appends a new node, it should honor the key style from the patch. Prior to this commit, no style was applied, leading to problems when the key value could be interpreted as a different type based on its content. For example, "9110" needs quoting to ensure it is seen as a string in yaml.
This commit is contained in:
@@ -690,6 +690,10 @@ type FieldSetter struct {
|
||||
// when setting it. Otherwise, if an existing node is found, the style is
|
||||
// retained.
|
||||
OverrideStyle bool `yaml:"overrideStyle,omitempty"`
|
||||
|
||||
// AppendKeyStyle defines the style of the key when no existing node is
|
||||
// found, and a new node is appended.
|
||||
AppendKeyStyle Style `yaml:"appendKeyStyle,omitempty"`
|
||||
}
|
||||
|
||||
func (s FieldSetter) Filter(rn *RNode) (*RNode, error) {
|
||||
@@ -747,6 +751,7 @@ func (s FieldSetter) Filter(rn *RNode) (*RNode, error) {
|
||||
&yaml.Node{
|
||||
Kind: yaml.ScalarNode,
|
||||
Value: s.Name,
|
||||
Style: s.AppendKeyStyle,
|
||||
HeadComment: s.Comments.HeadComment,
|
||||
LineComment: s.Comments.LineComment,
|
||||
FootComment: s.Comments.FootComment,
|
||||
|
||||
Reference in New Issue
Block a user