From 65eca3337ed9f28572020131d25738e8376f92e5 Mon Sep 17 00:00:00 2001 From: yxxhero <11087727+yxxhero@users.noreply.github.com> Date: Fri, 10 Feb 2023 07:32:08 +0800 Subject: [PATCH] fix panic issue (#690) --- pkg/app/app.go | 5 ++++- pkg/app/run.go | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/app/app.go b/pkg/app/app.go index 9a8a64a1..69de4bc4 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -943,7 +943,10 @@ func (a *App) ForEachState(do func(*Run) (bool, []error), includeTransitiveNeeds err := a.visitStatesWithSelectorsAndRemoteSupport(a.FileOrDir, func(st *state.HelmState) (bool, []error) { helm := a.getHelm(st) - run := NewRun(st, helm, ctx) + run, err := NewRun(st, helm, ctx) + if err != nil { + return false, []error{err} + } return do(run) }, includeTransitiveNeeds, o...) diff --git a/pkg/app/run.go b/pkg/app/run.go index 61ac86f6..c7ab9093 100644 --- a/pkg/app/run.go +++ b/pkg/app/run.go @@ -21,16 +21,16 @@ type Run struct { Ask func(string) bool } -func NewRun(st *state.HelmState, helm helmexec.Interface, ctx Context) *Run { +func NewRun(st *state.HelmState, helm helmexec.Interface, ctx Context) (*Run, error) { if helm == nil { - panic("Assertion failed: helmexec.Interface must not be nil") + return nil, fmt.Errorf("Assertion failed: helmexec.Interface must not be nil") } if !helm.IsHelm3() { - panic("helmfile has deprecated helm2 since v1.0") + return nil, fmt.Errorf("helmfile has deprecated helm2 since v0.150.0") } - return &Run{state: st, helm: helm, ctx: ctx} + return &Run{state: st, helm: helm, ctx: ctx}, nil } func (r *Run) askForConfirmation(msg string) bool {