@@ -53,6 +53,8 @@ type Options struct {
53
53
SkipNormalization bool
54
54
// Resolve paths
55
55
ResolvePaths bool
56
+ // Convert Windows paths
57
+ ConvertWindowsPaths bool
56
58
// Skip consistency check
57
59
SkipConsistencyCheck bool
58
60
// Skip extends
@@ -489,7 +491,7 @@ func loadServiceWithExtends(filename, name string, servicesDict map[string]inter
489
491
return nil , fmt .Errorf ("cannot extend service %q in %s: service not found" , name , filename )
490
492
}
491
493
492
- serviceConfig , err := LoadService (name , target .(map [string ]interface {}), workingDir , lookupEnv , opts .ResolvePaths )
494
+ serviceConfig , err := LoadService (name , target .(map [string ]interface {}), workingDir , lookupEnv , opts .ResolvePaths , opts . ConvertWindowsPaths )
493
495
if err != nil {
494
496
return nil , err
495
497
}
@@ -552,7 +554,7 @@ func loadServiceWithExtends(filename, name string, servicesDict map[string]inter
552
554
553
555
// LoadService produces a single ServiceConfig from a compose file Dict
554
556
// the serviceDict is not validated if directly used. Use Load() to enable validation
555
- func LoadService (name string , serviceDict map [string ]interface {}, workingDir string , lookupEnv template.Mapping , resolvePaths bool ) (* types.ServiceConfig , error ) {
557
+ func LoadService (name string , serviceDict map [string ]interface {}, workingDir string , lookupEnv template.Mapping , resolvePaths bool , convertPaths bool ) (* types.ServiceConfig , error ) {
556
558
serviceConfig := & types.ServiceConfig {
557
559
Scale : 1 ,
558
560
}
@@ -577,11 +579,30 @@ func LoadService(name string, serviceDict map[string]interface{}, workingDir str
577
579
if resolvePaths {
578
580
serviceConfig .Volumes [i ] = resolveVolumePath (volume , workingDir , lookupEnv )
579
581
}
582
+
583
+ if convertPaths {
584
+ serviceConfig .Volumes [i ] = convertVolumePath (volume )
585
+ }
580
586
}
581
587
582
588
return serviceConfig , nil
583
589
}
584
590
591
+ // Windows paths, c:\\my\\path\\shiny, need to be changed to be compatible with
592
+ // the Engine. Volume paths are expected to be linux style /c/my/path/shiny/
593
+ func convertVolumePath (volume types.ServiceVolumeConfig ) types.ServiceVolumeConfig {
594
+ volumeName := strings .ToLower (filepath .VolumeName (volume .Source ))
595
+ if len (volumeName ) != 2 {
596
+ return volume
597
+ }
598
+
599
+ convertedSource := fmt .Sprintf ("/%c%s" , volumeName [0 ], volume .Source [len (volumeName ):])
600
+ convertedSource = strings .ReplaceAll (convertedSource , "\\ " , "/" )
601
+
602
+ volume .Source = convertedSource
603
+ return volume
604
+ }
605
+
585
606
func resolveEnvironment (serviceConfig * types.ServiceConfig , workingDir string , lookupEnv template.Mapping ) error {
586
607
environment := types.MappingWithEquals {}
587
608
0 commit comments