-
Notifications
You must be signed in to change notification settings - Fork 600
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
simplify FillDefault()
using reflects
#1069
base: master
Are you sure you want to change the base?
Conversation
c54861d
to
29d65ad
Compare
29d65ad
to
01a8a36
Compare
pkg/limayaml
: remove deprecated network
and useHostResolver ; simplify
FillDefault()` using reflectspkg/limayaml
: remove deprecated network
and useHostResolver
; simplify FillDefault()
using reflects
- `network`: deprecated in Lima v0.7.0 (Oct 2021), in favor of `networks`: lima-vm@07e6823 - `useHostResolver`: deprecated in Lima v0.8.1 (Jan 2022), in favor of `hostResolver.enabled`: lima-vm@eaeee31 The deprecated support for VDE is not removed in this commit. Signed-off-by: Akihiro Suda <[email protected]>
01a8a36
to
2b3f4ca
Compare
Signed-off-by: Akihiro Suda <[email protected]>
2b3f4ca
to
7cbfb37
Compare
var err error | ||
x, err = Merge(x, v) | ||
if err != nil { | ||
return x, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't return incompletely merged result in case of error:
return x, err | |
return nil, err |
func logX(t testing.TB, x interface{}, format string, args ...interface{}) { | ||
// Print in JSON for human readability | ||
j, err := json.Marshal(x) | ||
assert.NilError(t, err) | ||
t.Logf(format+": %s", append(args, string(j))...) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args
is never used; format
is really just a name:
func logX(t testing.TB, x interface{}, format string, args ...interface{}) { | |
// Print in JSON for human readability | |
j, err := json.Marshal(x) | |
assert.NilError(t, err) | |
t.Logf(format+": %s", append(args, string(j))...) | |
} | |
func logX(t testing.TB, x interface{}, name string) { | |
// Print in JSON for human readability | |
j, err := json.Marshal(x) | |
assert.NilError(t, err) | |
t.Logf("%s: %s", name, string(j)) | |
} |
Personally I would also swap the order of x
and name
, but it doesn't really matter.
} | ||
} | ||
// *EXCEPTION*: Mounts are appended in d, y, o order, but "merged" when the Location matches a previous entry; | ||
// the highest priority Writable setting wins. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just below is this block:
mounts := make([]Mount, 0, len(d.Mounts)+len(y.Mounts)+len(o.Mounts))
location := make(map[string]int)
for _, mount := range append(append(d.Mounts, y.Mounts...), o.Mounts...) {
if i, ok := location[mount.Location]; ok {
It should have been updated to no longer use d
, y
, and o
, but just x
.
mounts := make([]Mount, 0, len(x.Mounts))
location := make(map[string]int)
for _, mount := range x.Mounts {
mount.Location = filepath.Clean(mount.Location)
if i, ok := location[mount.Location]; ok {
Update: I also added a call to filepath.Clean()
to normalize paths before matching. Could be in a separate commit or even PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing again further down for networks
.
networks := make([]Network, 0, len(d.Networks)+len(y.Networks)+len(o.Networks)) | ||
iface := make(map[string]int) | ||
for _, nw := range append(append(d.Networks, y.Networks...), o.Networks...) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
networks := make([]Network, 0, len(d.Networks)+len(y.Networks)+len(o.Networks)) | |
iface := make(map[string]int) | |
for _, nw := range append(append(d.Networks, y.Networks...), o.Networks...) { | |
networks := make([]Network, 0, len(x.Networks)) | |
iface := make(map[string]int) | |
for _, nw := range x.Networks { |
pkg/limayaml
: remove deprecated network
and useHostResolver
; simplify FillDefault()
using reflectsFillDefault()
using reflects
The type of
CPUType map[Arch]string
is now changed tomap[Arch]*string
, aspkg/reflectutil.Merge()
is designed to distinguish "empty" from "nil".