Skip to content
Snippets Groups Projects
Commit e9552392 authored by Florent Aide's avatar Florent Aide
Browse files

docstrings and small renamings

parent 5ddd47ba
No related branches found
No related tags found
No related merge requests found
Pipeline #38194 passed
......@@ -27,7 +27,7 @@
func Run() int {
if _, err := parser.Parse(); err != nil {
code := 1
if fe, ok := err.(*flags.Error); ok {
if fe, ok := err.(*flags.Error); ok { // nolint:errorlint
if fe.Type == flags.ErrHelp {
code = 0
// this error actually contains a help message for the user
......
......@@ -19,6 +19,7 @@
defaultDirMod os.FileMode = 0700
)
// Runner is the struct in charge of launching commands
type Runner struct {
config *CmdConfig
}
......@@ -129,7 +130,6 @@
Str("stderr", strings.Join(stdErr, "\n")).
Msg("failed to run command")
// TODO: print error to stderr
// Error message must be pretty printed to end users
fmt.Printf("\n%s\n\n", strings.Join(stdErr, "\n"))
return fmt.Errorf("failed to run command: %w", err)
......@@ -162,4 +162,6 @@
return nil
}
// YamlSplit takes a buildDier and an inputFile.
// it returns a list of yaml documents and an eventual error
func YamlSplit(buildDir, inputFile string) ([]string, error) {
......@@ -165,7 +167,7 @@
func YamlSplit(buildDir, inputFile string) ([]string, error) {
var splitted []string
var docs []string
var allResources []map[string]interface{}
input, err := os.ReadFile(inputFile)
if err != nil {
return nil, err
}
......@@ -167,9 +169,9 @@
var allResources []map[string]interface{}
input, err := os.ReadFile(inputFile)
if err != nil {
return nil, err
}
if err := UnmarshalAllResources(input, &allResources); err != nil {
if err := unmarshalAllResources(input, &allResources); err != nil {
return nil, err
}
for _, resource := range allResources {
......@@ -203,6 +205,6 @@
if err := os.WriteFile(fPath, content, defaultFileMod); err != nil {
return nil, fmt.Errorf("cannot write resource: %w", err)
}
splitted = append(splitted, fPath)
docs = append(docs, fPath)
}
......@@ -207,5 +209,5 @@
}
return splitted, nil
return docs, nil
}
......@@ -210,6 +212,6 @@
}
func UnmarshalAllResources(in []byte, out *[]map[string]interface{}) error {
func unmarshalAllResources(in []byte, out *[]map[string]interface{}) error {
r := bytes.NewReader(in)
decoder := yaml.NewDecoder(r)
for {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment