Skip to content

Commit 65faa5f

Browse files
committed
pkg/networks/config.go: allow non-existing networks.yaml fields
Allow non-existing YAML fields, as a config created with Lima < v0.22 contains `vdeSwitch` and `vdeVMNet`. These fields were removed in Lima v0.22 (PR 2311). Signed-off-by: Akihiro Suda <[email protected]>
1 parent a26f5cf commit 65faa5f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/networks/config.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,17 @@ func loadCache() {
132132
if cache.err != nil {
133133
return
134134
}
135-
cache.err = yaml.UnmarshalWithOptions(b, &cache.config, yaml.Strict())
135+
cache.err = yaml.UnmarshalWithOptions(b, &cache.config, yaml.DisallowDuplicateKey())
136136
if cache.err != nil {
137137
cache.err = fmt.Errorf("cannot parse %q: %w", configFile, cache.err)
138138
return
139139
}
140+
var strictConfig YAML
141+
if strictErr := yaml.UnmarshalWithOptions(b, &strictConfig, yaml.Strict()); strictErr != nil {
142+
// Allow non-existing YAML fields, as a config created with Lima < v0.22 contains `vdeSwitch` and `vdeVMNet`.
143+
// These fields were removed in Lima v0.22.
144+
logrus.WithError(strictErr).Warn("Non-strict YAML is deprecated and will be unsupported in a future version of Lima: " + configFile)
145+
}
140146
cache.config, cache.err = fillDefaults(cache.config)
141147
if cache.err != nil {
142148
cache.err = fmt.Errorf("cannot fill default %q: %w", configFile, cache.err)

0 commit comments

Comments
 (0)