fea(#507): support assign `--post-renderer` and `--post-renderer-args` within args in helmDefaults when use helm v3
Signed-off-by: guofutan <guofutan@tencent.com> Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
parent
a6df2f8148
commit
7be64f29cf
|
|
@ -36,6 +36,7 @@ type execer struct {
|
|||
logger *zap.SugaredLogger
|
||||
kubeContext string
|
||||
extra []string
|
||||
postRenderers []string
|
||||
decryptedSecretMutex sync.Mutex
|
||||
decryptedSecrets map[string]*decryptedSecret
|
||||
writeTempFile func([]byte) (string, error)
|
||||
|
|
@ -131,7 +132,19 @@ func New(helmBinary string, enableLiveOutput bool, logger *zap.SugaredLogger, ku
|
|||
}
|
||||
|
||||
func (helm *execer) SetExtraArgs(args ...string) {
|
||||
helm.extra = args
|
||||
var extraArgs []string
|
||||
|
||||
// reset the postRenderers and filter the post-renderer args from args and put into helm.postRenderers
|
||||
helm.postRenderers = nil
|
||||
for _, arg := range args {
|
||||
if strings.HasPrefix(arg, "--post-renderer=") || strings.HasPrefix(arg, "--post-renderer-args=") {
|
||||
helm.postRenderers = append(helm.postRenderers, arg)
|
||||
continue
|
||||
}
|
||||
extraArgs = append(extraArgs, arg)
|
||||
}
|
||||
|
||||
helm.extra = extraArgs
|
||||
}
|
||||
|
||||
func (helm *execer) SetHelmBinary(bin string) {
|
||||
|
|
@ -250,6 +263,10 @@ func (helm *execer) SyncRelease(context HelmContext, name, chart string, flags .
|
|||
} else {
|
||||
env["HELM_TILLER_HISTORY_MAX"] = strconv.Itoa(context.HistoryMax)
|
||||
}
|
||||
|
||||
if helm.IsHelm3() {
|
||||
flags = append(flags, helm.postRenderers...)
|
||||
}
|
||||
|
||||
out, err := helm.exec(append(append(preArgs, "upgrade", "--install", name, chart), flags...), env, nil)
|
||||
helm.write(nil, out)
|
||||
|
|
@ -390,6 +407,10 @@ func (helm *execer) TemplateRelease(name string, chart string, flags ...string)
|
|||
args = []string{"template", chart, "--name", name}
|
||||
}
|
||||
|
||||
if helm.IsHelm3() {
|
||||
flags = append(flags, helm.postRenderers...)
|
||||
}
|
||||
|
||||
out, err := helm.exec(append(args, flags...), map[string]string{}, nil)
|
||||
|
||||
var outputToFile bool
|
||||
|
|
|
|||
Loading…
Reference in New Issue