From aab80f0d5e2e689a8f16a1578fc91578ef5cc400 Mon Sep 17 00:00:00 2001 From: Bogusz Przybyslawski Date: Wed, 12 Jul 2023 16:43:50 +0200 Subject: [PATCH] Add possibility to specify flux path --- third_party/flux/cmd_manager.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/third_party/flux/cmd_manager.go b/third_party/flux/cmd_manager.go index 1127f5c3..ca6da3d6 100644 --- a/third_party/flux/cmd_manager.go +++ b/third_party/flux/cmd_manager.go @@ -50,6 +50,7 @@ const ( type Manager struct { e *gexe.Echo kubeConfig string + path string } type Option func(*Opts) @@ -112,7 +113,11 @@ func WithArgs(args ...string) Option { } func (m *Manager) run(opts *Opts) (err error) { - if m.e.Prog().Avail("flux") == "" { + executable := "flux" + if m.path != "" { + executable = m.path + } + if m.e.Prog().Avail(executable) == "" { err = fmt.Errorf("'flux' command is missing. Please ensure the tool exists before using the flux manager") return } @@ -210,3 +215,9 @@ func (m *Manager) deleteKustomization(name string, opts ...Option) error { o.name = name return m.run(o) } + +// WithPath is used to provide a custom path where the `flux` executable command can be found +func (m *Manager) WithPath(path string) *Manager { + m.path = path + return m +}