From 95b81eb68467897fdfb3cf68187403bfe4e1aa5a Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Thu, 6 Apr 2017 10:32:35 -0400 Subject: [PATCH] Support rw as a volume option in compose file. Signed-off-by: Daniel Nephin --- compose/loader/volume.go | 2 ++ compose/loader/volume_test.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/compose/loader/volume.go b/compose/loader/volume.go index 3f33492ea7..4dce1b2ef5 100644 --- a/compose/loader/volume.go +++ b/compose/loader/volume.go @@ -70,6 +70,8 @@ func populateFieldFromBuffer(char rune, buffer []rune, volume *types.ServiceVolu switch option { case "ro": volume.ReadOnly = true + case "rw": + volume.ReadOnly = false case "nocopy": volume.Volume = &types.ServiceVolumeVolume{NoCopy: true} default: diff --git a/compose/loader/volume_test.go b/compose/loader/volume_test.go index 0735d5a54a..19d19f2306 100644 --- a/compose/loader/volume_test.go +++ b/compose/loader/volume_test.go @@ -132,3 +132,17 @@ func TestParseVolumeWithReadOnly(t *testing.T) { assert.DeepEqual(t, volume, expected) } } + +func TestParseVolumeWithRW(t *testing.T) { + for _, path := range []string{"./foo", "/home/user"} { + volume, err := parseVolume(path + ":/target:rw") + expected := types.ServiceVolumeConfig{ + Type: "bind", + Source: path, + Target: "/target", + ReadOnly: false, + } + assert.NilError(t, err) + assert.DeepEqual(t, volume, expected) + } +}