diff --git a/compose_viz/parser.py b/compose_viz/parser.py index 37e8b37..2440bce 100644 --- a/compose_viz/parser.py +++ b/compose_viz/parser.py @@ -6,7 +6,7 @@ from ruamel.yaml import YAML from compose_viz.compose import Compose, Service from compose_viz.extends import Extends from compose_viz.port import Port, Protocol -from compose_viz.volume import AccessMode, Volume, VolumeType +from compose_viz.volume import Volume, VolumeType class Parser: @@ -190,9 +190,7 @@ class Parser: service_volumes.append(Volume(source=spilt_data[0], target=spilt_data[1])) elif len(spilt_data) == 3: service_volumes.append( - Volume( - source=spilt_data[0], target=spilt_data[1], access_mode=AccessMode[spilt_data[2]] - ) + Volume(source=spilt_data[0], target=spilt_data[1], access_mode=spilt_data[2]) ) service_links: List[str] = [] diff --git a/compose_viz/volume.py b/compose_viz/volume.py index f86d203..192ed97 100644 --- a/compose_viz/volume.py +++ b/compose_viz/volume.py @@ -8,17 +8,8 @@ class VolumeType(str, Enum): npipe = "npipe" -class AccessMode(str, Enum): - rw = "rw" - ro = "ro" - z = "z" - Z = "Z" - - class Volume: - def __init__( - self, source: str, target: str, type: VolumeType = VolumeType.volume, access_mode: AccessMode = AccessMode.rw - ): + def __init__(self, source: str, target: str, type: VolumeType = VolumeType.volume, access_mode: str = "rw"): self._source = source self._target = target self._type = type diff --git a/tests/test_parse_file.py b/tests/test_parse_file.py index e760c9e..d624a43 100644 --- a/tests/test_parse_file.py +++ b/tests/test_parse_file.py @@ -5,7 +5,7 @@ from compose_viz.extends import Extends from compose_viz.parser import Parser from compose_viz.port import Port, Protocol from compose_viz.service import Service -from compose_viz.volume import AccessMode, Volume, VolumeType +from compose_viz.volume import Volume, VolumeType @pytest.mark.parametrize( @@ -219,7 +219,7 @@ from compose_viz.volume import AccessMode, Volume, VolumeType Volume( source="cli-volume", target="/var/lib/backup/data", - access_mode=AccessMode.ro, + access_mode="ro,z", ), ], ), diff --git a/tests/test_volume.py b/tests/test_volume.py index d1d4cac..b3651ec 100644 --- a/tests/test_volume.py +++ b/tests/test_volume.py @@ -1,4 +1,4 @@ -from compose_viz.volume import AccessMode, Volume, VolumeType +from compose_viz.volume import Volume, VolumeType def test_volume_init_normal() -> None: @@ -8,7 +8,7 @@ def test_volume_init_normal() -> None: assert v.source == "./foo" assert v.target == "./bar" assert v.type == VolumeType.volume - assert v.access_mode == AccessMode.rw + assert v.access_mode == "rw" except Exception as e: assert False, e @@ -20,18 +20,18 @@ def test_volume_with_type() -> None: assert v.source == "./foo" assert v.target == "./bar" assert v.type == VolumeType.bind - assert v.access_mode == AccessMode.rw + assert v.access_mode == "rw" except Exception as e: assert False, e def test_volume_with_access_mode() -> None: try: - v = Volume(source="./foo", target="./bar", access_mode=AccessMode.ro) + v = Volume(source="./foo", target="./bar", access_mode="ro,z") assert v.source == "./foo" assert v.target == "./bar" assert v.type == VolumeType.volume - assert v.access_mode == AccessMode.ro + assert v.access_mode == "ro,z" except Exception as e: assert False, e diff --git a/tests/ymls/volumes/docker-compose.yml b/tests/ymls/volumes/docker-compose.yml index dd004c1..4edb77c 100644 --- a/tests/ymls/volumes/docker-compose.yml +++ b/tests/ymls/volumes/docker-compose.yml @@ -11,7 +11,7 @@ services: common: image: busybox volumes: - - common-volume:/var/lib/backup/data:rw + - common-volume:/var/lib/backup/data:rw,z cli: extends: service: common