Skip to content

Commit a2c3535

Browse files
committed
Supress warnings from libyaml.Validate unless called by main.Start
Signed-off-by: Jan Dubois <[email protected]>
1 parent a4920c1 commit a2c3535

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

cmd/limactl/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string) (*store.Instance, e
120120
if err != nil {
121121
return nil, err
122122
}
123-
if err := limayaml.Validate(*y); err != nil {
123+
if err := limayaml.Validate(*y, true); err != nil {
124124
if !tty {
125125
return nil, err
126126
}

pkg/cidata/cidata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var (
3535
)
3636

3737
func GenerateISO9660(instDir, name string, y *limayaml.LimaYAML) error {
38-
if err := limayaml.Validate(*y); err != nil {
38+
if err := limayaml.Validate(*y, false); err != nil {
3939
return err
4040
}
4141
u, err := osutil.LimaUser(true)

pkg/limayaml/validate.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/sirupsen/logrus"
1919
)
2020

21-
func Validate(y LimaYAML) error {
21+
func Validate(y LimaYAML, warn bool) error {
2222
switch y.Arch {
2323
case X8664, AARCH64:
2424
default:
@@ -161,17 +161,18 @@ func Validate(y LimaYAML) error {
161161
// processed sequentially and the first matching rule for a guest port determines forwarding behavior.
162162
}
163163

164-
if err := validateNetwork(y); err != nil {
164+
if err := validateNetwork(y, warn); err != nil {
165165
return err
166166
}
167-
168167
return nil
169168
}
170169

171-
func validateNetwork(y LimaYAML) error {
170+
func validateNetwork(y LimaYAML, warn bool) error {
172171
if len(y.Network.VDEDeprecated) > 0 {
173172
if y.Network.migrated {
174-
logrus.Warnf("field `network.VDE` is deprecated; please use `networks` instead")
173+
if warn {
174+
logrus.Warnf("field `network.VDE` is deprecated; please use `networks` instead")
175+
}
175176
} else {
176177
return fmt.Errorf("you cannot use deprecated field `network.VDE` together with replacement field `networks`")
177178
}
@@ -233,8 +234,10 @@ func validateNetwork(y LimaYAML) error {
233234
}
234235
}
235236
} else if runtime.GOOS != "linux" {
236-
logrus.Warnf("field `%s.vnl` is unlikely to work for %s (unless libvdeplug4 has been ported to %s and is installed)",
237-
field, runtime.GOOS, runtime.GOOS)
237+
if warn {
238+
logrus.Warnf("field `%s.vnl` is unlikely to work for %s (unless libvdeplug4 has been ported to %s and is installed)",
239+
field, runtime.GOOS, runtime.GOOS)
240+
}
238241
}
239242
}
240243
if nw.MACAddress != "" {

pkg/store/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func LoadYAMLByFilePath(filePath string) (*limayaml.LimaYAML, error) {
5454
if err != nil {
5555
return nil, err
5656
}
57-
if err := limayaml.Validate(*y); err != nil {
57+
if err := limayaml.Validate(*y, false); err != nil {
5858
return nil, err
5959
}
6060
return y, nil

0 commit comments

Comments
 (0)