diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d3b3df..2558da5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,10 @@ jobs: with: python-version: '3.10.4' + - name: Changing naming convention + run: | + python3 naming.py + - name: Setup Poetry uses: abatilo/actions-poetry@v3 with: diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml new file mode 100644 index 0000000..c3e1aab --- /dev/null +++ b/.github/workflows/cron.yml @@ -0,0 +1,20 @@ +name: CRON + +on: + schedule: + - cron: '0 0 * * *' + +jobs: +#renew git submodule + update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: update compose-spec submodule + run: | + git submodule update --init --recursive + git submodule update --remote --recursive + - name: Commit changes + run: | + git commit -am "Update submodules" || echo "No changes to commit" + git push diff --git a/compose_viz/parser.py b/compose_viz/parser.py index 0539f0f..82fab0c 100644 --- a/compose_viz/parser.py +++ b/compose_viz/parser.py @@ -107,7 +107,7 @@ class Parser: container_port = str(int(port_data)) host_port = f"0.0.0.0:{container_port}" elif type(port_data) is str: - regex = r"((?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:)|:)?((?P\d+(\-\d+)?):)?((?P\d+(\-\d+)?))?(/(?P\w+))?" # noqa: E501 + regex = r"((?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:|(\$\{([^}]+)\}):)|:|)?((?P\d+(\-\d+)?):)?((?P\d+(\-\d+)?))?(/(?P\w+))?" # noqa: E501 match = re.match(regex, port_data) if match: diff --git a/naming.py b/naming.py new file mode 100644 index 0000000..f1ecc72 --- /dev/null +++ b/naming.py @@ -0,0 +1,20 @@ +def revise_naming_convention(): + name_mapping = { + "EnvFile1": "EnvFilePath", + "Volume1": "AdditionalVolumeOption", + "External": "ExternalVolumeNetwork", + "External1": "ExternalConfig", + } + + with open("./compose_viz/spec/compose_spec.py", "r") as spec_file: + spec_content = spec_file.read() + + for origin_name, new_name in name_mapping.items(): + spec_content.replace(origin_name, new_name) + + return + + +if __name__ == "__main__": + revise_naming_convention() + print("Revised naming convention successfully!") diff --git a/tests/test_parse_file.py b/tests/test_parse_file.py index 255d750..2526330 100644 --- a/tests/test_parse_file.py +++ b/tests/test_parse_file.py @@ -176,6 +176,10 @@ from compose_viz.parser import Parser host_port="0.0.0.0:7777", container_port="7777", ), + Port( + host_port="${BIND_IP:-127.0.0.1}:8080", + container_port="8080", + ), Port( host_port="127.0.0.1:8080", container_port="80", diff --git a/tests/ymls/ports/docker-compose.yml b/tests/ymls/ports/docker-compose.yml index 725e10a..72b8599 100644 --- a/tests/ymls/ports/docker-compose.yml +++ b/tests/ymls/ports/docker-compose.yml @@ -12,6 +12,7 @@ services: - "127.0.0.1:5000-5010:5000-5010" - "6060:6060/udp" - ":7777" + - "${BIND_IP:-127.0.0.1}:8080:8080" - target: 80 host_ip: 127.0.0.1 published: 8080