Skip to content

Commit 32d47fc

Browse files
committed
Fix relative converted paths in windows
Signed-off-by: Ulysses Souza <[email protected]>
1 parent 771cf87 commit 32d47fc

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

cli/options.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ func withNamePrecedenceLoad(absWorkingDir string, options *ProjectOptions) func(
365365
func withConvertWindowsPaths(options *ProjectOptions) func(*loader.Options) {
366366
return func(o *loader.Options) {
367367
o.ConvertWindowsPaths = utils.StringToBool(options.Environment["COMPOSE_CONVERT_WINDOWS_PATHS"])
368+
o.ResolvePaths = true
368369
}
369370
}
370371

cli/options_windows_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ import (
2626
func TestConvertWithEnvVar(t *testing.T) {
2727
os.Setenv("COMPOSE_CONVERT_WINDOWS_PATHS", "1")
2828
defer os.Unsetenv("COMPOSE_CONVERT_WINDOWS_PATHS")
29-
opts, _ := NewProjectOptions([]string{"testdata/simple/compose-with-paths.yaml"}, WithOsEnv)
29+
opts, _ := NewProjectOptions([]string{"testdata/simple/compose-with-paths.yaml"},
30+
WithOsEnv,
31+
WithWorkingDirectory("C:\\\\"))
3032

3133
p, err := ProjectFromOptions(opts)
3234

3335
assert.NilError(t, err)
36+
assert.Equal(t, len(p.Services[0].Volumes), 3)
3437
assert.Equal(t, p.Services[0].Volumes[0].Source, "/c/docker/project")
38+
assert.Equal(t, p.Services[0].Volumes[1].Source, "/c/relative")
39+
assert.Equal(t, p.Services[0].Volumes[2].Source, "/c/relative2")
3540
}

cli/testdata/simple/compose-with-paths.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ services:
55
- type: bind
66
source: C:\docker\project
77
target: /test
8+
- type: bind
9+
source: ./relative
10+
target: /test-relative
11+
- ./relative2:/test-relative2

loader/loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ func LoadService(name string, serviceDict map[string]interface{}, workingDir str
574574
return nil, errors.New(`invalid mount config for type "bind": field Source must not be empty`)
575575
}
576576

577-
if resolvePaths {
577+
if resolvePaths || convertPaths {
578578
volume = resolveVolumePath(volume, workingDir, lookupEnv)
579579
}
580580

0 commit comments

Comments
 (0)