Review comments fixed

- Documentation improvement
- Loop detection limit into package variable
- Loop detection now handles self-pointer
reviewable/pr2278/r2
Gergo Huszty 9 years ago
parent 33fbcda4cc
commit 77cda0e624

@ -68,7 +68,7 @@ func newDependencyBuildCmd(out io.Writer) *cobra.Command {
f := cmd.Flags() f := cmd.Flags()
f.BoolVar(&dbc.verify, "verify", false, "verify the packages against signatures") f.BoolVar(&dbc.verify, "verify", false, "verify the packages against signatures")
f.StringVar(&dbc.keyring, "keyring", defaultKeyring(), "keyring containing public keys") 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 return cmd
} }

@ -24,7 +24,7 @@ helm dependency build [flags] CHART
``` ```
--keyring string keyring containing public keys (default "~/.gnupg/pubring.gpg") --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 --verify verify the packages against signatures
``` ```
@ -41,4 +41,4 @@ helm dependency build [flags] CHART
### SEE ALSO ### SEE ALSO
* [helm dependency](helm_dependency.md) - manage a chart's dependencies * [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

@ -34,7 +34,7 @@ of 'helm dependency update'.
.PP .PP
\fB\-\-recursive\fP[=false] \fB\-\-recursive\fP[=false]
recursive mode run the dependency build also for the dependent charts recursively
.PP .PP
\fB\-\-verify\fP[=false] \fB\-\-verify\fP[=false]
@ -70,4 +70,4 @@ of 'helm dependency update'.
.SH HISTORY .SH HISTORY
.PP .PP
16\-Apr\-2017 Auto generated by spf13/cobra 30\-Apr\-2017 Auto generated by spf13/cobra

@ -61,10 +61,17 @@ type Manager struct {
Recursive bool 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. // Build rebuilds a local charts directory from a lockfile.
// //
// If the lockfile is not present, this will run a Manager.Update() // 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. // If SkipUpdate is set, this will not update the repository.
func (m *Manager) Build() (int, error) { func (m *Manager) Build() (int, error) {
c, err := m.loadChartDir() c, err := m.loadChartDir()
@ -105,7 +112,7 @@ func (m *Manager) Build() (int, error) {
return 0, err return 0, err
} }
myDeps := len(reqs.Dependencies) myDeps := 1 + len(reqs.Dependencies)
if m.Recursive { if m.Recursive {
depM := *m depM := *m
for _, dep := range reqs.Dependencies { for _, dep := range reqs.Dependencies {
@ -117,7 +124,7 @@ func (m *Manager) Build() (int, error) {
return 0, err return 0, err
} }
myDeps += depOfDeps myDeps += depOfDeps
if myDeps > 100 { if myDeps > MaxDepsPerChart {
return 0, fmt.Errorf("Loop prevention kicked in.") return 0, fmt.Errorf("Loop prevention kicked in.")
} }
} }

Loading…
Cancel
Save