From 5c9f6a4dd421ee7c6acfc23f3dec143c7f46bbe9 Mon Sep 17 00:00:00 2001 From: jeroenpeeters Date: Thu, 11 May 2017 10:16:40 +0200 Subject: [PATCH 1/6] fixed volume mapping problem when no data bucket is used. --- src/coffee/compose.coffee | 2 +- src/coffee/compose/actions.coffee | 5 +++-- tests/coffee/compose.test.coffee | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/coffee/compose.coffee b/src/coffee/compose.coffee index 46ffb61..4507cc0 100644 --- a/src/coffee/compose.coffee +++ b/src/coffee/compose.coffee @@ -57,7 +57,7 @@ module.exports = (config) -> else if vsplit.length is 3 if bucketPath "#{resolvePath bucketPath, vsplit[0]}:#{vsplit[1]}:#{vsplit[2]}" - else "#{vsplit[1]}:#{vsplit[2]}" + else "#{vsplit[1]}" else v catch e console.error "Error while mapping volumes. Root: #{bucketPath}, path: #{v}", e diff --git a/src/coffee/compose/actions.coffee b/src/coffee/compose/actions.coffee index 8640c4e..ef1a894 100644 --- a/src/coffee/compose/actions.coffee +++ b/src/coffee/compose/actions.coffee @@ -43,9 +43,10 @@ module.exports = (config) -> volumePaths = [] for service in _.values composition.services when service.volumes volumePaths = _.uniq (_.union volumePaths, service.volumes).map (mapping) -> - mapping.split(':')[0] + splits = mapping.split(':') + splits[0] if splits.length is 2 - for path in volumePaths + for path in volumePaths when path try process.umask 0 mkdirp.sync path diff --git a/tests/coffee/compose.test.coffee b/tests/coffee/compose.test.coffee index 1531268..f78e923 100644 --- a/tests/coffee/compose.test.coffee +++ b/tests/coffee/compose.test.coffee @@ -116,8 +116,8 @@ describe 'Compose', -> volumeTest '/my/mapping:/internal/volume:rw', '/local/data/google/bucket1/my/mapping:/internal/volume:rw' it 'should leave a :ro postfix intact', -> volumeTest '/my/mapping:/internal/volume:ro', '/local/data/google/bucket1/my/mapping:/internal/volume:ro' - it 'should leave a postfix intact when no storage bucket is given', -> - volumeTest '/my/mapping:/internal/volume:rw', '/internal/volume:rw', {} + it 'should remove the postfix when no storage bucket is given', -> + volumeTest '/my/mapping:/internal/volume:rw', '/internal/volume', {} it 'should not do anything to an unmapped volume', -> volumeTest '/internal/volume', '/internal/volume' it 'should not do anything to an unmapped volume when no data bucket is given', -> From 0050473dbb3015afde9c597d5a9c304fc03970d8 Mon Sep 17 00:00:00 2001 From: jeroenpeeters Date: Thu, 11 May 2017 10:18:13 +0200 Subject: [PATCH 2/6] bumped fix version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9c61227..ce6f66e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "docker-dashboard-agent-compose", - "version": "2.10.0", + "version": "2.10.1", "description": "", "main": "index.js", "scripts": { From 0b373682903de3d8cf7b73649124646cd2e547c3 Mon Sep 17 00:00:00 2001 From: jeroenpeeters Date: Thu, 11 May 2017 10:31:24 +0200 Subject: [PATCH 3/6] fixed ro/rw postfix bug when no bind volume is present (compose bug). --- src/coffee/compose.coffee | 2 +- tests/coffee/compose.test.coffee | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/coffee/compose.coffee b/src/coffee/compose.coffee index 4507cc0..95a0103 100644 --- a/src/coffee/compose.coffee +++ b/src/coffee/compose.coffee @@ -50,7 +50,7 @@ module.exports = (config) -> try if vsplit.length is 2 if vsplit[1] in ['rw', 'ro'] - v + vsplit[0] else if bucketPath "#{resolvePath bucketPath, vsplit[0]}:#{vsplit[1]}" else vsplit[1] diff --git a/tests/coffee/compose.test.coffee b/tests/coffee/compose.test.coffee index f78e923..3dea164 100644 --- a/tests/coffee/compose.test.coffee +++ b/tests/coffee/compose.test.coffee @@ -116,16 +116,16 @@ describe 'Compose', -> volumeTest '/my/mapping:/internal/volume:rw', '/local/data/google/bucket1/my/mapping:/internal/volume:rw' it 'should leave a :ro postfix intact', -> volumeTest '/my/mapping:/internal/volume:ro', '/local/data/google/bucket1/my/mapping:/internal/volume:ro' - it 'should remove the postfix when no storage bucket is given', -> + it 'should remove the postfix when no storage bucket is given (compose bug)', -> volumeTest '/my/mapping:/internal/volume:rw', '/internal/volume', {} it 'should not do anything to an unmapped volume', -> volumeTest '/internal/volume', '/internal/volume' it 'should not do anything to an unmapped volume when no data bucket is given', -> volumeTest '/internal/volume', '/internal/volume', {} - it 'should not do anything to an unmapped volume with :ro when no data bucket is given', -> - volumeTest '/internal/volume:ro', '/internal/volume:ro', {} - it 'should not do anything to an unmapped volume with :rw', -> - volumeTest '/internal/volume:rw', '/internal/volume:rw' + it 'should remove a postfix (:ro) from an unmapped volume when no data bucket is given (compose bug)', -> + volumeTest '/internal/volume:ro', '/internal/volume', {} + it 'should remove a postfix (:rw) from an unmapped volume when no data bucket is given (compose bug)', -> + volumeTest '/internal/volume:rw', '/internal/volume' it 'should discard a volume with a mapping that resolves outside of the bucket root', -> c = compose dataDir: '/local/data/', domain: 'google' service = volumes: ['../../my-malicious-volume/:/internal'] From 896a864b23174c02297d5f1863349a7b7bf19d6d Mon Sep 17 00:00:00 2001 From: jeroenpeeters Date: Thu, 11 May 2017 10:31:45 +0200 Subject: [PATCH 4/6] bumped fix version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ce6f66e..2910690 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "docker-dashboard-agent-compose", - "version": "2.10.1", + "version": "2.10.2", "description": "", "main": "index.js", "scripts": { From f0187dc0ee6a1a16051269adbb664a0917abbd8d Mon Sep 17 00:00:00 2001 From: jeroenpeeters Date: Thu, 11 May 2017 13:01:15 +0200 Subject: [PATCH 5/6] fixed ro/rw postfix bug when no bind volume is present (compose bug). --- src/coffee/compose/actions.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/coffee/compose/actions.coffee b/src/coffee/compose/actions.coffee index ef1a894..1fdbe8f 100644 --- a/src/coffee/compose/actions.coffee +++ b/src/coffee/compose/actions.coffee @@ -42,9 +42,10 @@ module.exports = (config) -> volumePaths = [] for service in _.values composition.services when service.volumes - volumePaths = _.uniq (_.union volumePaths, service.volumes).map (mapping) -> + volumePaths = _.uniq (_.union volumePaths, service.volumes.map (mapping) -> splits = mapping.split(':') - splits[0] if splits.length is 2 + splits[0] if splits.length >= 2 + ) for path in volumePaths when path try From 49e143e56d44bae7143eabb6878910ebc20a2338 Mon Sep 17 00:00:00 2001 From: jeroenpeeters Date: Thu, 11 May 2017 13:01:52 +0200 Subject: [PATCH 6/6] bumped fix version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2910690..4464bb9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "docker-dashboard-agent-compose", - "version": "2.10.2", + "version": "2.10.3", "description": "", "main": "index.js", "scripts": {