mirror of https://github.com/helm/helm
add flag include-file that loads a local file external to the chart and makes it available to the templates
Signed-off-by: Vlad Fratila <vfratila@adobe.com> Signed-off-by: Matheus Hunsche <matheus.hunsche@ifood.com.br>pull/8840/head
parent
b74ee4d710
commit
5e86b54c25
@ -0,0 +1,19 @@
|
|||||||
|
package loader
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LoadLocalFile loads a file from the local filesystem.
|
||||||
|
func LoadLocalFile(path string) ([]byte, error) {
|
||||||
|
if fi, err := os.Stat(path); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if fi.IsDir() {
|
||||||
|
return nil, errors.New("cannot load a directory")
|
||||||
|
}
|
||||||
|
|
||||||
|
return ioutil.ReadFile(path)
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package files
|
||||||
|
|
||||||
|
// ExternalFiles holds the list of external files or globs
|
||||||
|
type ExternalFiles struct {
|
||||||
|
Files []string
|
||||||
|
Globs []string
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package files
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ParseIntoString parses a include-file line and merges the result into dest.
|
||||||
|
func ParseIntoString(s string, dest map[string]string) error {
|
||||||
|
for _, val := range strings.Split(s, ",") {
|
||||||
|
val = strings.TrimSpace(val)
|
||||||
|
splt := strings.SplitN(val, "=", 2)
|
||||||
|
|
||||||
|
if len(splt) != 2 {
|
||||||
|
return errors.New("Could not parse line")
|
||||||
|
}
|
||||||
|
|
||||||
|
name := strings.TrimSpace(splt[0])
|
||||||
|
path := strings.TrimSpace(splt[1])
|
||||||
|
dest[name] = path
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Reference in new issue