fix panic issue (#690)

This commit is contained in:
yxxhero 2023-02-10 07:32:08 +08:00 committed by GitHub
parent 2d98bba1a1
commit 65eca3337e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -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...)

View File

@ -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 {