Disable dependency update while running helm-x/chartify in more cases (#1548)
`helm dep up` is now skipped while running helm-x/chartify when the chart/directory is obtained by running go-getter, or `skipDeps` is configured using a command-line flag, helmDefaults, or release configuration. Resolves #1547
This commit is contained in:
		
							parent
							
								
									afb2653452
								
							
						
					
					
						commit
						0663831dd5
					
				|  | @ -104,6 +104,9 @@ helmDefaults: | ||||||
|   createNamespace: true |   createNamespace: true | ||||||
|   # if used with charts museum allows to pull unstable charts for deployment, for example: if 1.2.3 and 1.2.4-dev versions exist and set to true, 1.2.4-dev will be pulled (default false) |   # if used with charts museum allows to pull unstable charts for deployment, for example: if 1.2.3 and 1.2.4-dev versions exist and set to true, 1.2.4-dev will be pulled (default false) | ||||||
|   devel: true |   devel: true | ||||||
|  |   # When set to `true`, skips running `helm dep up` and `helm dep build` on this release's chart. | ||||||
|  |   # Useful when the chart is broken, like seen in https://github.com/roboll/helmfile/issues/1547 | ||||||
|  |   skipDeps: false | ||||||
| 
 | 
 | ||||||
| # these labels will be applied to all releases in a Helmfile. Useful in templating if you have a helmfile per environment or customer and don't want to copy the same label to each release | # these labels will be applied to all releases in a Helmfile. Useful in templating if you have a helmfile per environment or customer and don't want to copy the same label to each release | ||||||
| commonLabels: | commonLabels: | ||||||
|  | @ -193,6 +196,9 @@ releases: | ||||||
|     kubeContext: kube-context |     kubeContext: kube-context | ||||||
|     # limit the maximum number of revisions saved per release. Use 0 for no limit (default 10) |     # limit the maximum number of revisions saved per release. Use 0 for no limit (default 10) | ||||||
|     historyMax: 10 |     historyMax: 10 | ||||||
|  |     # When set to `true`, skips running `helm dep up` and `helm dep build` on this release's chart. | ||||||
|  |     # Useful when the chart is broken, like seen in https://github.com/roboll/helmfile/issues/1547 | ||||||
|  |     skipDeps: false | ||||||
| 
 | 
 | ||||||
|   # Local chart example |   # Local chart example | ||||||
|   - name: grafana                            # name of this release |   - name: grafana                            # name of this release | ||||||
|  |  | ||||||
							
								
								
									
										2
									
								
								go.mod
								
								
								
								
							
							
						
						
									
										2
									
								
								go.mod
								
								
								
								
							|  | @ -22,7 +22,7 @@ require ( | ||||||
| 	github.com/spf13/cobra v0.0.3 | 	github.com/spf13/cobra v0.0.3 | ||||||
| 	github.com/tatsushid/go-prettytable v0.0.0-20141013043238-ed2d14c29939 | 	github.com/tatsushid/go-prettytable v0.0.0-20141013043238-ed2d14c29939 | ||||||
| 	github.com/urfave/cli v1.20.0 | 	github.com/urfave/cli v1.20.0 | ||||||
| 	github.com/variantdev/chartify v0.4.4 | 	github.com/variantdev/chartify v0.4.8 | ||||||
| 	github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363 | 	github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363 | ||||||
| 	github.com/variantdev/vals v0.10.3 | 	github.com/variantdev/vals v0.10.3 | ||||||
| 	go.uber.org/multierr v1.1.0 | 	go.uber.org/multierr v1.1.0 | ||||||
|  |  | ||||||
							
								
								
									
										8
									
								
								go.sum
								
								
								
								
							
							
						
						
									
										8
									
								
								go.sum
								
								
								
								
							|  | @ -855,6 +855,14 @@ github.com/variantdev/chartify v0.4.3 h1:CRyi9XDCXkgvvgOkNUwXp0oaIJG0BWKjbUZHN3D | ||||||
| github.com/variantdev/chartify v0.4.3/go.mod h1:Fr4oPNJ4b19knlovn0wBoU2+MZxQdBacmBs30wwgAFk= | github.com/variantdev/chartify v0.4.3/go.mod h1:Fr4oPNJ4b19knlovn0wBoU2+MZxQdBacmBs30wwgAFk= | ||||||
| github.com/variantdev/chartify v0.4.4 h1:ludsoqljh2HVNpZhMjtvzo5P0ntEcFqMufu6B4SfByY= | github.com/variantdev/chartify v0.4.4 h1:ludsoqljh2HVNpZhMjtvzo5P0ntEcFqMufu6B4SfByY= | ||||||
| github.com/variantdev/chartify v0.4.4/go.mod h1:Fr4oPNJ4b19knlovn0wBoU2+MZxQdBacmBs30wwgAFk= | github.com/variantdev/chartify v0.4.4/go.mod h1:Fr4oPNJ4b19knlovn0wBoU2+MZxQdBacmBs30wwgAFk= | ||||||
|  | github.com/variantdev/chartify v0.4.5 h1:Nt2lFV1yNnu2uvs0iAf/uyRrNtlrL74Ie/KVwBe2WqA= | ||||||
|  | github.com/variantdev/chartify v0.4.5/go.mod h1:Fr4oPNJ4b19knlovn0wBoU2+MZxQdBacmBs30wwgAFk= | ||||||
|  | github.com/variantdev/chartify v0.4.6 h1:YILsir/llPNwbITPIdQ7bCc5lYJgmK3l15jcS62v88E= | ||||||
|  | github.com/variantdev/chartify v0.4.6/go.mod h1:Fr4oPNJ4b19knlovn0wBoU2+MZxQdBacmBs30wwgAFk= | ||||||
|  | github.com/variantdev/chartify v0.4.7 h1:qBAmbMFdQ1mMLP9ZikqVLMyakkeqPKNcv/YT2laP6P4= | ||||||
|  | github.com/variantdev/chartify v0.4.7/go.mod h1:Fr4oPNJ4b19knlovn0wBoU2+MZxQdBacmBs30wwgAFk= | ||||||
|  | github.com/variantdev/chartify v0.4.8 h1:bQAlp9N1qiyG29bn39r51g1bBuDJrYdT9zxT303PhbM= | ||||||
|  | github.com/variantdev/chartify v0.4.8/go.mod h1:Fr4oPNJ4b19knlovn0wBoU2+MZxQdBacmBs30wwgAFk= | ||||||
| github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363 h1:KrfQBEUn+wEOQ/6UIfoqRDvn+Q/wZridQ7t0G1vQqKE= | github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363 h1:KrfQBEUn+wEOQ/6UIfoqRDvn+Q/wZridQ7t0G1vQqKE= | ||||||
| github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363/go.mod h1:pH1TQsNSLj2uxMo9NNl9zdGy01Wtn+/2MT96BrKmVyE= | github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363/go.mod h1:pH1TQsNSLj2uxMo9NNl9zdGy01Wtn+/2MT96BrKmVyE= | ||||||
| github.com/variantdev/vals v0.4.0 h1:O1O7/sWhlvozcY2DjZBzlE1notxwVo6UBT1+w7HsO/k= | github.com/variantdev/vals v0.4.0 h1:O1O7/sWhlvozcY2DjZBzlE1notxwVo6UBT1+w7HsO/k= | ||||||
|  |  | ||||||
|  | @ -139,6 +139,10 @@ type HelmSpec struct { | ||||||
| 	HistoryMax *int `yaml:"historyMax,omitempty"` | 	HistoryMax *int `yaml:"historyMax,omitempty"` | ||||||
| 	// CreateNamespace, when set to true (default), --create-namespace is passed to helm3 on install/upgrade (ignored for helm2)
 | 	// CreateNamespace, when set to true (default), --create-namespace is passed to helm3 on install/upgrade (ignored for helm2)
 | ||||||
| 	CreateNamespace *bool `yaml:"createNamespace,omitempty"` | 	CreateNamespace *bool `yaml:"createNamespace,omitempty"` | ||||||
|  | 	// SkipDeps disables running `helm dependency up` and `helm dependency build` on this release's chart.
 | ||||||
|  | 	// This is relevant only when your release uses a local chart or a directory containing K8s manifests or a Kustomization
 | ||||||
|  | 	// as a Helm chart.
 | ||||||
|  | 	SkipDeps bool `yaml:"skipDeps"` | ||||||
| 
 | 
 | ||||||
| 	TLS                      bool   `yaml:"tls"` | 	TLS                      bool   `yaml:"tls"` | ||||||
| 	TLSCACert                string `yaml:"tlsCACert,omitempty"` | 	TLSCACert                string `yaml:"tlsCACert,omitempty"` | ||||||
|  | @ -270,6 +274,11 @@ type ReleaseSpec struct { | ||||||
| 	// In standard use-cases, `Namespace` should be sufficient.
 | 	// In standard use-cases, `Namespace` should be sufficient.
 | ||||||
| 	// Use this only when you know what you want to do!
 | 	// Use this only when you know what you want to do!
 | ||||||
| 	ForceNamespace string `yaml:"forceNamespace"` | 	ForceNamespace string `yaml:"forceNamespace"` | ||||||
|  | 
 | ||||||
|  | 	// SkipDeps disables running `helm dependency up` and `helm dependency build` on this release's chart.
 | ||||||
|  | 	// This is relevant only when your release uses a local chart or a directory containing K8s manifests or a Kustomization
 | ||||||
|  | 	// as a Helm chart.
 | ||||||
|  | 	SkipDeps *bool `yaml:"skipDeps"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type Release struct { | type Release struct { | ||||||
|  | @ -894,6 +903,8 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre | ||||||
| 
 | 
 | ||||||
| 				chartName := release.Chart | 				chartName := release.Chart | ||||||
| 
 | 
 | ||||||
|  | 				isLocal := pathExists(normalizeChart(st.basePath, chartName)) | ||||||
|  | 
 | ||||||
| 				chartPath, err := st.goGetterChart(chartName, release.Directory, release.ForceGoGetter) | 				chartPath, err := st.goGetterChart(chartName, release.Directory, release.ForceGoGetter) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					results <- &chartPrepareResult{err: fmt.Errorf("release %q: %w", release.Name, err)} | 					results <- &chartPrepareResult{err: fmt.Errorf("release %q: %w", release.Name, err)} | ||||||
|  | @ -911,20 +922,34 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre | ||||||
| 
 | 
 | ||||||
| 				var buildDeps bool | 				var buildDeps bool | ||||||
| 
 | 
 | ||||||
|  | 				skipDepsGlobal := opts.SkipRepos | ||||||
|  | 				skipDepsRelease := release.SkipDeps != nil && *release.SkipDeps | ||||||
|  | 				skipDepsDefault := release.SkipDeps == nil && st.HelmDefaults.SkipDeps | ||||||
|  | 				skipDeps := !isLocal || skipDepsGlobal || skipDepsRelease || skipDepsDefault | ||||||
|  | 
 | ||||||
| 				if chartification != nil { | 				if chartification != nil { | ||||||
| 					c := chartify.New( | 					c := chartify.New( | ||||||
| 						chartify.HelmBin(st.DefaultHelmBinary), | 						chartify.HelmBin(st.DefaultHelmBinary), | ||||||
| 						chartify.UseHelm3(helm3), | 						chartify.UseHelm3(helm3), | ||||||
| 					) | 					) | ||||||
| 
 | 
 | ||||||
| 					out, err := c.Chartify(release.Name, chartPath, chartify.WithChartifyOpts(chartification.Opts)) | 					chartifyOpts := chartification.Opts | ||||||
|  | 
 | ||||||
|  | 					if skipDeps { | ||||||
|  | 						chartifyOpts.SkipDeps = true | ||||||
|  | 					} | ||||||
|  | 
 | ||||||
|  | 					out, err := c.Chartify(release.Name, chartPath, chartify.WithChartifyOpts(chartifyOpts)) | ||||||
| 					if err != nil { | 					if err != nil { | ||||||
| 						results <- &chartPrepareResult{err: err} | 						results <- &chartPrepareResult{err: err} | ||||||
| 						return | 						return | ||||||
| 					} else { | 					} else { | ||||||
| 						// TODO Chartify
 |  | ||||||
| 						chartPath = out | 						chartPath = out | ||||||
| 					} | 					} | ||||||
|  | 
 | ||||||
|  | 					// Skip `helm dep build` and `helm dep up` altogether when the chart is from remote or the dep is
 | ||||||
|  | 					// explicitly skipped.
 | ||||||
|  | 					buildDeps = !skipDeps | ||||||
| 				} else if pathExists(normalizeChart(st.basePath, chartPath)) { | 				} else if pathExists(normalizeChart(st.basePath, chartPath)) { | ||||||
| 					// At this point, we are sure that chartPath is a local directory containing either:
 | 					// At this point, we are sure that chartPath is a local directory containing either:
 | ||||||
| 					// - A remote chart fetched by go-getter or
 | 					// - A remote chart fetched by go-getter or
 | ||||||
|  | @ -951,7 +976,7 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre | ||||||
| 					// a broken remote chart won't completely block their job.
 | 					// a broken remote chart won't completely block their job.
 | ||||||
| 					chartPath = normalizeChart(st.basePath, chartPath) | 					chartPath = normalizeChart(st.basePath, chartPath) | ||||||
| 
 | 
 | ||||||
| 					buildDeps = !opts.SkipRepos | 					buildDeps = !skipDeps | ||||||
| 				} else if !opts.ForceDownload { | 				} else if !opts.ForceDownload { | ||||||
| 					// At this point, we are sure that either:
 | 					// At this point, we are sure that either:
 | ||||||
| 					// 1. It is a local chart and we can use it in later process (helm upgrade/template/lint/etc)
 | 					// 1. It is a local chart and we can use it in later process (helm upgrade/template/lint/etc)
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue