@@ -29,28 +29,6 @@ import (
29
29
"github.com/lima-vm/lima/pkg/version/versionutil"
30
30
)
31
31
32
- func validateFileObject (f File , fieldName string ) error {
33
- var errs error
34
- if ! strings .Contains (f .Location , "://" ) {
35
- if _ , err := localpathutil .Expand (f .Location ); err != nil {
36
- errs = errors .Join (errs , fmt .Errorf ("field `%s.location` refers to an invalid local file path: %q: %w" , fieldName , f .Location , err ))
37
- }
38
- // f.Location does NOT need to be accessible, so we do NOT check os.Stat(f.Location)
39
- }
40
- if ! slices .Contains (ArchTypes , f .Arch ) {
41
- errs = errors .Join (errs , fmt .Errorf ("field `arch` must be one of %v; got %q" , ArchTypes , f .Arch ))
42
- }
43
- if f .Digest != "" {
44
- if ! f .Digest .Algorithm ().Available () {
45
- errs = errors .Join (errs , fmt .Errorf ("field `%s.digest` refers to an unavailable digest algorithm" , fieldName ))
46
- }
47
- if err := f .Digest .Validate (); err != nil {
48
- errs = errors .Join (errs , fmt .Errorf ("field `%s.digest` is invalid: %s: %w" , fieldName , f .Digest .String (), err ))
49
- }
50
- }
51
- return errs
52
- }
53
-
54
32
func Validate (y * LimaYAML , warn bool ) error {
55
33
var errs error
56
34
@@ -441,6 +419,28 @@ func Validate(y *LimaYAML, warn bool) error {
441
419
return errs
442
420
}
443
421
422
+ func validateFileObject (f File , fieldName string ) error {
423
+ var errs error
424
+ if ! strings .Contains (f .Location , "://" ) {
425
+ if _ , err := localpathutil .Expand (f .Location ); err != nil {
426
+ errs = errors .Join (errs , fmt .Errorf ("field `%s.location` refers to an invalid local file path: %q: %w" , fieldName , f .Location , err ))
427
+ }
428
+ // f.Location does NOT need to be accessible, so we do NOT check os.Stat(f.Location)
429
+ }
430
+ if ! slices .Contains (ArchTypes , f .Arch ) {
431
+ errs = errors .Join (errs , fmt .Errorf ("field `arch` must be one of %v; got %q" , ArchTypes , f .Arch ))
432
+ }
433
+ if f .Digest != "" {
434
+ if ! f .Digest .Algorithm ().Available () {
435
+ errs = errors .Join (errs , fmt .Errorf ("field `%s.digest` refers to an unavailable digest algorithm" , fieldName ))
436
+ }
437
+ if err := f .Digest .Validate (); err != nil {
438
+ errs = errors .Join (errs , fmt .Errorf ("field `%s.digest` is invalid: %s: %w" , fieldName , f .Digest .String (), err ))
439
+ }
440
+ }
441
+ return errs
442
+ }
443
+
444
444
func validateNetwork (y * LimaYAML ) error {
445
445
var errs error
446
446
interfaceName := make (map [string ]int )
@@ -518,9 +518,9 @@ func validateNetwork(y *LimaYAML) error {
518
518
return errs
519
519
}
520
520
521
- // ValidateParamIsUsed checks if the keys in the `param` field are used in any script, probe, copyToHost, or portForward.
521
+ // validateParamIsUsed checks if the keys in the `param` field are used in any script, probe, copyToHost, or portForward.
522
522
// It should be called before the `y` parameter is passed to FillDefault() that execute template.
523
- func ValidateParamIsUsed (y * LimaYAML ) error {
523
+ func validateParamIsUsed (y * LimaYAML ) error {
524
524
for key := range y .Param {
525
525
re , err := regexp .Compile (`{{[^}]*\.Param\.` + key + `[^}]*}}|\bPARAM_` + key + `\b` )
526
526
if err != nil {
@@ -611,9 +611,9 @@ func warnExperimental(y *LimaYAML) {
611
611
}
612
612
}
613
613
614
- // ValidateYAMLAgainstLatestConfig validates the values between the latest YAML and the updated(New) YAML.
614
+ // ValidateAgainstLatestConfig validates the values between the latest YAML and the updated(New) YAML.
615
615
// This validates configuration rules that disallow certain changes, such as shrinking the disk.
616
- func ValidateYAMLAgainstLatestConfig (yNew , yLatest []byte ) error {
616
+ func ValidateAgainstLatestConfig (yNew , yLatest []byte ) error {
617
617
var n LimaYAML
618
618
619
619
// Load the latest YAML and fill in defaults
0 commit comments