Skip to content

Commit

Permalink
support for depends_on
Browse files Browse the repository at this point in the history
  • Loading branch information
lindt committed Mar 22, 2016
1 parent 6c20a0b commit dbde74b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
12 changes: 12 additions & 0 deletions compose_plantuml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def link_graph(self, compose):
result += '[{0}]\n'.format(component)
for source, destination in sorted(self.links(compose)):
result += '[{0}] --> [{1}]\n'.format(source, destination)
for source, destination in sorted(self.dependencies(compose)):
result += '[{0}] ..> [{1}] : depends on\n'.format(source, destination)
return result.strip()

def boundaries(self, compose):
Expand Down Expand Up @@ -60,6 +62,16 @@ def links(compose):
result.append((component_name, link))
return result

@staticmethod
def dependencies(compose):
result = []
components = compose if 'version' not in compose else compose.get('services', {})

for component_name, component in components.items():
for dependency in component.get('depends_on', []):
result.append((component_name, dependency))
return result

@staticmethod
def ports(compose):
result = []
Expand Down
20 changes: 20 additions & 0 deletions features/link_graph.feature
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ Feature: Link Graph
"""

Scenario: Supports Dependencies
Given a file named "compose.yml" with:
"""
version: "2"
services:
first:
depends_on:
- second
second: {}
"""
When I run `bin/compose_plantuml --link-graph compose.yml`
Then it should pass with exactly:
"""
skinparam componentStyle uml2
[first]
[second]
[first] ..> [second] : depends on
"""

Scenario: Suppport for legacy docker-compose format
Given a file named "compose.yml" with:
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def readme():

setup(
name='compose_plantuml',
version='0.0.5',
version='0.0.6',
description='converts docker-compose into plantuml',
long_description=readme(),
url='http://github.com/funkwerk/compose_plantuml',
Expand Down

0 comments on commit dbde74b

Please sign in to comment.