From 4433e17969200b7cd9dc463d929eb4eef0928ce2 Mon Sep 17 00:00:00 2001 From: Oleksandr Halushko Date: Tue, 22 Mar 2022 21:40:11 +0100 Subject: [PATCH 1/3] Use README.md instead of README.rst --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 53b6f40..861e824 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ def readme(): - with open('README.rst') as file: + with open('README.md') as file: return file.read() From b8bec7441ea87a01ce585c70736a7478ffdb87d9 Mon Sep 17 00:00:00 2001 From: Oleksandr Halushko Date: Tue, 22 Mar 2022 21:41:02 +0100 Subject: [PATCH 2/3] Use FullLoader from pyyaml See https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation for context. --- compose_plantuml/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compose_plantuml/__init__.py b/compose_plantuml/__init__.py index 8adb17d..fc55a18 100755 --- a/compose_plantuml/__init__.py +++ b/compose_plantuml/__init__.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 from yaml import load +from yaml import FullLoader class ComposePlantuml: @@ -8,7 +9,7 @@ def __init__(self): pass def parse(self, data): - return load(data) + return load(data, Loader=FullLoader) def link_graph(self, compose, notes=False): result = 'skinparam componentStyle uml2\n' From 1bd946fe1271dd697d59e7c55f4ec6ca754dd8f4 Mon Sep 17 00:00:00 2001 From: Oleksandr Halushko Date: Tue, 22 Mar 2022 21:42:10 +0100 Subject: [PATCH 3/3] Handle case when volume is dictionary --- compose_plantuml/__init__.py | 40 +++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/compose_plantuml/__init__.py b/compose_plantuml/__init__.py index fc55a18..ca334f9 100755 --- a/compose_plantuml/__init__.py +++ b/compose_plantuml/__init__.py @@ -117,8 +117,13 @@ def is_volume_used(compose, volume): for _, component in components.items(): for volume_name in component.get('volumes', {}): - if volume_name.startswith('{0}:'.format(volume)): - return True + if isinstance(volume_name, dict): + if volume_name['target'].startswith('{0}:'.format(volume)): + return True + else: + if volume_name.startswith('{0}:'.format(volume)): + return True + return False @staticmethod @@ -156,10 +161,17 @@ def has_service_volumes(compose, service): if 'volumes' not in component: return False for volume in component['volumes']: - if volume.startswith('/'): - continue - if ':' in volume: - return True + if isinstance(volume, dict): + if volume['target'].startswith('/'): + continue + if ':' in volume: + return True + else: + if volume.startswith('/'): + continue + if ':' in volume: + return True + return False @staticmethod @@ -229,8 +241,12 @@ def volume_usage(compose, volume): for component_name, component in components.items(): for volume_name in component.get('volumes', {}): - if not volume_name.startswith('{0}:'.format(volume)): - continue + if isinstance(volume_name, dict): + if not volume_name['target'].startswith('{0}:'.format(volume)): + continue + else: + if not volume_name.startswith('{0}:'.format(volume)): + continue result.append(volume_name.split(':')[1]) return result @@ -241,7 +257,11 @@ def service_using_path(compose, volume): for component_name, component in components.items(): for volume_name in component.get('volumes', {}): - if not volume_name.startswith('{0}:'.format(volume)): - continue + if isinstance(volume_name, dict): + if not volume_name['target'].startswith('{0}:'.format(volume)): + continue + else: + if not volume_name.startswith('{0}:'.format(volume)): + continue result.append((component_name, volume_name.split(':')[1])) return result