Commit 1322fb53
1322fb53d755Merged
zhiliaev <[email protected]> · 4 years ago · 4 files · ~4 modified
Description
feat: validate registries and some fixes
Details
- Commit
- 1322fb53d755
- Parent
- 58f6d2257579
pkg/plan/validate.gomodifiedView file
@@ -2,6 +2,7 @@
22
33
import (44
"errors"5+
"fmt"56
"net/url"67
"os"78
"regexp"@@ -13,7 +14,7 @@
1314
// ErrValidateFailed is returned for failed values validation.1415
var ErrValidateFailed = errors.New("validate failed")1516
16-
// ValidateValues checkes whether all values files exist.17+
// ValidateValues checks whether all values files exist.1718
func (p *Plan) ValidateValues() error {1819
f := false1920
for _, rel := range p.body.Releases {@@ -42,6 +43,10 @@
4243
return errors.New("releases and repositories are empty")4344
}4445
46+
if err := p.ValidateRegistries(); err != nil {47+
return err48+
}49+
4550
if err := p.ValidateRepositories(); err != nil {4651
return err4752
}@@ -71,7 +76,23 @@
7176
7277
a[r.Name()]++7378
if a[r.Name()] > 1 {74-
return errors.New("repository name duplicate: " + r.Name())79+
return fmt.Errorf("repository %s duplicate", r.Name())80+
}81+
}82+
83+
return nil84+
}85+
86+
func (p *planBody) ValidateRegistries() error {87+
a := make(map[string]int8)88+
for _, r := range p.Registries {89+
if r.Host() == "" {90+
return errors.New("registry name is empty")91+
}92+
93+
a[r.Host()]++94+
if a[r.Host()] > 1 {95+
return fmt.Errorf("registry %s duplicate", r.Host())7596
}7697
}7798
pkg/registry/config.gomodifiedView file
Loading diff…
pkg/registry/interface.gomodifiedView file
Loading diff…
tests/10_helmwave.ymlmodifiedView file
Loading diff…