wire set 2.0 command

This commit is contained in:
Phillip Wittrock
2020-02-13 17:19:50 -08:00
parent 1ce469f1fd
commit 61cf3e6ec5
4 changed files with 362 additions and 7 deletions

View File

@@ -125,6 +125,10 @@ type SetOpenAPI struct {
Name string `yaml:"name"`
// Value is the current value of the setter
Value string `yaml:"value"`
Description string `yaml:"description"`
SetBy string `yaml:"setBy"`
}
// UpdateFile updates the OpenAPI definitions in a file with the given setter value.
@@ -146,5 +150,22 @@ func (s SetOpenAPI) Filter(object *yaml.RNode) (*yaml.RNode, error) {
return nil, err
}
if s.SetBy != "" {
if err := def.PipeE(&yaml.FieldSetter{Name: "setBy", StringValue: s.SetBy}); err != nil {
return nil, err
}
}
if s.Description != "" {
d, err := object.Pipe(yaml.LookupCreate(
yaml.MappingNode, "openAPI", "definitions", key))
if err != nil {
return nil, err
}
if err := d.PipeE(&yaml.FieldSetter{Name: "description", StringValue: s.Description}); err != nil {
return nil, err
}
}
return object, nil
}