@@ -631,21 +631,39 @@ func FillDefault(ctx context.Context, y, d, o *limatype.LimaYAML, filePath strin
631
631
// Combine all mounts; highest priority entry determines writable status.
632
632
// Only works for exact matches; does not normalize case or resolve symlinks.
633
633
mounts := make ([]limatype.Mount , 0 , len (d .Mounts )+ len (y .Mounts )+ len (o .Mounts ))
634
- location := make (map [string ]int )
634
+ mountPoint := make (map [string ]int )
635
635
for _ , mount := range slices .Concat (d .Mounts , y .Mounts , o .Mounts ) {
636
636
if out , err := executeHostTemplate (mount .Location , instDir , y .Param ); err == nil {
637
637
mount .Location = filepath .Clean (out .String ())
638
638
} else {
639
639
logrus .WithError (err ).Warnf ("Couldn't process mount location %q as a template" , mount .Location )
640
640
}
641
- if mount .MountPoint != nil {
641
+ // Expand a path that begins with `~`. Relative paths are not modified, and rejected by Validate() later.
642
+ if localpathutil .IsTildePath (mount .Location ) {
643
+ if location , err := localpathutil .Expand (mount .Location ); err == nil {
644
+ mount .Location = location
645
+ } else {
646
+ logrus .WithError (err ).Warnf ("Couldn't expand location %q" , mount .Location )
647
+ }
648
+ }
649
+ if mount .MountPoint == nil {
650
+ mountLocation := mount .Location
651
+ if runtime .GOOS == "windows" {
652
+ var err error
653
+ mountLocation , err = ioutilx .WindowsSubsystemPath (ctx , mountLocation )
654
+ if err != nil {
655
+ logrus .WithError (err ).Warnf ("Couldn't convert location %q into mount target" , mount .Location )
656
+ }
657
+ }
658
+ mount .MountPoint = ptr .Of (mountLocation )
659
+ } else {
642
660
if out , err := executeGuestTemplate (* mount .MountPoint , instDir , y .User , y .Param ); err == nil {
643
661
mount .MountPoint = ptr .Of (out .String ())
644
662
} else {
645
663
logrus .WithError (err ).Warnf ("Couldn't process mount point %q as a template" , * mount .MountPoint )
646
664
}
647
665
}
648
- if i , ok := location [ mount .Location ]; ok {
666
+ if i , ok := mountPoint [ * mount .MountPoint ]; ok {
649
667
if mount .SSHFS .Cache != nil {
650
668
mounts [i ].SSHFS .Cache = mount .SSHFS .Cache
651
669
}
@@ -677,7 +695,7 @@ func FillDefault(ctx context.Context, y, d, o *limatype.LimaYAML, filePath strin
677
695
mounts [i ].MountPoint = mount .MountPoint
678
696
}
679
697
} else {
680
- location [ mount .Location ] = len (mounts )
698
+ mountPoint [ * mount .MountPoint ] = len (mounts )
681
699
mounts = append (mounts , mount )
682
700
}
683
701
}
@@ -713,26 +731,6 @@ func FillDefault(ctx context.Context, y, d, o *limatype.LimaYAML, filePath strin
713
731
mounts [i ].NineP .Cache = ptr .Of (Default9pCacheForRO )
714
732
}
715
733
}
716
-
717
- // Expand a path that begins with `~`. Relative paths are not modified, and rejected by Validate() later.
718
- if localpathutil .IsTildePath (mount .Location ) {
719
- if location , err := localpathutil .Expand (mount .Location ); err == nil {
720
- mounts [i ].Location = location
721
- } else {
722
- logrus .WithError (err ).Warnf ("Couldn't expand location %q" , mount .Location )
723
- }
724
- }
725
- if mount .MountPoint == nil {
726
- mountLocation := mounts [i ].Location
727
- if runtime .GOOS == "windows" {
728
- var err error
729
- mountLocation , err = ioutilx .WindowsSubsystemPath (ctx , mountLocation )
730
- if err != nil {
731
- logrus .WithError (err ).Warnf ("Couldn't convert location %q into mount target" , mounts [i ].Location )
732
- }
733
- }
734
- mounts [i ].MountPoint = ptr .Of (mountLocation )
735
- }
736
734
}
737
735
738
736
// Note: DNS lists are not combined; highest priority setting is picked
0 commit comments