* fix: correcting regex for formatting string #51 
* ci: add cron.yml

---------

Co-authored-by: Xyphuz <38447974+wst24365888@users.noreply.github.com>
This commit is contained in:
Cheng Chih Yuan 2024-04-28 01:34:03 +08:00 committed by GitHub
parent 0ffcc16b61
commit 36d18a6300
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 50 additions and 1 deletions

View file

@ -25,6 +25,10 @@ jobs:
with: with:
python-version: '3.10.4' python-version: '3.10.4'
- name: Changing naming convention
run: |
python3 naming.py
- name: Setup Poetry - name: Setup Poetry
uses: abatilo/actions-poetry@v3 uses: abatilo/actions-poetry@v3
with: with:

20
.github/workflows/cron.yml vendored Normal file
View file

@ -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

View file

@ -107,7 +107,7 @@ class Parser:
container_port = str(int(port_data)) container_port = str(int(port_data))
host_port = f"0.0.0.0:{container_port}" host_port = f"0.0.0.0:{container_port}"
elif type(port_data) is str: elif type(port_data) is str:
regex = r"((?P<host_ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:)|:)?((?P<host_port>\d+(\-\d+)?):)?((?P<container_port>\d+(\-\d+)?))?(/(?P<protocol>\w+))?" # noqa: E501 regex = r"((?P<host_ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:|(\$\{([^}]+)\}):)|:|)?((?P<host_port>\d+(\-\d+)?):)?((?P<container_port>\d+(\-\d+)?))?(/(?P<protocol>\w+))?" # noqa: E501
match = re.match(regex, port_data) match = re.match(regex, port_data)
if match: if match:

20
naming.py Normal file
View file

@ -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!")

View file

@ -176,6 +176,10 @@ from compose_viz.parser import Parser
host_port="0.0.0.0:7777", host_port="0.0.0.0:7777",
container_port="7777", container_port="7777",
), ),
Port(
host_port="${BIND_IP:-127.0.0.1}:8080",
container_port="8080",
),
Port( Port(
host_port="127.0.0.1:8080", host_port="127.0.0.1:8080",
container_port="80", container_port="80",

View file

@ -12,6 +12,7 @@ services:
- "127.0.0.1:5000-5010:5000-5010" - "127.0.0.1:5000-5010:5000-5010"
- "6060:6060/udp" - "6060:6060/udp"
- ":7777" - ":7777"
- "${BIND_IP:-127.0.0.1}:8080:8080"
- target: 80 - target: 80
host_ip: 127.0.0.1 host_ip: 127.0.0.1
published: 8080 published: 8080