Skip to content

Commit

Permalink
refactor: onelines for err only returns
Browse files Browse the repository at this point in the history
  • Loading branch information
matty-rose committed Oct 9, 2021
1 parent 7a8be78 commit d8c59ef
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions pkg/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,19 @@ func Parse(filename string) (*types.CompositeAction, error) {

data := make(map[interface{}]interface{})

err = yaml.Unmarshal(file, &data)
if err != nil {
if err := yaml.Unmarshal(file, &data); err != nil {
return nil, errors.Wrap(err, "failed unmarshalling yaml data")
}

var action types.CompositeAction

parseMetadata(&action, data)

err = parseInputs(&action, data)
if err != nil {
if err := parseInputs(&action, data); err != nil {
return nil, err
}

err = parseOutputs(&action, data)
if err != nil {
if err := parseOutputs(&action, data); err != nil {
return nil, err
}

Expand All @@ -76,8 +73,7 @@ func parseInputs(action *types.CompositeAction, data map[interface{}]interface{}
for name, input := range inputs {
inp := types.Input{Name: name}

err := mapstructure.Decode(input, &inp)
if err != nil {
if err := mapstructure.Decode(input, &inp); err != nil {
return errors.Wrap(err, "failed parsing action input into struct")
}

Expand All @@ -96,8 +92,7 @@ func parseOutputs(action *types.CompositeAction, data map[interface{}]interface{
for name, output := range outputs {
out := types.Output{Name: name}

err := mapstructure.Decode(output, &out)
if err != nil {
if err := mapstructure.Decode(output, &out); err != nil {
return errors.Wrap(err, "failed parsing action output into struct")
}

Expand Down

0 comments on commit d8c59ef

Please sign in to comment.