mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-18 02:55:22 +00:00
Merge pull request #2181 from phanimarupaka/FieldOptionalForSetter
Make field optional flag for create setter
This commit is contained in:
@@ -38,7 +38,6 @@ func NewCreateSetterRunner(parent string) *CreateSetterRunner {
|
||||
"create a partial setter for only part of the field value.")
|
||||
fixDocs(parent, set)
|
||||
set.MarkFlagRequired("type")
|
||||
set.MarkFlagRequired("field")
|
||||
r.Command = set
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -55,8 +55,9 @@ func (m *customFieldSetter) Filter(object *yaml.RNode) (*yaml.RNode, error) {
|
||||
return node.PipeE(m)
|
||||
})
|
||||
case yaml.ScalarNode:
|
||||
// only create the setter for fields with the given name
|
||||
if m.currentFieldName != m.Field {
|
||||
// if filed is empty, create the setter for all fields with given value
|
||||
// else only create the setter for given field and value combination, with given name
|
||||
if m.Field != "" && m.currentFieldName != m.Field {
|
||||
return object, nil
|
||||
}
|
||||
if err := m.create(object); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user