|
|
@ -30,6 +30,7 @@ import (
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/Masterminds/semver"
|
|
|
|
"github.com/Masterminds/semver"
|
|
|
|
"github.com/ghodss/yaml"
|
|
|
|
"github.com/ghodss/yaml"
|
|
|
|
|
|
|
|
yaml2 "gopkg.in/yaml.v2"
|
|
|
|
|
|
|
|
|
|
|
|
"k8s.io/helm/pkg/chartutil"
|
|
|
|
"k8s.io/helm/pkg/chartutil"
|
|
|
|
"k8s.io/helm/pkg/proto/hapi/chart"
|
|
|
|
"k8s.io/helm/pkg/proto/hapi/chart"
|
|
|
@ -83,6 +84,14 @@ type IndexFile struct {
|
|
|
|
PublicKeys []string `json:"publicKeys,omitempty"`
|
|
|
|
PublicKeys []string `json:"publicKeys,omitempty"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// IndexValidation is used to validate the integrity of an index file
|
|
|
|
|
|
|
|
type IndexValidation struct {
|
|
|
|
|
|
|
|
APIVersion string `yaml:"apiVersion"`
|
|
|
|
|
|
|
|
Generated time.Time `yaml:"generated"`
|
|
|
|
|
|
|
|
Entries map[string]interface{} `yaml:"entries"`
|
|
|
|
|
|
|
|
PublicKeys []string `yaml:"publicKeys,omitempty"`
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NewIndexFile initializes an index.
|
|
|
|
// NewIndexFile initializes an index.
|
|
|
|
func NewIndexFile() *IndexFile {
|
|
|
|
func NewIndexFile() *IndexFile {
|
|
|
|
return &IndexFile{
|
|
|
|
return &IndexFile{
|
|
|
@ -283,9 +292,14 @@ func IndexDirectory(dir, baseURL string) (*IndexFile, error) {
|
|
|
|
// This will fail if API Version is not set (ErrNoAPIVersion) or if the unmarshal fails.
|
|
|
|
// This will fail if API Version is not set (ErrNoAPIVersion) or if the unmarshal fails.
|
|
|
|
func loadIndex(data []byte) (*IndexFile, error) {
|
|
|
|
func loadIndex(data []byte) (*IndexFile, error) {
|
|
|
|
i := &IndexFile{}
|
|
|
|
i := &IndexFile{}
|
|
|
|
|
|
|
|
if err := validateIndex(data); err != nil {
|
|
|
|
|
|
|
|
return i, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err := yaml.Unmarshal(data, i); err != nil {
|
|
|
|
if err := yaml.Unmarshal(data, i); err != nil {
|
|
|
|
return i, err
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
i.SortEntries()
|
|
|
|
i.SortEntries()
|
|
|
|
if i.APIVersion == "" {
|
|
|
|
if i.APIVersion == "" {
|
|
|
|
// When we leave Beta, we should remove legacy support and just
|
|
|
|
// When we leave Beta, we should remove legacy support and just
|
|
|
@ -296,6 +310,16 @@ func loadIndex(data []byte) (*IndexFile, error) {
|
|
|
|
return i, nil
|
|
|
|
return i, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// validateIndex validates that the index is well-formed.
|
|
|
|
|
|
|
|
func validateIndex(data []byte) error {
|
|
|
|
|
|
|
|
// This is done ONLY for validation. We need to use ghodss/yaml for the actual parsing.
|
|
|
|
|
|
|
|
validation := &IndexValidation{}
|
|
|
|
|
|
|
|
if err := yaml2.UnmarshalStrict(data, validation); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// unversionedEntry represents a deprecated pre-Alpha.5 format.
|
|
|
|
// unversionedEntry represents a deprecated pre-Alpha.5 format.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// This will be removed prior to v2.0.0
|
|
|
|
// This will be removed prior to v2.0.0
|
|
|
|