Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending basePath to yamls renderer #981

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ func (a *App) within(dir string, do func() error) error {
return appErr
}

func (a *App) visitStateFiles(fileOrDir string, do func(string, string) error) error {
desiredStateFiles, err := a.findDesiredStateFiles(fileOrDir)
func (a *App) visitStateFiles(absFileOrDir string, do func(string, string) error) error {
desiredStateFiles, err := a.findDesiredStateFiles(absFileOrDir)
if err != nil {
return appError("", err)
}
Expand Down Expand Up @@ -299,17 +299,16 @@ func (a *App) loadDesiredStateFromYaml(file string, opts ...LoadOpts) (*state.He
return ld.Load(file, op)
}

func (a *App) visitStates(fileOrDir string, defOpts LoadOpts, converge func(*state.HelmState, helmexec.Interface) (bool, []error)) error {
func (a *App) visitStates(absFileOrDir string, defOpts LoadOpts, converge func(*state.HelmState, helmexec.Interface) (bool, []error)) error {
noMatchInHelmfiles := true

err := a.visitStateFiles(fileOrDir, func(f, d string) error {
err := a.visitStateFiles(absFileOrDir, func(f, d string) error {
opts := defOpts.DeepCopy()

if opts.CalleePath == "" {
opts.CalleePath = f
}

st, err := a.loadDesiredStateFromYaml(f, opts)
absFile := filepath.Join(d, f)
st, err := a.loadDesiredStateFromYaml(absFile, opts)

sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
Expand Down Expand Up @@ -399,7 +398,8 @@ func (a *App) visitStates(fileOrDir string, defOpts LoadOpts, converge func(*sta

func (a *App) ForEachStateFiltered(do func(*Run) []error) error {
ctx := NewContext()
err := a.VisitDesiredStatesWithReleasesFiltered(a.FileOrDir, func(st *state.HelmState, helm helmexec.Interface) []error {
absFileOrDir, err := a.abs(a.FileOrDir)
err = a.VisitDesiredStatesWithReleasesFiltered(absFileOrDir, func(st *state.HelmState, helm helmexec.Interface) []error {
run := NewRun(st, helm, ctx)

return do(run)
Expand All @@ -414,7 +414,11 @@ func (a *App) ForEachStateFiltered(do func(*Run) []error) error {

func (a *App) ForEachState(do func(*Run) (bool, []error)) error {
ctx := NewContext()
err := a.visitStatesWithSelectorsAndRemoteSupport(a.FileOrDir, func(st *state.HelmState, helm helmexec.Interface) (bool, []error) {
absFileOrDir, err := a.abs(a.FileOrDir)
if err != nil && a.ErrorHandler != nil {
return err
}
err = a.visitStatesWithSelectorsAndRemoteSupport(absFileOrDir, func(st *state.HelmState, helm helmexec.Interface) (bool, []error) {
run := NewRun(st, helm, ctx)
return do(run)
})
Expand Down Expand Up @@ -493,7 +497,7 @@ type Opts struct {
DAGEnabled bool
}

func (a *App) visitStatesWithSelectorsAndRemoteSupport(fileOrDir string, converge func(*state.HelmState, helmexec.Interface) (bool, []error)) error {
func (a *App) visitStatesWithSelectorsAndRemoteSupport(absFileOrDir string, converge func(*state.HelmState, helmexec.Interface) (bool, []error)) error {
opts := LoadOpts{
Selectors: a.Selectors,
}
Expand Down Expand Up @@ -532,7 +536,7 @@ func (a *App) visitStatesWithSelectorsAndRemoteSupport(fileOrDir string, converg

a.remote = remote

return a.visitStates(fileOrDir, opts, converge)
return a.visitStates(absFileOrDir, opts, converge)
}

func (a *App) Wrap(converge func(*state.HelmState, helmexec.Interface) []error) func(st *state.HelmState, helm helmexec.Interface) (bool, []error) {
Expand Down Expand Up @@ -570,10 +574,10 @@ func (a *App) Wrap(converge func(*state.HelmState, helmexec.Interface) []error)
}
}

func (a *App) VisitDesiredStatesWithReleasesFiltered(fileOrDir string, converge func(*state.HelmState, helmexec.Interface) []error) error {
func (a *App) VisitDesiredStatesWithReleasesFiltered(absFileOrDir string, converge func(*state.HelmState, helmexec.Interface) []error) error {
f := a.Wrap(converge)

return a.visitStatesWithSelectorsAndRemoteSupport(fileOrDir, func(st *state.HelmState, helm helmexec.Interface) (bool, []error) {
return a.visitStatesWithSelectorsAndRemoteSupport(absFileOrDir, func(st *state.HelmState, helm helmexec.Interface) (bool, []error) {
return f(st, helm)
})
}
Expand Down
Loading