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

Function validateFileObject

pkg/limayaml/validate.go:423–440  ·  view source on GitHub ↗
(f limatype.File, fieldName string)

Source from the content-addressed store, hash-verified

421}
422
423func validateFileObject(f limatype.File, fieldName string) error {
424 var errs error
425 if !strings.Contains(f.Location, "://") {
426 if _, err := localpathutil.Expand(f.Location); err != nil {
427 errs = errors.Join(errs, fmt.Errorf("field `%s.location` refers to an invalid local file path: %#q: %w", fieldName, f.Location, err))
428 }
429 // f.Location does NOT need to be accessible, so we do NOT check os.Stat(f.Location)
430 }
431 if !slices.Contains(limatype.ArchTypes, f.Arch) {
432 errs = errors.Join(errs, fmt.Errorf("field `arch` must be one of %v; got %#q", limatype.ArchTypes, f.Arch))
433 }
434 if f.Digest != "" {
435 if err := f.Digest.Validate(); err != nil {
436 errs = errors.Join(errs, fmt.Errorf("field `%s.digest` is invalid: %s: %w", fieldName, f.Digest.String(), err))
437 }
438 }
439 return errs
440}
441
442func validateNetwork(y *limatype.LimaYAML) error {
443 var errs error

Callers 1

ValidateFunction · 0.85

Calls 3

ExpandFunction · 0.92
ValidateMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected