MCPcopy
hub / github.com/helmfile/helmfile / DiffReleases

Method DiffReleases

pkg/state/state.go:3000–3104  ·  view source on GitHub ↗

DiffReleases wrapper for executing helm diff on the releases It returns releases that had any changes, and errors if any. This function has responsibility to stabilize the order of writes to stdout from multiple concurrent helm-diff runs. It's required to use the stdout from helmfile-diff to detect

(helm helmexec.Interface, additionalValues []string, workerLimit int, detailedExitCode bool, stripTrailingCR bool, includeTests bool, suppress []string, suppressSecrets, showSecrets, noHooks bool, suppressDiff, triggerCleanupEvents bool, opt ...DiffOpt)

Source from the content-addressed store, hash-verified

2998// `terraform`, by design, fails when helmfile-diff outputs were not equivalent.
2999// Stabilized helmfile-diff output rescues that.
3000func (st *HelmState) DiffReleases(helm helmexec.Interface, additionalValues []string, workerLimit int, detailedExitCode bool, stripTrailingCR bool, includeTests bool, suppress []string, suppressSecrets, showSecrets, noHooks bool, suppressDiff, triggerCleanupEvents bool, opt ...DiffOpt) ([]ReleaseSpec, []error) {
3001 opts := &DiffOpts{}
3002 for _, o := range opt {
3003 o.Apply(opts)
3004 }
3005
3006 preps, prepErrs := st.prepareDiffReleases(helm, additionalValues, workerLimit, detailedExitCode, stripTrailingCR, includeTests, suppress, suppressSecrets, showSecrets, noHooks, opts)
3007
3008 if !opts.SkipCleanup {
3009 defer func() {
3010 for _, p := range preps {
3011 st.removeFiles(p.files)
3012 }
3013 }()
3014 }
3015
3016 if len(prepErrs) > 0 {
3017 return []ReleaseSpec{}, prepErrs
3018 }
3019
3020 jobQueue := make(chan *diffPrepareResult, len(preps))
3021 results := make(chan diffResult, len(preps))
3022
3023 rs := []ReleaseSpec{}
3024 outputs := map[string]*bytes.Buffer{}
3025 errs := []error{}
3026
3027 // The exit code returned by helm-diff when it detected any changes
3028 HelmDiffExitCodeChanged := 2
3029
3030 st.scatterGather(
3031 workerLimit,
3032 len(preps),
3033 func() {
3034 for i := 0; i < len(preps); i++ {
3035 jobQueue <- &preps[i]
3036 }
3037 close(jobQueue)
3038 },
3039 func(workerIndex int) {
3040 for prep := range jobQueue {
3041 flags := prep.flags
3042 release := prep.release
3043 buf := &bytes.Buffer{}
3044
3045 releaseSuppressDiff := suppressDiff
3046 if prep.suppressDiff {
3047 releaseSuppressDiff = true
3048 }
3049
3050 // Use ChartPath directly if already set (normalized during chart preparation),
3051 // otherwise normalize the original chart name.
3052 chartPath := release.ChartPathOrName()
3053 if release.ChartPath == "" {
3054 chartPath = normalizeChart(st.basePath, chartPath)
3055 }
3056
3057 if prep.upgradeDueToSkippedDiff {

Callers 3

diffMethod · 0.80

Calls 12

prepareDiffReleasesMethod · 0.95
removeFilesMethod · 0.95
scatterGatherMethod · 0.95
TriggerCleanupEventMethod · 0.95
normalizeChartFunction · 0.85
ReleaseToIDFunction · 0.85
ChartPathOrNameMethod · 0.80
ExitStatusMethod · 0.80
StringMethod · 0.80
ApplyMethod · 0.65
DiffReleaseMethod · 0.65

Tested by 2