Merge pull request #2181 from phanimarupaka/FieldOptionalForSetter

Make field optional flag for create setter
This commit is contained in:
Kubernetes Prow Robot
2020-02-05 12:47:55 -08:00
committed by GitHub
2 changed files with 3 additions and 3 deletions

View File

@@ -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
}

View File

@@ -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 {