Skip to content

Commit

Permalink
Avoid repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
metal3d committed Apr 24, 2024
1 parent 451a134 commit 0aa7023
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions generator/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,18 @@ func Convert(config ConvertOptions, dockerComposeFile ...string) {
f.Write([]byte(notes))
f.Close()

if config.HelmUpdate {
if err := helmUpdate(config); err != nil {
fmt.Println(utils.IconFailure, err)
os.Exit(1)
} else if err := helmLint(config); err != nil {
executeAndHandleError := func(fn func(ConvertOptions) error, config ConvertOptions, message string) {
if err := fn(config); err != nil {
fmt.Println(utils.IconFailure, err)
os.Exit(1)
} else {
fmt.Println(utils.IconSuccess, "Helm chart created successfully")
}
fmt.Println(utils.IconSuccess, message)
}

if config.HelmUpdate {
executeAndHandleError(helmUpdate, config, "Helm dependencies updated")
executeAndHandleError(helmLint, config, "Helm chart linted")
fmt.Println(utils.IconSuccess, "Helm chart created successfully")
}
}

Expand Down

0 comments on commit 0aa7023

Please sign in to comment.