mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
Merge pull request #9774 from yxxhero/fix_msg_when_index_yaml_empty
Add a more friendly prompt when index.yaml is empty.
This commit is contained in:
commit
d83dd95cae
2 changed files with 13 additions and 0 deletions
|
|
@ -50,6 +50,8 @@ var (
|
|||
ErrNoChartVersion = errors.New("no chart version found")
|
||||
// ErrNoChartName indicates that a chart with the given name is not found.
|
||||
ErrNoChartName = errors.New("no chart name found")
|
||||
// ErrEmptyIndexYaml indicates that the content of index.yaml is empty.
|
||||
ErrEmptyIndexYaml = errors.New("empty index.yaml file")
|
||||
)
|
||||
|
||||
// ChartVersions is a list of versioned chart references.
|
||||
|
|
@ -326,6 +328,11 @@ func IndexDirectory(dir, baseURL string) (*IndexFile, error) {
|
|||
// This will fail if API Version is not set (ErrNoAPIVersion) or if the unmarshal fails.
|
||||
func loadIndex(data []byte, source string) (*IndexFile, error) {
|
||||
i := &IndexFile{}
|
||||
|
||||
if len(data) == 0 {
|
||||
return i, ErrEmptyIndexYaml
|
||||
}
|
||||
|
||||
if err := yaml.UnmarshalStrict(data, i); err != nil {
|
||||
return i, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,6 +152,12 @@ func TestLoadIndex_Duplicates(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestLoadIndex_Empty(t *testing.T) {
|
||||
if _, err := loadIndex([]byte(""), "indexWithEmpty"); err == nil {
|
||||
t.Errorf("Expected an error when index.yaml is empty.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadIndexFileAnnotations(t *testing.T) {
|
||||
i, err := LoadIndexFile(annotationstestfile)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue