From 74cd2bc147155e25206da82ba5eb104e87e6ef00 Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Fri, 9 Apr 2021 09:49:57 +0900 Subject: [PATCH] Enable helmfile-deps to limit helm-dep-up by selector (#1764) Ref https://github.com/roboll/helmfile/issues/809#issuecomment-814423653 This is not what had been requested originally in #809 but anyway- This enables you to limit helm-dep-up run by helmfile-deps by selector. For example, `helmfile -l name=foo deps` should result in only the release named `foo` to be helm-dep-uped. --- pkg/state/state.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pkg/state/state.go b/pkg/state/state.go index 332b4984..fa347c10 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -2128,9 +2128,26 @@ func (st *HelmState) ResolveDeps() (*HelmState, error) { // UpdateDeps wrapper for updating dependencies on the releases func (st *HelmState) UpdateDeps(helm helmexec.Interface) []error { + var selected []ReleaseSpec + + if len(st.Selectors) > 0 { + var err error + + // This and releasesNeedCharts ensures that we run operations like helm-dep-build and prepare-hook calls only on + // releases that are (1) selected by the selectors and (2) to be installed. + selected, err = st.GetSelectedReleasesWithOverrides() + if err != nil { + return []error{err} + } + } else { + selected = st.Releases + } + + releases := releasesNeedCharts(selected) + var errs []error - for _, release := range st.Releases { + for _, release := range releases { if st.directoryExistsAt(release.Chart) { if err := helm.UpdateDeps(release.Chart); err != nil { errs = append(errs, err)