Review comments fixed

- Documentation improvement
- Loop detection limit into package variable
- Loop detection now handles self-pointer
pull/2278/head
Gergo Huszty 9 years ago committed by Gergo Huszty
parent 428f050ba2
commit cfa4560078

@ -66,7 +66,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
}

@ -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
```

@ -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]

@ -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.")
}
}

Loading…
Cancel
Save