mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-18 19:01:50 +02:00
feat: add option --include-tests for diff and apply command (#1179)
Co-authored-by: Raymond Liu (RD-TW) <raymond_liu@trend.com.tw>
This commit is contained in:
co-authored by
Raymond Liu
parent
486be0970d
commit
71635caace
+1
-1
@@ -812,7 +812,7 @@ func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) {
|
||||
|
||||
// TODO Better way to detect diff on only filtered releases
|
||||
{
|
||||
changedReleases, planningErrs = st.DiffReleases(helm, c.Values(), c.Concurrency(), detailedExitCode, c.SuppressSecrets(), c.SuppressDiff(), false, diffOpts)
|
||||
changedReleases, planningErrs = st.DiffReleases(helm, c.Values(), c.Concurrency(), detailedExitCode, c.IncludeTests(), c.SuppressSecrets(), c.SuppressDiff(), false, diffOpts)
|
||||
|
||||
var err error
|
||||
deletingReleases, err = st.DetectReleasesToBeDeletedForSync(helm, st.Releases)
|
||||
|
||||
@@ -2000,6 +2000,7 @@ type applyConfig struct {
|
||||
set []string
|
||||
validate bool
|
||||
skipDeps bool
|
||||
includeTests bool
|
||||
suppressSecrets bool
|
||||
suppressDiff bool
|
||||
noColor bool
|
||||
@@ -2030,6 +2031,10 @@ func (a applyConfig) SkipDeps() bool {
|
||||
return a.skipDeps
|
||||
}
|
||||
|
||||
func (a applyConfig) IncludeTests() bool {
|
||||
return a.includeTests
|
||||
}
|
||||
|
||||
func (a applyConfig) SuppressSecrets() bool {
|
||||
return a.suppressSecrets
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ type ApplyConfigProvider interface {
|
||||
Set() []string
|
||||
SkipDeps() bool
|
||||
|
||||
IncludeTests() bool
|
||||
|
||||
SuppressSecrets() bool
|
||||
SuppressDiff() bool
|
||||
|
||||
@@ -73,6 +75,8 @@ type DiffConfigProvider interface {
|
||||
Set() []string
|
||||
SkipDeps() bool
|
||||
|
||||
IncludeTests() bool
|
||||
|
||||
SuppressSecrets() bool
|
||||
SuppressDiff() bool
|
||||
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ func (r *Run) Diff(c DiffConfigProvider) []error {
|
||||
NoColor: c.NoColor(),
|
||||
Set: c.Set(),
|
||||
}
|
||||
_, errs := st.DiffReleases(helm, c.Values(), c.Concurrency(), c.DetailedExitcode(), c.SuppressSecrets(), c.SuppressDiff(), true, opts)
|
||||
_, errs := st.DiffReleases(helm, c.Values(), c.Concurrency(), c.DetailedExitcode(), c.IncludeTests(), c.SuppressSecrets(), c.SuppressDiff(), true, opts)
|
||||
|
||||
return errs
|
||||
}
|
||||
|
||||
+7
-3
@@ -951,7 +951,7 @@ type diffPrepareResult struct {
|
||||
errors []*ReleaseError
|
||||
}
|
||||
|
||||
func (st *HelmState) prepareDiffReleases(helm helmexec.Interface, additionalValues []string, concurrency int, detailedExitCode, suppressSecrets bool, opt ...DiffOpt) ([]diffPrepareResult, []error) {
|
||||
func (st *HelmState) prepareDiffReleases(helm helmexec.Interface, additionalValues []string, concurrency int, detailedExitCode, includeTests, suppressSecrets bool, opt ...DiffOpt) ([]diffPrepareResult, []error) {
|
||||
opts := &DiffOpts{}
|
||||
for _, o := range opt {
|
||||
o.Apply(opts)
|
||||
@@ -1014,6 +1014,10 @@ func (st *HelmState) prepareDiffReleases(helm helmexec.Interface, additionalValu
|
||||
flags = append(flags, "--detailed-exitcode")
|
||||
}
|
||||
|
||||
if includeTests {
|
||||
flags = append(flags, "--include-tests")
|
||||
}
|
||||
|
||||
if suppressSecrets {
|
||||
flags = append(flags, "--suppress-secrets")
|
||||
}
|
||||
@@ -1099,13 +1103,13 @@ type DiffOpt interface{ Apply(*DiffOpts) }
|
||||
|
||||
// DiffReleases wrapper for executing helm diff on the releases
|
||||
// It returns releases that had any changes
|
||||
func (st *HelmState) DiffReleases(helm helmexec.Interface, additionalValues []string, workerLimit int, detailedExitCode, suppressSecrets bool, suppressDiff bool, triggerCleanupEvents bool, opt ...DiffOpt) ([]ReleaseSpec, []error) {
|
||||
func (st *HelmState) DiffReleases(helm helmexec.Interface, additionalValues []string, workerLimit int, detailedExitCode, includeTests, suppressSecrets, suppressDiff, triggerCleanupEvents bool, opt ...DiffOpt) ([]ReleaseSpec, []error) {
|
||||
opts := &DiffOpts{}
|
||||
for _, o := range opt {
|
||||
o.Apply(opts)
|
||||
}
|
||||
|
||||
preps, prepErrs := st.prepareDiffReleases(helm, additionalValues, workerLimit, detailedExitCode, suppressSecrets, opts)
|
||||
preps, prepErrs := st.prepareDiffReleases(helm, additionalValues, workerLimit, detailedExitCode, includeTests, suppressSecrets, opts)
|
||||
if len(prepErrs) > 0 {
|
||||
return []ReleaseSpec{}, prepErrs
|
||||
}
|
||||
|
||||
@@ -1391,7 +1391,7 @@ func TestHelmState_DiffReleases(t *testing.T) {
|
||||
logger: logger,
|
||||
valsRuntime: valsRuntime,
|
||||
}
|
||||
_, errs := state.DiffReleases(tt.helm, []string{}, 1, false, false, false, false)
|
||||
_, errs := state.DiffReleases(tt.helm, []string{}, 1, false, false, false, false, false)
|
||||
if errs != nil && len(errs) > 0 {
|
||||
t.Errorf("unexpected error: %v", errs)
|
||||
}
|
||||
@@ -1556,7 +1556,7 @@ func TestHelmState_DiffReleasesCleanup(t *testing.T) {
|
||||
`,
|
||||
})
|
||||
state = injectFs(state, testfs)
|
||||
if _, errs := state.DiffReleases(tt.helm, []string{}, 1, false, false, false, false); errs != nil && len(errs) > 0 {
|
||||
if _, errs := state.DiffReleases(tt.helm, []string{}, 1, false, false, false, false, false); errs != nil && len(errs) > 0 {
|
||||
t.Errorf("unexpected errors: %v", errs)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user