|
|
@ -39,6 +39,10 @@ var headerBytes = []byte("+aHR0cHM6Ly95b3V0dS5iZS96OVV6MWljandyTQo=")
|
|
|
|
// directory, writing the chart's contents to that subdirectory.
|
|
|
|
// directory, writing the chart's contents to that subdirectory.
|
|
|
|
func SaveDir(c *chart.Chart, dest string) error {
|
|
|
|
func SaveDir(c *chart.Chart, dest string) error {
|
|
|
|
// Create the chart directory
|
|
|
|
// Create the chart directory
|
|
|
|
|
|
|
|
err := validateName(c.Name())
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
outdir := filepath.Join(dest, c.Name())
|
|
|
|
outdir := filepath.Join(dest, c.Name())
|
|
|
|
if fi, err := os.Stat(outdir); err == nil && !fi.IsDir() {
|
|
|
|
if fi, err := os.Stat(outdir); err == nil && !fi.IsDir() {
|
|
|
|
return errors.Errorf("file %s already exists and is not a directory", outdir)
|
|
|
|
return errors.Errorf("file %s already exists and is not a directory", outdir)
|
|
|
@ -149,6 +153,10 @@ func Save(c *chart.Chart, outDir string) (string, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error {
|
|
|
|
func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error {
|
|
|
|
|
|
|
|
err := validateName(c.Name())
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
base := filepath.Join(prefix, c.Name())
|
|
|
|
base := filepath.Join(prefix, c.Name())
|
|
|
|
|
|
|
|
|
|
|
|
// Pull out the dependencies of a v1 Chart, since there's no way
|
|
|
|
// Pull out the dependencies of a v1 Chart, since there's no way
|
|
|
@ -242,3 +250,15 @@ func writeToTar(out *tar.Writer, name string, body []byte) error {
|
|
|
|
_, err := out.Write(body)
|
|
|
|
_, err := out.Write(body)
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If the name has directory name has characters which would change the location
|
|
|
|
|
|
|
|
// they need to be removed.
|
|
|
|
|
|
|
|
func validateName(name string) error {
|
|
|
|
|
|
|
|
nname := filepath.Base(name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if nname != name {
|
|
|
|
|
|
|
|
return ErrInvalidChartName{name}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|