Skip to content

Commit 7a68f1c

Browse files
committed
add warning log when non-existent directory
Signed-off-by: Songpon Srisawai <songpon.ssw@gmail.com>
1 parent d3a5741 commit 7a68f1c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/limayaml/validate.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ func Validate(y *LimaYAML, warn bool) error {
144144
}
145145
}
146146

147+
var mountWarnings []string
148+
147149
for i, f := range y.Mounts {
148150
if !filepath.IsAbs(f.Location) && !strings.HasPrefix(f.Location, "~") {
149151
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 {
159161
if !errors.Is(err, os.ErrNotExist) {
160162
return fmt.Errorf("field `mounts[%d].location` refers to an inaccessible path: %q: %w", i, f.Location, err)
161163
}
164+
mountWarnings = append(mountWarnings, fmt.Sprintf("field `mounts[%d].location` non-existent directory: %q:", i, f.Location))
162165
} else if !st.IsDir() {
163166
return fmt.Errorf("field `mounts[%d].location` refers to a non-directory path: %q: %w", i, f.Location, err)
164167
}
@@ -180,6 +183,12 @@ func Validate(y *LimaYAML, warn bool) error {
180183
}
181184
}
182185

186+
if warn && len(mountWarnings) > 0 {
187+
for _, warning := range mountWarnings {
188+
logrus.Warn(warning)
189+
}
190+
}
191+
183192
if *y.SSH.LocalPort != 0 {
184193
if err := validatePort("ssh.localPort", *y.SSH.LocalPort); err != nil {
185194
return err

0 commit comments

Comments
 (0)