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

Commit

Permalink
augment service names with instance name
Browse files Browse the repository at this point in the history
  • Loading branch information
greyarch committed Jul 25, 2017
1 parent 6524400 commit 6267733
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/coffee/compose.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ module.exports = (config) ->
_addDefaultNetwork: addDefaultNetwork = (doc) ->
doc.networks = appsnet: external: name: config.network.name

_augmentServiceNames: augmentServiceNames = (instance, serviceName, service, doc) ->
doc.services["#{instance}-#{serviceName}"] = service
delete doc.services[serviceName]

augmentCompose: (instance, options, doc) ->
addDefaultNetwork doc
for serviceName, service of doc.services
Expand All @@ -125,6 +129,7 @@ module.exports = (config) ->
addLocaltimeMapping serviceName, service
addDockerMapping serviceName, service
restrictCompose serviceName, service
augmentServiceNames instance, serviceName, service, doc

doc.version = '2.1'
delete doc.volumes
Expand Down
9 changes: 9 additions & 0 deletions tests/coffee/compose.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ describe 'Compose', ->
it 'should add /etc/localtime volume mapping when there are other volumes', ->
localtimeTest volumes: ['volume1', '/mapped:/volume']

describe '_augmentServiceNames', ->
doc =
services:
www: {}
it 'should add instance name to service name', ->
compose(standardCfg)._augmentServiceNames 'myinst', 'www', doc.services.www, doc
assert.deepEqual doc, services:
'myinst-www': {}

describe '_addNetworkContainer', ->
invokeTestSubject = (service, cfgNetContainer) ->
doc = services: {}
Expand Down

0 comments on commit 6267733

Please sign in to comment.