Skip to content

Commit

Permalink
return directly from switch case in add_or_update_change.go
Browse files Browse the repository at this point in the history
  • Loading branch information
cppforlife committed Jul 13, 2020
1 parent 4b3ccbb commit bfb08a4
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions pkg/kapp/clusterapply/add_or_update_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ func (c AddOrUpdateChange) Apply() error {
return err
}

err = c.recordAppliedResource(createdRes)
if err != nil {
return err
}
return c.recordAppliedResource(createdRes)

case createStrategyFallbackOnUpdateAnnValue:
createdRes, err := c.identifiedResources.Create(newRes)
Expand All @@ -66,10 +63,7 @@ func (c AddOrUpdateChange) Apply() error {
return err
}

err = c.recordAppliedResource(createdRes)
if err != nil {
return err
}
return c.recordAppliedResource(createdRes)

default:
return fmt.Errorf("Unknown create strategy: %s", strategy)
Expand All @@ -93,10 +87,7 @@ func (c AddOrUpdateChange) Apply() error {
return err
}

err = c.recordAppliedResource(updatedRes)
if err != nil {
return err
}
return c.recordAppliedResource(updatedRes)

case updateStrategyFallbackOnReplaceAnnValue:
replaceIfIsInvalidErrFunc := func(err error) error {
Expand All @@ -114,20 +105,18 @@ func (c AddOrUpdateChange) Apply() error {
return replaceIfIsInvalidErrFunc(err)
}

err = c.recordAppliedResource(updatedRes)
if err != nil {
return err
}
return c.recordAppliedResource(updatedRes)

case updateStrategyAlwaysReplaceAnnValue:
return c.replace()

default:
return fmt.Errorf("Unknown update strategy: %s", strategy)
}
}

return nil
default:
return fmt.Errorf("Unknown add-or-update op: %s", op)
}
}

func (c AddOrUpdateChange) replace() error {
Expand Down

0 comments on commit bfb08a4

Please sign in to comment.