mirror of
https://github.com/helm/helm.git
synced 2026-06-30 19:57:48 +00:00
add nil judge for dependency , maintainers validate and some testcase.
Signed-off-by: wujunwei <wjw3323@live.com>
This commit is contained in:
@@ -53,6 +53,9 @@ type Dependency struct {
|
||||
// the chart. This check must be done at load time before the dependency's charts are
|
||||
// loaded.
|
||||
func (d *Dependency) Validate() error {
|
||||
if d == nil {
|
||||
return ValidationError("the dependency's item can not be nil")
|
||||
}
|
||||
d.Name = sanitizeString(d.Name)
|
||||
d.Version = sanitizeString(d.Version)
|
||||
d.Repository = sanitizeString(d.Repository)
|
||||
|
||||
@@ -34,6 +34,9 @@ type Maintainer struct {
|
||||
|
||||
// Validate checks valid data and sanitizes string characters.
|
||||
func (m *Maintainer) Validate() error {
|
||||
if m == nil {
|
||||
return ValidationError("the maintainer's item can not be nil")
|
||||
}
|
||||
m.Name = sanitizeString(m.Name)
|
||||
m.Email = sanitizeString(m.Email)
|
||||
m.URL = sanitizeString(m.URL)
|
||||
|
||||
@@ -72,6 +72,30 @@ func TestValidate(t *testing.T) {
|
||||
},
|
||||
ValidationError("dependency \"bad\" has disallowed characters in the alias"),
|
||||
},
|
||||
{
|
||||
&Metadata{
|
||||
Name: "test",
|
||||
APIVersion: "v2",
|
||||
Version: "1.0",
|
||||
Type: "application",
|
||||
Dependencies: []*Dependency{
|
||||
nil,
|
||||
},
|
||||
},
|
||||
ValidationError("the dependency's item can not be nil"),
|
||||
},
|
||||
{
|
||||
&Metadata{
|
||||
Name: "test",
|
||||
APIVersion: "v2",
|
||||
Version: "1.0",
|
||||
Type: "application",
|
||||
Maintainers: []*Maintainer{
|
||||
nil,
|
||||
},
|
||||
},
|
||||
ValidationError("the maintainer's item can not be nil"),
|
||||
},
|
||||
{
|
||||
&Metadata{APIVersion: "v2", Name: "test", Version: "1.2.3.4"},
|
||||
ValidationError("chart.metadata.version \"1.2.3.4\" is invalid"),
|
||||
|
||||
Reference in New Issue
Block a user