feat: add helm-unittest integration

This commit adds support for running helm-unittest on releases defined in helmfile.

Features:
- Add unittest command to run helm-unittest on releases
- Add unitTests field to release spec for specifying test directories
- Add helm-unittest plugin to init command
- Support for --values, --fail-fast, --color, --debug-plugin, --unittest-args flags
- Concurrent execution support
- Integration with needs/selectors like other commands

Example usage:
  helmfile unittest -e test
  helmfile unittest --fail-fast --color
  helmfile unittest --values values.yaml

Example helmfile.yaml:
  releases:
  - name: myapp
    chart: ./charts/myapp
    unitTests:
      - tests/

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero
2026-01-23 09:08:05 +08:00
parent 7500eef7c6
commit e9069679f6
12 changed files with 352 additions and 0 deletions
+11
View File
@@ -649,6 +649,17 @@ func (helm *execer) TemplateRelease(name string, chart string, flags ...string)
return err
}
func (helm *execer) UnittestRelease(context HelmContext, name, chart string, flags ...string) error {
helm.logger.Infof("Running unittest for release=%v, chart=%v", name, redactedURL(chart))
preArgs := make([]string, 0)
env := make(map[string]string)
var overrideEnableLiveOutput *bool = nil
out, err := helm.exec(append(append(preArgs, "unittest", chart), flags...), env, overrideEnableLiveOutput)
helm.write(context.Writer, out)
return err
}
func (helm *execer) DiffRelease(context HelmContext, name, chart, namespace string, suppressDiff bool, flags ...string) error {
diffMsg := fmt.Sprintf("Comparing release=%v, chart=%v, namespace=%v\n", name, redactedURL(chart), namespace)
if context.Writer != nil && !suppressDiff {
+1
View File
@@ -24,6 +24,7 @@ type Interface interface {
SyncRelease(context HelmContext, name, chart, namespace string, flags ...string) error
DiffRelease(context HelmContext, name, chart, namespace string, suppressDiff bool, flags ...string) error
TemplateRelease(name, chart string, flags ...string) error
UnittestRelease(context HelmContext, name, chart string, flags ...string) error
Fetch(chart string, flags ...string) error
ChartPull(chart string, path string, flags ...string) error
ChartExport(chart string, path string) error