Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into startchecks
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenpeeters committed May 11, 2017
2 parents 7a7be6c + 49e143e commit 0d5899d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docker-dashboard-agent-compose",
"version": "2.10.0",
"version": "2.10.3",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/coffee/compose.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/coffee/compose/actions.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/coffee/compose.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit 0d5899d

Please sign in to comment.