diff --git a/pkg/app/desired_state_file_loader.go b/pkg/app/desired_state_file_loader.go index 31932a9d..d0c29d66 100644 --- a/pkg/app/desired_state_file_loader.go +++ b/pkg/app/desired_state_file_loader.go @@ -126,7 +126,20 @@ func (ld *desiredStateLoader) loadFileWithOverrides(inheritedEnv, overrodeEnv *e ) } - return self, err + if err != nil { + return nil, err + } + + for i, h := range self.Helmfiles { + if h.Path == f { + return nil, fmt.Errorf("%s contains a recursion into the same sub-helmfile at helmfiles[%d]", f, i) + } + if h.Path == "." { + return nil, fmt.Errorf("%s contains a recursion into the the directory containing this helmfile at helmfiles[%d]", f, i) + } + } + + return self, nil } func (a *desiredStateLoader) underlying() *state.StateCreator {