Skip to content

Fix logging non-existent path #3595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/limayaml/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
}
Expand All @@ -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
Expand Down
Loading