| 421 | } |
| 422 | |
| 423 | func 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 | |
| 442 | func validateNetwork(y *limatype.LimaYAML) error { |
| 443 | var errs error |