Skip to content

Commit 92f2af5

Browse files
committed
[fix] volume can be defined by a numeric ID
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 4e62a57 commit 92f2af5

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

loader/loader_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,3 +2354,34 @@ func TestInvalidProjectNameType(t *testing.T) {
23542354
assert.Error(t, err, "validating filename0.yml: name must be a string")
23552355
assert.Assert(t, is.Nil(p))
23562356
}
2357+
2358+
func TestNumericIDs(t *testing.T) {
2359+
p, err := loadYAML(`
2360+
name: 'test-numeric-ids'
2361+
services:
2362+
foo:
2363+
image: busybox
2364+
volumes:
2365+
- 0:/foo
2366+
2367+
volumes:
2368+
'0': {}
2369+
`)
2370+
assert.NilError(t, err)
2371+
assert.DeepEqual(t, p.Services, types.Services{
2372+
{
2373+
Name: "foo",
2374+
Image: "busybox",
2375+
Environment: types.MappingWithEquals{},
2376+
Scale: 1,
2377+
Volumes: []types.ServiceVolumeConfig{
2378+
{
2379+
Type: types.VolumeTypeVolume,
2380+
Source: "0",
2381+
Target: "/foo",
2382+
Volume: &types.ServiceVolumeVolume{},
2383+
},
2384+
},
2385+
},
2386+
})
2387+
}

loader/volume.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,8 @@ func isFilePath(source string) bool {
176176
}
177177

178178
first, nextIndex := utf8.DecodeRuneInString(source)
179+
if len(source) <= nextIndex {
180+
return false
181+
}
179182
return isWindowsDrive([]rune{first}, rune(source[nextIndex]))
180183
}

0 commit comments

Comments
 (0)