MCPcopy Create free account
hub / github.com/Vanilla-OS/apx / LoadStackFromPath

Function LoadStackFromPath

core/stack.go:53–76  ·  view source on GitHub ↗

LoadStackFromPath loads a stack from the specified path.

(path string)

Source from the content-addressed store, hash-verified

51
52// LoadStackFromPath loads a stack from the specified path.
53func LoadStackFromPath(path string) (*Stack, error) {
54 stack := &Stack{}
55
56 f, err := os.Open(path)
57 if err != nil {
58 return nil, errors.New("stack not found")
59 }
60
61 data, err := io.ReadAll(f)
62 if err != nil {
63 return nil, err
64 }
65
66 err = yaml.Unmarshal(data, stack)
67 if err != nil {
68 return nil, err
69 }
70
71 if stack.Name == "" || stack.Base == "" || stack.PkgManager == "" {
72 return nil, errors.New("invalid stack file")
73 }
74
75 return stack, nil
76}
77
78// Save saves the stack to a YAML file.
79func (stack *Stack) Save() error {

Callers 2

RunMethod · 0.92
LoadStackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected