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'
Browse files Browse the repository at this point in the history
  • Loading branch information
greyarch committed May 11, 2017
2 parents 21f49f9 + 896a864 commit eec6f5d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/coffee/compose.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,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
5 changes: 3 additions & 2 deletions src/coffee/compose/actions.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -121,16 +121,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 Object.assign {}, standardCfg, dataDir: '/local/data/', domain: 'google'
service = volumes: ['../../my-malicious-volume/:/internal']
Expand Down

0 comments on commit eec6f5d

Please sign in to comment.