go fmt all tree

This commit is contained in:
Ron Green
2021-05-02 11:03:42 +03:00
committed by Louis DeLosSantos
parent 70e91a94b5
commit f089cd51f2
2 changed files with 49 additions and 49 deletions
+48 -48
View File
@@ -488,7 +488,7 @@ func ReadYmlInputFile(opts *CommonOptions, input interface{}, output interface{}
return err return err
} }
tmpFile = opts.File.String() tmpFile = opts.File.String()
// we need to copy the original output so that we can restore // we need to copy the original output so that we can restore
// it on retries in case we try to populate bogus fields that // it on retries in case we try to populate bogus fields that
@@ -499,57 +499,57 @@ func ReadYmlInputFile(opts *CommonOptions, input interface{}, output interface{}
return err return err
} }
// parse template // parse template
data, err := ioutil.ReadFile(tmpFile) data, err := ioutil.ReadFile(tmpFile)
if err != nil { if err != nil {
return err return err
} }
defer func(mapType, iface reflect.Type) { defer func(mapType, iface reflect.Type) {
yaml.DefaultMapType = mapType yaml.DefaultMapType = mapType
yaml.IfaceType = iface yaml.IfaceType = iface
}(yaml.DefaultMapType, yaml.IfaceType) }(yaml.DefaultMapType, yaml.IfaceType)
yaml.DefaultMapType = reflect.TypeOf(map[string]interface{}{}) yaml.DefaultMapType = reflect.TypeOf(map[string]interface{}{})
yaml.IfaceType = yaml.DefaultMapType.Elem() yaml.IfaceType = yaml.DefaultMapType.Elem()
// restore output incase of retry loop // restore output incase of retry loop
err = copier.Copy(output, dup.Interface()) err = copier.Copy(output, dup.Interface())
if err != nil { if err != nil {
return err return err
} }
// HACK HACK HACK we want to trim out all the yaml garbage that is not // HACK HACK HACK we want to trim out all the yaml garbage that is not
// poplulated, like empty arrays, string values with only a newline, // poplulated, like empty arrays, string values with only a newline,
// etc. We need to do this because jira will reject json documents // etc. We need to do this because jira will reject json documents
// with empty arrays, or empty strings typically. So here we process // with empty arrays, or empty strings typically. So here we process
// the data to a raw interface{} then we fixup the yaml parsed // the data to a raw interface{} then we fixup the yaml parsed
// interface, then we serialize to a new yaml document ... then is // interface, then we serialize to a new yaml document ... then is
// parsed as the original document to populate the output struct. Phew. // parsed as the original document to populate the output struct. Phew.
var raw interface{} var raw interface{}
if err := yaml.Unmarshal(data, &raw); err != nil { if err := yaml.Unmarshal(data, &raw); err != nil {
log.Error(err.Error()) log.Error(err.Error())
fmt.Printf("Invalid YAML syntax\n") fmt.Printf("Invalid YAML syntax\n")
return FileAbort return FileAbort
} }
yamlFixup(&raw) yamlFixup(&raw)
fixedYAML, err := yaml.Marshal(&raw) fixedYAML, err := yaml.Marshal(&raw)
if err != nil { if err != nil {
log.Error(err.Error()) log.Error(err.Error())
fmt.Printf("Invalid YAML syntax\n") fmt.Printf("Invalid YAML syntax\n")
return FileAbort return FileAbort
} }
if err := yaml.Unmarshal(fixedYAML, output); err != nil { if err := yaml.Unmarshal(fixedYAML, output); err != nil {
log.Error(err.Error()) log.Error(err.Error())
fmt.Printf("Invalid YAML syntax\n") fmt.Printf("Invalid YAML syntax\n")
return FileAbort return FileAbort
} }
// submit template // submit template
if err := submit(); err != nil { if err := submit(); err != nil {
log.Error(err.Error()) log.Error(err.Error())
fmt.Printf("Jira reported an error\n") fmt.Printf("Jira reported an error\n")
return FileAbort return FileAbort
} }
return nil return nil
} }
+1 -1
View File
@@ -20,8 +20,8 @@ import (
"github.com/coryb/figtree" "github.com/coryb/figtree"
shellquote "github.com/kballard/go-shellquote" shellquote "github.com/kballard/go-shellquote"
"github.com/mgutz/ansi" "github.com/mgutz/ansi"
"github.com/olekukonko/tablewriter"
wordwrap "github.com/mitchellh/go-wordwrap" wordwrap "github.com/mitchellh/go-wordwrap"
"github.com/olekukonko/tablewriter"
"golang.org/x/crypto/ssh/terminal" "golang.org/x/crypto/ssh/terminal"
) )