MCPcopy
hub / github.com/helm/helm / LoadDir

Function LoadDir

pkg/chart/v2/loader/directory.go:45–122  ·  view source on GitHub ↗

LoadDir loads from a directory. This loads charts only from directories.

(dir string)

Source from the content-addressed store, hash-verified

43//
44// This loads charts only from directories.
45func LoadDir(dir string) (*chart.Chart, error) {
46 topdir, err := filepath.Abs(dir)
47 if err != nil {
48 return nil, err
49 }
50
51 // Just used for errors.
52 c := &chart.Chart{}
53
54 rules := ignore.Empty()
55 ifile := filepath.Join(topdir, ignore.HelmIgnore)
56 if _, err := os.Stat(ifile); err == nil {
57 r, err := ignore.ParseFile(ifile)
58 if err != nil {
59 return c, err
60 }
61 rules = r
62 }
63 rules.AddDefaults()
64
65 files := []*archive.BufferedFile{}
66 topdir += string(filepath.Separator)
67
68 walk := func(name string, fi os.FileInfo, err error) error {
69 n := strings.TrimPrefix(name, topdir)
70 if n == "" {
71 // No need to process top level. Avoid bug with helmignore .* matching
72 // empty names. See issue 1779.
73 return nil
74 }
75
76 // Normalize to / since it will also work on Windows
77 n = filepath.ToSlash(n)
78
79 if err != nil {
80 return err
81 }
82 if fi.IsDir() {
83 // Directory-based ignore rules should involve skipping the entire
84 // contents of that directory.
85 if rules.Ignore(n, fi) {
86 return filepath.SkipDir
87 }
88 return nil
89 }
90
91 // If a .helmignore file matches, skip this file.
92 if rules.Ignore(n, fi) {
93 return nil
94 }
95
96 // Irregular files include devices, sockets, and other uses of files that
97 // are not regular files. In Go they have a file mode type bit set.
98 // See https://golang.org/pkg/os/#FileMode for examples.
99 if !fi.Mode().IsRegular() {
100 return fmt.Errorf("cannot load irregular file %s as it has file mode type bits set", name)
101 }
102

Callers 11

DependenciesFunction · 0.92
TestCreateFunction · 0.92
TestCreateFromFunction · 0.92
TestSaveDirFunction · 0.92
TestDownloadAllFunction · 0.92
loadChartDirMethod · 0.92
downloadAllMethod · 0.92
tarFromLocalDirFunction · 0.92
RunWithReturnMethod · 0.92
ResolveMethod · 0.92
LoadMethod · 0.70

Calls 7

EmptyFunction · 0.92
ParseFileFunction · 0.92
WalkFunction · 0.92
AddDefaultsMethod · 0.80
IgnoreMethod · 0.80
LoadFilesFunction · 0.70
NameMethod · 0.65

Tested by 4

TestCreateFunction · 0.74
TestCreateFromFunction · 0.74
TestSaveDirFunction · 0.74
TestDownloadAllFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…