diff --git a/cmd/helm/dependency_build.go b/cmd/helm/dependency_build.go index 9dd548db3..94e809f1c 100644 --- a/cmd/helm/dependency_build.go +++ b/cmd/helm/dependency_build.go @@ -68,7 +68,7 @@ func newDependencyBuildCmd(out io.Writer) *cobra.Command { f := cmd.Flags() f.BoolVar(&dbc.verify, "verify", false, "verify the packages against signatures") f.StringVar(&dbc.keyring, "keyring", defaultKeyring(), "keyring containing public keys") - f.BoolVar(&dbc.recursive, "recursive", false, "recursive mode") + f.BoolVar(&dbc.recursive, "recursive", false, "run the dependency build also for the dependent charts recursively") return cmd } diff --git a/docs/helm/helm_dependency_build.md b/docs/helm/helm_dependency_build.md index 99bbd9110..fb53c6b53 100644 --- a/docs/helm/helm_dependency_build.md +++ b/docs/helm/helm_dependency_build.md @@ -24,7 +24,7 @@ helm dependency build [flags] CHART ``` --keyring string keyring containing public keys (default "~/.gnupg/pubring.gpg") - --recursive recursive mode + --recursive run the dependency build also for the dependent charts recursively --verify verify the packages against signatures ``` @@ -41,4 +41,4 @@ helm dependency build [flags] CHART ### SEE ALSO * [helm dependency](helm_dependency.md) - manage a chart's dependencies -###### Auto generated by spf13/cobra on 16-Apr-2017 +###### Auto generated by spf13/cobra on 30-Apr-2017 diff --git a/docs/man/man1/helm_dependency_build.1 b/docs/man/man1/helm_dependency_build.1 index 6d5fa762e..abc982c6b 100644 --- a/docs/man/man1/helm_dependency_build.1 +++ b/docs/man/man1/helm_dependency_build.1 @@ -34,7 +34,7 @@ of 'helm dependency update'. .PP \fB\-\-recursive\fP[=false] - recursive mode + run the dependency build also for the dependent charts recursively .PP \fB\-\-verify\fP[=false] @@ -70,4 +70,4 @@ of 'helm dependency update'. .SH HISTORY .PP -16\-Apr\-2017 Auto generated by spf13/cobra +30\-Apr\-2017 Auto generated by spf13/cobra diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 76eb7d5cc..7b8e08733 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -61,10 +61,17 @@ type Manager struct { Recursive bool } +// MaxDepsPerChart is the limit of chart hierarchy in case of recursive mode +// If it is exceeded, it is treated as loop between the chart dependencies. +var MaxDepsPerChart = 100 + // Build rebuilds a local charts directory from a lockfile. // // If the lockfile is not present, this will run a Manager.Update() // +// The integer return value indicates the dependency sum. It is used to +// detect loops in case of recirsive mode. +// // If SkipUpdate is set, this will not update the repository. func (m *Manager) Build() (int, error) { c, err := m.loadChartDir() @@ -105,7 +112,7 @@ func (m *Manager) Build() (int, error) { return 0, err } - myDeps := len(reqs.Dependencies) + myDeps := 1 + len(reqs.Dependencies) if m.Recursive { depM := *m for _, dep := range reqs.Dependencies { @@ -117,7 +124,7 @@ func (m *Manager) Build() (int, error) { return 0, err } myDeps += depOfDeps - if myDeps > 100 { + if myDeps > MaxDepsPerChart { return 0, fmt.Errorf("Loop prevention kicked in.") } }