MCPcopy
hub / github.com/carvel-dev/ytt / NewRootLibrary

Function NewRootLibrary

pkg/workspace/library.go:27–47  ·  view source on GitHub ↗
(fs []*files.File)

Source from the content-addressed store, hash-verified

25}
26
27func NewRootLibrary(fs []*files.File) *Library {
28 rootLibrary := &Library{}
29
30 for _, file := range fs {
31 dirPieces, _ := files.SplitPath(file.RelativePath())
32
33 var currLibrary *Library = rootLibrary
34 for _, piece := range dirPieces {
35 lib, found := currLibrary.findLibrary(piece)
36 if !found {
37 currLibrary = currLibrary.CreateLibrary(piece)
38 } else {
39 currLibrary = lib
40 }
41 }
42
43 currLibrary.files = append(currLibrary.files, file)
44 }
45
46 return rootLibrary
47}
48
49func (l *Library) findLibrary(name string) (*Library, bool) {
50 for _, lib := range l.children {

Callers 1

RunWithFilesMethod · 0.92

Calls 4

findLibraryMethod · 0.95
CreateLibraryMethod · 0.95
SplitPathFunction · 0.92
RelativePathMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…