diff --git a/pkg/limayaml/validate.go b/pkg/limayaml/validate.go index 750383e2c51..3bc84545f66 100644 --- a/pkg/limayaml/validate.go +++ b/pkg/limayaml/validate.go @@ -144,6 +144,8 @@ func Validate(y *LimaYAML, warn bool) error { } } + var mountWarnings []string + for i, f := range y.Mounts { if !filepath.IsAbs(f.Location) && !strings.HasPrefix(f.Location, "~") { return fmt.Errorf("field `mounts[%d].location` must be an absolute path, got %q", @@ -159,6 +161,7 @@ func Validate(y *LimaYAML, warn bool) error { if !errors.Is(err, os.ErrNotExist) { return fmt.Errorf("field `mounts[%d].location` refers to an inaccessible path: %q: %w", i, f.Location, err) } + mountWarnings = append(mountWarnings, fmt.Sprintf("field `mounts[%d].location` non-existent directory: %q:", i, f.Location)) } else if !st.IsDir() { return fmt.Errorf("field `mounts[%d].location` refers to a non-directory path: %q: %w", i, f.Location, err) } @@ -180,6 +183,12 @@ func Validate(y *LimaYAML, warn bool) error { } } + if warn && len(mountWarnings) > 0 { + for _, warning := range mountWarnings { + logrus.Warn(warning) + } + } + if *y.SSH.LocalPort != 0 { if err := validatePort("ssh.localPort", *y.SSH.LocalPort); err != nil { return err