Skip to content

Commit

Permalink
don't update set scalar args
Browse files Browse the repository at this point in the history
  • Loading branch information
shanalily committed Jan 31, 2022
1 parent ff186e7 commit 42c3731
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions api/filters/filtersutil/setters.go
Expand Up @@ -8,13 +8,20 @@ import (
type SetFn func(*yaml.RNode) error

// SetScalar returns a SetFn to set a scalar value
func SetScalar(value, tag string) SetFn {
func SetScalar(value string) SetFn {
return func(node *yaml.RNode) error {
return node.PipeE(yaml.FieldSetter{StringValue: value})
}
}

// SetString returns a SetFn to set a string value
func SetString(value string) SetFn {
n := &yaml.Node{
Kind: yaml.ScalarNode,
Value: value,
Tag: tag,
Tag: yaml.NodeTagString,
}
if tag == yaml.NodeTagString && yaml.IsYaml1_1NonString(n) {
if yaml.IsYaml1_1NonString(n) {
n.Style = yaml.DoubleQuotedStyle
}
return func(node *yaml.RNode) error {
Expand Down Expand Up @@ -55,8 +62,8 @@ func (s *TrackableSetter) WithMutationTracker(callback func(key, value, tag stri
// SetScalar returns a SetFn to set a scalar value
// if a mutation tracker has been registered, the tracker will be invoked each
// time a scalar is set
func (s TrackableSetter) SetScalar(value, tag string) SetFn {
origSetScalar := SetScalar(value, tag)
func (s TrackableSetter) SetScalar(value string) SetFn {
origSetScalar := SetScalar(value)
return func(node *yaml.RNode) error {
if s.setValueCallback != nil {
s.setValueCallback("", value, "", node)
Expand Down

0 comments on commit 42c3731

Please sign in to comment.