Add --kubeconfig flag (#1381)

add kubeconfig flag

Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
This commit is contained in:
Tim Ramlot
2024-03-01 20:26:54 +08:00
committed by GitHub
parent 7ccacb7ee5
commit 5910ce0b99
8 changed files with 105 additions and 81 deletions
+4 -1
View File
@@ -37,6 +37,7 @@ type App struct {
DisableForceUpdate bool
Logger *zap.SugaredLogger
Kubeconfig string
Env string
Namespace string
Chart string
@@ -81,6 +82,7 @@ func New(conf ConfigProvider) *App {
StripArgsValuesOnExitError: conf.StripArgsValuesOnExitError(),
DisableForceUpdate: conf.DisableForceUpdate(),
Logger: conf.Logger(),
Kubeconfig: conf.Kubeconfig(),
Env: conf.Env(),
Namespace: conf.Namespace(),
Chart: conf.Chart(),
@@ -789,12 +791,13 @@ func (a *App) getHelm(st *state.HelmState) helmexec.Interface {
}
bin := st.DefaultHelmBinary
kubeconfig := a.Kubeconfig
kubectx := st.HelmDefaults.KubeContext
key := createHelmKey(bin, kubectx)
if _, ok := a.helms[key]; !ok {
a.helms[key] = helmexec.New(bin, helmexec.HelmExecOptions{EnableLiveOutput: a.EnableLiveOutput, DisableForceUpdate: a.DisableForceUpdate}, a.Logger, kubectx, &helmexec.ShellRunner{
a.helms[key] = helmexec.New(bin, helmexec.HelmExecOptions{EnableLiveOutput: a.EnableLiveOutput, DisableForceUpdate: a.DisableForceUpdate}, a.Logger, kubeconfig, kubectx, &helmexec.ShellRunner{
Logger: a.Logger,
Ctx: a.ctx,
StripArgsValuesOnExitError: a.StripArgsValuesOnExitError,
+1 -1
View File
@@ -2441,7 +2441,7 @@ func (mock *mockRunner) Execute(cmd string, args []string, env map[string]string
}
func MockExecer(logger *zap.SugaredLogger, kubeContext string) helmexec.Interface {
execer := helmexec.New("helm", helmexec.HelmExecOptions{}, logger, kubeContext, &mockRunner{})
execer := helmexec.New("helm", helmexec.HelmExecOptions{}, logger, "", kubeContext, &mockRunner{})
return execer
}
+1
View File
@@ -18,6 +18,7 @@ type ConfigProvider interface {
Selectors() []string
StateValuesSet() map[string]any
StateValuesFiles() []string
Kubeconfig() string
Env() string
loggingConfig
+1 -1
View File
@@ -163,7 +163,7 @@ func (h *HelmfileInit) WhetherContinue(ask string) error {
func (h *HelmfileInit) CheckHelmPlugins() error {
settings := cli.New()
helm := helmexec.New(h.helmBinary, helmexec.HelmExecOptions{}, h.logger, "", h.runner)
helm := helmexec.New(h.helmBinary, helmexec.HelmExecOptions{}, h.logger, "", "", h.runner)
for _, p := range helmPlugins {
pluginVersion, err := helmexec.GetPluginVersion(p.name, settings.PluginsDirectory)
if err != nil {