MCPcopy
hub / github.com/lima-vm/lima / LoadYAMLByFilePath

Function LoadYAMLByFilePath

pkg/store/store.go:110–131  ·  view source on GitHub ↗

LoadYAMLByFilePath loads and validates the yaml.

(ctx context.Context, filePath string)

Source from the content-addressed store, hash-verified

108
109// LoadYAMLByFilePath loads and validates the yaml.
110func LoadYAMLByFilePath(ctx context.Context, filePath string) (*limatype.LimaYAML, error) {
111 // We need to use the absolute path because it may be used to determine hostSocket locations.
112 absPath, err := filepath.Abs(filePath)
113 if err != nil {
114 return nil, err
115 }
116 yContent, err := os.ReadFile(absPath)
117 if err != nil {
118 return nil, err
119 }
120 y, err := limayaml.Load(ctx, yContent, absPath)
121 if err != nil {
122 return nil, err
123 }
124 if err := driverutil.ResolveVMType(ctx, y, filePath); err != nil {
125 return nil, fmt.Errorf("failed to resolve vm for %q: %w", filePath, err)
126 }
127 if err := limayaml.Validate(y, false); err != nil {
128 return nil, err
129 }
130 return y, nil
131}

Callers 2

FuzzLoadYAMLByFilePathFunction · 0.85
InspectFunction · 0.85

Calls 4

LoadFunction · 0.92
ResolveVMTypeFunction · 0.92
ValidateFunction · 0.92
ReadFileMethod · 0.80

Tested by 1

FuzzLoadYAMLByFilePathFunction · 0.68