From 944a86bc3a649fc220992df360d67a39a1b498cf Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Wed, 13 Sep 2023 21:48:13 +0100 Subject: [PATCH] Inline errors Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- cmd/apps/grafana_app.go | 33 +++++++++++++-------------------- pkg/helm/helm.go | 1 - 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/cmd/apps/grafana_app.go b/cmd/apps/grafana_app.go index c25568644..eaf27a4ea 100644 --- a/cmd/apps/grafana_app.go +++ b/cmd/apps/grafana_app.go @@ -36,34 +36,28 @@ func MakeInstallGrafana() *cobra.Command { "Use custom flags or override existing flags \n(example --set persistence.enabled=true)") grafana.PreRunE = func(command *cobra.Command, args []string) error { - _, err := command.Flags().GetString("kubeconfig") - if err != nil { - return fmt.Errorf("error with --kubeconfig usage: %s", err) + if _, err := command.Flags().GetString("kubeconfig"); err != nil { + return fmt.Errorf("error with --kubeconfig usage: %w", err) } - _, err = command.Flags().GetBool("wait") - if err != nil { - return fmt.Errorf("error with --wait usage: %s", err) + if _, err := command.Flags().GetBool("wait"); err != nil { + return fmt.Errorf("error with --wait usage: %w", err) } - _, err = command.Flags().GetBool("persistence") - if err != nil { - return fmt.Errorf("error with --persistence usage: %s", err) + if _, err := command.Flags().GetBool("persistence"); err != nil { + return fmt.Errorf("error with --persistence usage: %w", err) } - _, err = command.Flags().GetString("namespace") - if err != nil { - return fmt.Errorf("error with --namespace usage: %s", err) + if _, err := command.Flags().GetString("namespace"); err != nil { + return fmt.Errorf("error with --namespace usage: %w", err) } - _, err = command.Flags().GetBool("update-repo") - if err != nil { - return fmt.Errorf("error with --update-repo usage: %s", err) + if _, err := command.Flags().GetBool("update-repo"); err != nil { + return fmt.Errorf("error with --update-repo usage: %w", err) } - _, err = command.Flags().GetStringArray("set") - if err != nil { - return fmt.Errorf("error with --set usage: %s", err) + if _, err := command.Flags().GetStringArray("set"); err != nil { + return fmt.Errorf("error with --set usage: %w", err) } return nil @@ -106,8 +100,7 @@ func MakeInstallGrafana() *cobra.Command { WithKubeconfigPath(kubeConfigPath). WithWait(wait) - _, err := apps.MakeInstallChart(grafanaAppOptions) - if err != nil { + if _, err := apps.MakeInstallChart(grafanaAppOptions); err != nil { return err } diff --git a/pkg/helm/helm.go b/pkg/helm/helm.go index aa1f8e348..38ea3bb5d 100644 --- a/pkg/helm/helm.go +++ b/pkg/helm/helm.go @@ -143,7 +143,6 @@ func AddHelmRepo(name, url string, update bool) error { StreamStdio: true, } res, err := task.Execute() - if err != nil { return err }