diff --git a/package.json b/package.json index 9c61227..4464bb9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "docker-dashboard-agent-compose", - "version": "2.10.0", + "version": "2.10.3", "description": "", "main": "index.js", "scripts": { diff --git a/src/coffee/compose.coffee b/src/coffee/compose.coffee index 46ffb61..95a0103 100644 --- a/src/coffee/compose.coffee +++ b/src/coffee/compose.coffee @@ -50,14 +50,14 @@ 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] 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..1fdbe8f 100644 --- a/src/coffee/compose/actions.coffee +++ b/src/coffee/compose/actions.coffee @@ -42,10 +42,12 @@ module.exports = (config) -> volumePaths = [] for service in _.values composition.services when service.volumes - volumePaths = _.uniq (_.union volumePaths, service.volumes).map (mapping) -> - mapping.split(':')[0] + volumePaths = _.uniq (_.union volumePaths, service.volumes.map (mapping) -> + splits = mapping.split(':') + splits[0] if splits.length >= 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..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 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 (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']