|
|
@ -21,7 +21,6 @@ import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"text/template"
|
|
|
|
"text/template"
|
|
|
@ -63,8 +62,6 @@ const releaseNameMaxLen = 53
|
|
|
|
// since there can be filepath in front of it.
|
|
|
|
// since there can be filepath in front of it.
|
|
|
|
const notesFileSuffix = "NOTES.txt"
|
|
|
|
const notesFileSuffix = "NOTES.txt"
|
|
|
|
|
|
|
|
|
|
|
|
const defaultDirectoryPermission = 0755
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Install performs an installation operation.
|
|
|
|
// Install performs an installation operation.
|
|
|
|
type Install struct {
|
|
|
|
type Install struct {
|
|
|
|
cfg *Configuration
|
|
|
|
cfg *Configuration
|
|
|
@ -485,50 +482,6 @@ func (i *Install) replaceRelease(rel *release.Release) error {
|
|
|
|
return i.recordRelease(last)
|
|
|
|
return i.recordRelease(last)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// write the <data> to <output-dir>/<name>. <append> controls if the file is created or content will be appended
|
|
|
|
|
|
|
|
func writeToFile(outputDir string, name string, data string, append bool) error {
|
|
|
|
|
|
|
|
outfileName := strings.Join([]string{outputDir, name}, string(filepath.Separator))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err := ensureDirectoryForFile(outfileName)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
f, err := createOrOpenFile(outfileName, append)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_, err = f.WriteString(fmt.Sprintf("---\n# Source: %s\n%s\n", name, data))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Printf("wrote %s\n", outfileName)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func createOrOpenFile(filename string, append bool) (*os.File, error) {
|
|
|
|
|
|
|
|
if append {
|
|
|
|
|
|
|
|
return os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0600)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return os.Create(filename)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check if the directory exists to create file. creates if don't exists
|
|
|
|
|
|
|
|
func ensureDirectoryForFile(file string) error {
|
|
|
|
|
|
|
|
baseDir := path.Dir(file)
|
|
|
|
|
|
|
|
_, err := os.Stat(baseDir)
|
|
|
|
|
|
|
|
if err != nil && !os.IsNotExist(err) {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return os.MkdirAll(baseDir, defaultDirectoryPermission)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NameAndChart returns the name and chart that should be used.
|
|
|
|
// NameAndChart returns the name and chart that should be used.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// This will read the flags and handle name generation if necessary.
|
|
|
|
// This will read the flags and handle name generation if necessary.
|
|
|
|