|
|
@ -17,9 +17,10 @@ limitations under the License.
|
|
|
|
package repo // import "k8s.io/helm/pkg/repo"
|
|
|
|
package repo // import "k8s.io/helm/pkg/repo"
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"crypto/sha1"
|
|
|
|
"crypto/sha256"
|
|
|
|
|
|
|
|
"encoding/hex"
|
|
|
|
"errors"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io/ioutil"
|
|
|
|
"io/ioutil"
|
|
|
|
"net/url"
|
|
|
|
"net/url"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
@ -131,7 +132,7 @@ func (r *ChartRepository) Index() error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
chartfile := ch.Metadata
|
|
|
|
chartfile := ch.Metadata
|
|
|
|
hash, err := generateChecksum(path)
|
|
|
|
digest, err := generateDigest(path)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -152,7 +153,7 @@ func (r *ChartRepository) Index() error {
|
|
|
|
url, _ := url.Parse(r.URL)
|
|
|
|
url, _ := url.Parse(r.URL)
|
|
|
|
url.Path = filepath.Join(url.Path, key+".tgz")
|
|
|
|
url.Path = filepath.Join(url.Path, key+".tgz")
|
|
|
|
|
|
|
|
|
|
|
|
entry := &ChartRef{Chartfile: chartfile, Name: chartfile.Name, URL: url.String(), Created: created, Checksum: hash, Removed: false}
|
|
|
|
entry := &ChartRef{Chartfile: chartfile, Name: chartfile.Name, URL: url.String(), Created: created, Digest: digest, Removed: false}
|
|
|
|
|
|
|
|
|
|
|
|
r.IndexFile.Entries[key] = entry
|
|
|
|
r.IndexFile.Entries[key] = entry
|
|
|
|
|
|
|
|
|
|
|
@ -170,18 +171,15 @@ func (r *ChartRepository) Index() error {
|
|
|
|
return r.saveIndexFile()
|
|
|
|
return r.saveIndexFile()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func generateChecksum(path string) (string, error) {
|
|
|
|
func generateDigest(path string) (string, error) {
|
|
|
|
f, err := os.Open(path)
|
|
|
|
f, err := os.Open(path)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
b, err := ioutil.ReadAll(f)
|
|
|
|
h := sha256.New()
|
|
|
|
if err != nil {
|
|
|
|
io.Copy(h, f)
|
|
|
|
return "", err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result := sha1.Sum(b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return fmt.Sprintf("%x", result), nil
|
|
|
|
digest := h.Sum([]byte{})
|
|
|
|
|
|
|
|
return "sha256:" + hex.EncodeToString(digest[:]), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|