Skip to content

Commit

Permalink
Merge pull request compose-spec#402 from ndeloof/numeric-ids
Browse files Browse the repository at this point in the history
  • Loading branch information
ndeloof authored May 15, 2023
2 parents 4e62a57 + 92f2af5 commit ec9cd70
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
31 changes: 31 additions & 0 deletions loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2354,3 +2354,34 @@ func TestInvalidProjectNameType(t *testing.T) {
assert.Error(t, err, "validating filename0.yml: name must be a string")
assert.Assert(t, is.Nil(p))
}

func TestNumericIDs(t *testing.T) {
p, err := loadYAML(`
name: 'test-numeric-ids'
services:
foo:
image: busybox
volumes:
- 0:/foo
volumes:
'0': {}
`)
assert.NilError(t, err)
assert.DeepEqual(t, p.Services, types.Services{
{
Name: "foo",
Image: "busybox",
Environment: types.MappingWithEquals{},
Scale: 1,
Volumes: []types.ServiceVolumeConfig{
{
Type: types.VolumeTypeVolume,
Source: "0",
Target: "/foo",
Volume: &types.ServiceVolumeVolume{},
},
},
},
})
}
3 changes: 3 additions & 0 deletions loader/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,8 @@ func isFilePath(source string) bool {
}

first, nextIndex := utf8.DecodeRuneInString(source)
if len(source) <= nextIndex {
return false
}
return isWindowsDrive([]rune{first}, rune(source[nextIndex]))
}

0 comments on commit ec9cd70

Please sign in to comment.