Compare commits
No commits in common. "b17b23cbf816bcea5342d48c4f7bebd9a8dc830e" and "aa4d3b70ed33f1e20acb29a46860d79e0f48121f" have entirely different histories.
b17b23cbf8
...
aa4d3b70ed
15 changed files with 63 additions and 293 deletions
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
@ -26,9 +26,9 @@ jobs:
|
||||||
python-version: '3.10.4'
|
python-version: '3.10.4'
|
||||||
|
|
||||||
- name: Setup Poetry
|
- name: Setup Poetry
|
||||||
uses: abatilo/actions-poetry@v3
|
uses: Gr1N/setup-poetry@v7
|
||||||
with:
|
with:
|
||||||
poetry-version: 1.8.2
|
poetry-version: 1.2.1
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
|
|
4
.github/workflows/release-tagged-version.yml
vendored
4
.github/workflows/release-tagged-version.yml
vendored
|
@ -32,9 +32,9 @@ jobs:
|
||||||
python-version: '3.10.4'
|
python-version: '3.10.4'
|
||||||
|
|
||||||
- name: Setup Poetry
|
- name: Setup Poetry
|
||||||
uses: abatilo/actions-poetry@v3
|
uses: Gr1N/setup-poetry@v7
|
||||||
with:
|
with:
|
||||||
poetry-version: 1.8.2
|
poetry-version: 1.2.1
|
||||||
- run: |
|
- run: |
|
||||||
poetry install --no-root
|
poetry install --no-root
|
||||||
poetry build
|
poetry build
|
||||||
|
|
79
.github/workflows/update-submodules.yml
vendored
79
.github/workflows/update-submodules.yml
vendored
|
@ -1,79 +0,0 @@
|
||||||
name: Update Submodules
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ dev ]
|
|
||||||
schedule:
|
|
||||||
- cron: '0 0 * * *'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check_submodules:
|
|
||||||
name: Check Submodules
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
has_changes: ${{ steps.check.outputs.has_changes }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout Code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Create new branch and push changes
|
|
||||||
run: |
|
|
||||||
git submodule update --remote
|
|
||||||
|
|
||||||
- name: Check for changes
|
|
||||||
id: check
|
|
||||||
run: |
|
|
||||||
git diff --quiet || echo "::set-output name=has_changes::true"
|
|
||||||
|
|
||||||
update_submodules:
|
|
||||||
name: Update Submodules
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [check_submodules]
|
|
||||||
if: needs.check_submodules.outputs.has_changes == 'true'
|
|
||||||
steps:
|
|
||||||
|
|
||||||
- name: Setup Python 3.10.4
|
|
||||||
uses: actions/setup-python@v3
|
|
||||||
with:
|
|
||||||
python-version: '3.10.4'
|
|
||||||
|
|
||||||
- name: Setup Poetry
|
|
||||||
uses: abatilo/actions-poetry@v3
|
|
||||||
with:
|
|
||||||
poetry-version: 1.8.2
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
|
||||||
run: |
|
|
||||||
poetry install --no-root
|
|
||||||
|
|
||||||
- name: Update Submodule
|
|
||||||
run: |
|
|
||||||
datamodel-codegen --input ./compose-spec/schema/compose-spec.json --output-model-type pydantic_v2.BaseModel --field-constraints --output ./compose_viz/spec/compose_spec.py
|
|
||||||
poetry run python ./update-submodules.py
|
|
||||||
|
|
||||||
- name: Execute pre-commit
|
|
||||||
continue-on-error: true
|
|
||||||
run: |
|
|
||||||
poetry run python -m pre_commit run --all-files
|
|
||||||
|
|
||||||
- name: Push changes
|
|
||||||
run: |
|
|
||||||
git config user.name github-actions
|
|
||||||
git config user.email github-actions@github.com
|
|
||||||
git checkout -b $GITHUB_RUN_ID
|
|
||||||
git commit -am "chore: update submodules"
|
|
||||||
git push --set-upstream origin $GITHUB_RUN_ID
|
|
||||||
|
|
||||||
- name: File PR
|
|
||||||
uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
script: |
|
|
||||||
await github.rest.pulls.create({
|
|
||||||
owner: '${{ github.repository_owner }}',
|
|
||||||
repo: 'compose-viz',
|
|
||||||
head: process.env.GITHUB_RUN_ID,
|
|
||||||
base: 'main',
|
|
||||||
title: `chore: update submodules (${process.env.GITHUB_RUN_ID})`,
|
|
||||||
body: `Please add the version tag to trigger the release.`,
|
|
||||||
});
|
|
|
@ -122,7 +122,6 @@ Check out the result [here](https://github.com/compose-viz/compose-viz/blob/main
|
||||||
| `-o, --output-filename FILENAME` | Output filename for the generated visualization file. [default: compose-viz] |
|
| `-o, --output-filename FILENAME` | Output filename for the generated visualization file. [default: compose-viz] |
|
||||||
| `-m, --format FORMAT` | Output format for the generated visualization file. See [supported formats](https://github.com/compose-viz/compose-viz/blob/main/compose_viz/models/viz_formats.py). [default: png] |
|
| `-m, --format FORMAT` | Output format for the generated visualization file. See [supported formats](https://github.com/compose-viz/compose-viz/blob/main/compose_viz/models/viz_formats.py). [default: png] |
|
||||||
| `-r, --root-service SERVICE_NAME` | Root of the service tree (convenient for large compose yamls) |
|
| `-r, --root-service SERVICE_NAME` | Root of the service tree (convenient for large compose yamls) |
|
||||||
| `-l, --legend` | Include a legend in the visualization. |
|
|
||||||
| `-v, --version` | Show the version of compose-viz. |
|
| `-v, --version` | Show the version of compose-viz. |
|
||||||
| `--help` | Show help and exit. |
|
| `--help` | Show help and exit. |
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
__app_name__ = "compose_viz"
|
__app_name__ = "compose_viz"
|
||||||
__version__ = "0.3.2"
|
__version__ = "0.3.1"
|
||||||
|
|
|
@ -42,12 +42,6 @@ def compose_viz(
|
||||||
"-r",
|
"-r",
|
||||||
help="Root of the service tree (convenient for large compose yamls)",
|
help="Root of the service tree (convenient for large compose yamls)",
|
||||||
),
|
),
|
||||||
include_legend: bool = typer.Option(
|
|
||||||
False,
|
|
||||||
"--legend",
|
|
||||||
"-l",
|
|
||||||
help="Include a legend in the visualization.",
|
|
||||||
),
|
|
||||||
_: Optional[bool] = typer.Option(
|
_: Optional[bool] = typer.Option(
|
||||||
None,
|
None,
|
||||||
"--version",
|
"--version",
|
||||||
|
@ -63,7 +57,7 @@ def compose_viz(
|
||||||
if compose:
|
if compose:
|
||||||
typer.echo(f"Successfully parsed {input_path}")
|
typer.echo(f"Successfully parsed {input_path}")
|
||||||
|
|
||||||
Graph(compose, output_filename, include_legend).render(format)
|
Graph(compose, output_filename).render(format)
|
||||||
|
|
||||||
raise typer.Exit()
|
raise typer.Exit()
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ from typing import Optional
|
||||||
import graphviz
|
import graphviz
|
||||||
|
|
||||||
from compose_viz.models.compose import Compose
|
from compose_viz.models.compose import Compose
|
||||||
from compose_viz.models.port import AppProtocol, Protocol
|
|
||||||
|
|
||||||
|
|
||||||
def apply_vertex_style(type: str) -> dict:
|
def apply_vertex_style(type: str) -> dict:
|
||||||
|
@ -70,58 +69,12 @@ def apply_edge_style(type: str) -> dict:
|
||||||
|
|
||||||
|
|
||||||
class Graph:
|
class Graph:
|
||||||
def __init__(self, compose: Compose, filename: str, include_legend: bool) -> None:
|
def __init__(self, compose: Compose, filename: str) -> None:
|
||||||
self.dot = graphviz.Digraph()
|
self.dot = graphviz.Digraph()
|
||||||
self.dot.attr("graph", background="#ffffff", pad="0.5", ratio="fill")
|
self.dot.attr("graph", background="#ffffff", pad="0.5", ratio="fill")
|
||||||
self.compose = compose
|
self.compose = compose
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
|
|
||||||
if include_legend:
|
|
||||||
self.dot.attr(rankdir="LR")
|
|
||||||
|
|
||||||
with self.dot.subgraph(name="cluster_edge_") as edge:
|
|
||||||
edge.attr(label="Edge")
|
|
||||||
edge.node("line_0_l", style="invis")
|
|
||||||
edge.node("line_0_r", style="invis")
|
|
||||||
edge.edge("line_0_l", "line_0_r", label="exposes", **apply_edge_style("exposes"))
|
|
||||||
|
|
||||||
edge.node("line_1_l", style="invis")
|
|
||||||
edge.node("line_1_r", style="invis")
|
|
||||||
edge.edge("line_1_l", "line_1_r", label="links", **apply_edge_style("links"))
|
|
||||||
|
|
||||||
edge.node("line_2_l", style="invis")
|
|
||||||
edge.node("line_2_r", style="invis")
|
|
||||||
edge.edge("line_2_l", "line_2_r", label="volumes_rw", **apply_edge_style("volumes_rw"))
|
|
||||||
|
|
||||||
edge.node("line_3_l", style="invis")
|
|
||||||
edge.node("line_3_r", style="invis")
|
|
||||||
edge.edge("line_3_l", "line_3_r", label="volumes_ro", **apply_edge_style("volumes_ro"))
|
|
||||||
|
|
||||||
edge.node("line_4_l", style="invis")
|
|
||||||
edge.node("line_4_r", style="invis")
|
|
||||||
edge.edge("line_4_l", "line_4_r", label="depends_on", **apply_edge_style("depends_on"))
|
|
||||||
|
|
||||||
edge.node("line_5_l", style="invis")
|
|
||||||
edge.node("line_5_r", style="invis")
|
|
||||||
edge.edge("line_5_l", "line_5_r", label="extends", **apply_edge_style("extends"))
|
|
||||||
|
|
||||||
with self.dot.subgraph(name="cluster_node_") as node:
|
|
||||||
node.attr(label="Node")
|
|
||||||
node.node("service", shape="component", label="Service\n(image)")
|
|
||||||
node.node("volume", shape="cylinder", label="Volume")
|
|
||||||
node.node("network", shape="pentagon", label="Network")
|
|
||||||
node.node("port", shape="circle", label="Port")
|
|
||||||
node.node("env_file", shape="tab", label="Env File")
|
|
||||||
node.node("profile", shape="invhouse", label="Profile")
|
|
||||||
node.node("cgroup", shape="diamond", label="CGroupe")
|
|
||||||
node.node("device", shape="box3d", label="Device")
|
|
||||||
|
|
||||||
node.body.append("{ rank=source;service network env_file cgroup }")
|
|
||||||
|
|
||||||
self.dot.node("inv", style="invis")
|
|
||||||
self.dot.edge("inv", "network", style="invis")
|
|
||||||
self.dot.edge("port", "line_2_l", style="invis")
|
|
||||||
|
|
||||||
def validate_name(self, name: str) -> str:
|
def validate_name(self, name: str) -> str:
|
||||||
# graphviz does not allow ':' in node name
|
# graphviz does not allow ':' in node name
|
||||||
transTable = name.maketrans({":": ""})
|
transTable = name.maketrans({":": ""})
|
||||||
|
@ -164,14 +117,7 @@ class Graph:
|
||||||
self.add_edge(expose, service.name, "exposes")
|
self.add_edge(expose, service.name, "exposes")
|
||||||
for port in service.ports:
|
for port in service.ports:
|
||||||
self.add_vertex(port.host_port, "port", lable=port.host_port)
|
self.add_vertex(port.host_port, "port", lable=port.host_port)
|
||||||
self.add_edge(
|
self.add_edge(port.host_port, service.name, "links", lable=port.container_port)
|
||||||
port.host_port,
|
|
||||||
service.name,
|
|
||||||
"links",
|
|
||||||
lable=port.container_port
|
|
||||||
+ (("/" + port.protocol) if port.protocol != Protocol.any.value else "")
|
|
||||||
+ (("\n(" + port.app_protocol + ")") if port.app_protocol != AppProtocol.na.value else ""),
|
|
||||||
)
|
|
||||||
for env_file in service.env_file:
|
for env_file in service.env_file:
|
||||||
self.add_vertex(env_file, "env_file")
|
self.add_vertex(env_file, "env_file")
|
||||||
self.add_edge(env_file, service.name, "env_file")
|
self.add_edge(env_file, service.name, "env_file")
|
||||||
|
|
|
@ -7,27 +7,11 @@ class Protocol(str, Enum):
|
||||||
any = "any"
|
any = "any"
|
||||||
|
|
||||||
|
|
||||||
class AppProtocol(str, Enum):
|
|
||||||
rest = "REST"
|
|
||||||
mqtt = "MQTT"
|
|
||||||
wbsock = "WebSocket"
|
|
||||||
http = "http"
|
|
||||||
https = "https"
|
|
||||||
na = "NA"
|
|
||||||
|
|
||||||
|
|
||||||
class Port:
|
class Port:
|
||||||
def __init__(
|
def __init__(self, host_port: str, container_port: str, protocol: Protocol = Protocol.any):
|
||||||
self,
|
|
||||||
host_port: str,
|
|
||||||
container_port: str,
|
|
||||||
protocol: Protocol = Protocol.any,
|
|
||||||
app_protocol: AppProtocol = AppProtocol.na,
|
|
||||||
):
|
|
||||||
self._host_port = host_port
|
self._host_port = host_port
|
||||||
self._container_port = container_port
|
self._container_port = container_port
|
||||||
self._protocol = protocol
|
self._protocol = protocol
|
||||||
self._app_protocol = app_protocol
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def host_port(self):
|
def host_port(self):
|
||||||
|
@ -40,7 +24,3 @@ class Port:
|
||||||
@property
|
@property
|
||||||
def protocol(self):
|
def protocol(self):
|
||||||
return self._protocol
|
return self._protocol
|
||||||
|
|
||||||
@property
|
|
||||||
def app_protocol(self):
|
|
||||||
return self._app_protocol
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
import re
|
import re
|
||||||
from typing import Any, Dict, List, Optional, Union
|
from typing import Any, Dict, List, Optional, Union
|
||||||
|
|
||||||
|
from pydantic import ValidationError
|
||||||
from pydantic_yaml import parse_yaml_raw_as
|
from pydantic_yaml import parse_yaml_raw_as
|
||||||
|
|
||||||
import compose_viz.spec.compose_spec as spec
|
import compose_viz.spec.compose_spec as spec
|
||||||
from compose_viz.models.compose import Compose, Service
|
from compose_viz.models.compose import Compose, Service
|
||||||
from compose_viz.models.device import Device
|
from compose_viz.models.device import Device
|
||||||
from compose_viz.models.extends import Extends
|
from compose_viz.models.extends import Extends
|
||||||
from compose_viz.models.port import AppProtocol, Port, Protocol
|
from compose_viz.models.port import Port, Protocol
|
||||||
from compose_viz.models.volume import Volume, VolumeType
|
from compose_viz.models.volume import Volume, VolumeType
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ class Parser:
|
||||||
with open(file_path, "r") as file:
|
with open(file_path, "r") as file:
|
||||||
file_content = file.read()
|
file_content = file.read()
|
||||||
compose_data = parse_yaml_raw_as(spec.ComposeSpecification, file_content)
|
compose_data = parse_yaml_raw_as(spec.ComposeSpecification, file_content)
|
||||||
except Exception as e:
|
except ValidationError as e:
|
||||||
raise RuntimeError(f"Error parsing file '{file_path}': {e}")
|
raise RuntimeError(f"Error parsing file '{file_path}': {e}")
|
||||||
|
|
||||||
services: List[Service] = []
|
services: List[Service] = []
|
||||||
|
@ -101,13 +102,12 @@ class Parser:
|
||||||
host_port: Optional[str] = None
|
host_port: Optional[str] = None
|
||||||
container_port: Optional[str] = None
|
container_port: Optional[str] = None
|
||||||
protocol: Optional[str] = None
|
protocol: Optional[str] = None
|
||||||
app_protocol: Optional[str] = None
|
|
||||||
|
|
||||||
if type(port_data) is float:
|
if type(port_data) is float:
|
||||||
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:
|
||||||
|
@ -128,15 +128,17 @@ class Parser:
|
||||||
elif type(port_data) is spec.Ports:
|
elif type(port_data) is spec.Ports:
|
||||||
assert port_data.target is not None, "Invalid port format, aborting."
|
assert port_data.target is not None, "Invalid port format, aborting."
|
||||||
|
|
||||||
if type(port_data.published) is str or type(port_data.published) is int:
|
# ruamel.yaml does not parse port as int
|
||||||
host_port = str(port_data.published)
|
assert type(port_data.published) is not int
|
||||||
|
|
||||||
|
if type(port_data.published) is str:
|
||||||
|
host_port = port_data.published
|
||||||
|
|
||||||
if type(port_data.target) is int:
|
if type(port_data.target) is int:
|
||||||
container_port = str(port_data.target)
|
container_port = str(port_data.target)
|
||||||
|
|
||||||
host_ip = port_data.host_ip
|
host_ip = port_data.host_ip
|
||||||
protocol = port_data.protocol
|
protocol = port_data.protocol
|
||||||
app_protocol = port_data.app_protocol
|
|
||||||
|
|
||||||
if container_port is not None and host_port is None:
|
if container_port is not None and host_port is None:
|
||||||
host_port = container_port
|
host_port = container_port
|
||||||
|
@ -152,15 +154,11 @@ class Parser:
|
||||||
if protocol is None:
|
if protocol is None:
|
||||||
protocol = "any"
|
protocol = "any"
|
||||||
|
|
||||||
if app_protocol is None:
|
|
||||||
app_protocol = "na"
|
|
||||||
|
|
||||||
service_ports.append(
|
service_ports.append(
|
||||||
Port(
|
Port(
|
||||||
host_port=host_port,
|
host_port=host_port,
|
||||||
container_port=container_port,
|
container_port=container_port,
|
||||||
protocol=Protocol[protocol],
|
protocol=Protocol[protocol],
|
||||||
app_protocol=AppProtocol[app_protocol],
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -217,16 +215,11 @@ class Parser:
|
||||||
|
|
||||||
env_file: List[str] = []
|
env_file: List[str] = []
|
||||||
if service_data.env_file is not None:
|
if service_data.env_file is not None:
|
||||||
if type(service_data.env_file.root) is str:
|
if type(service_data.env_file) is spec.StringOrList:
|
||||||
env_file = [service_data.env_file.root]
|
if type(service_data.env_file.root) is spec.ListOfStrings:
|
||||||
elif type(service_data.env_file.root) is list:
|
env_file = service_data.env_file.root.root
|
||||||
for env_file_data in service_data.env_file.root:
|
elif type(service_data.env_file.root) is str:
|
||||||
if type(env_file_data) is str:
|
env_file.append(service_data.env_file.root)
|
||||||
env_file.append(env_file_data)
|
|
||||||
elif type(env_file_data) is spec.EnvFilePath:
|
|
||||||
env_file.append(env_file_data.path)
|
|
||||||
else:
|
|
||||||
print(f"Invalid env_file data: {service_data.env_file.root}")
|
|
||||||
|
|
||||||
expose: List[str] = []
|
expose: List[str] = []
|
||||||
if service_data.expose is not None:
|
if service_data.expose is not None:
|
||||||
|
|
|
@ -42,13 +42,7 @@ services:
|
||||||
extends:
|
extends:
|
||||||
service: frontend
|
service: frontend
|
||||||
ports:
|
ports:
|
||||||
- name: web-secured
|
- "8000:5010"
|
||||||
target: 443
|
|
||||||
host_ip: 127.0.0.1
|
|
||||||
published: "8083-9000"
|
|
||||||
protocol: tcp
|
|
||||||
app_protocol: wbsock
|
|
||||||
mode : host
|
|
||||||
links:
|
links:
|
||||||
- "db:database"
|
- "db:database"
|
||||||
cgroup_parent: awesome-parent
|
cgroup_parent: awesome-parent
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "compose-viz"
|
name = "compose-viz"
|
||||||
version = "0.3.2"
|
version = "0.3.1"
|
||||||
description = "A compose file visualization tool that supports compose-spec and allows you to gernerate graph in several formats."
|
description = "A compose file visualization tool that supports compose-spec and allows you to gernerate graph in several formats."
|
||||||
authors = ["Xyphuz Wu <xyphuzwu@gmail.com>"]
|
authors = ["Xyphuz Wu <xyphuzwu@gmail.com>"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
|
@ -176,10 +176,6 @@ 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",
|
||||||
|
|
|
@ -26,3 +26,5 @@ networks:
|
||||||
front-tier:
|
front-tier:
|
||||||
back-tier:
|
back-tier:
|
||||||
admin:
|
admin:
|
||||||
|
traefik-public:
|
||||||
|
external: true
|
||||||
|
|
|
@ -12,7 +12,6 @@ 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
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
def revise_naming_convention():
|
|
||||||
name_mapping = {
|
|
||||||
"EnvFile1": "EnvFilePath",
|
|
||||||
"Volume1": "AdditionalVolumeOption",
|
|
||||||
"External": "ExternalVolumeNetwork",
|
|
||||||
"External2": "ExternalConfig",
|
|
||||||
}
|
|
||||||
|
|
||||||
spec_content: str
|
|
||||||
with open("./compose_viz/spec/compose_spec.py", "r+") as spec_file:
|
|
||||||
spec_content: str = spec_file.read()
|
|
||||||
|
|
||||||
for origin_name, new_name in name_mapping.items():
|
|
||||||
spec_content = re.sub(rf"\b{origin_name}\b", new_name, spec_content)
|
|
||||||
|
|
||||||
spec_file.seek(0)
|
|
||||||
spec_file.write(spec_content)
|
|
||||||
|
|
||||||
print("Revised naming convention successfully!")
|
|
||||||
|
|
||||||
|
|
||||||
def update_version_number():
|
|
||||||
new_version_number: str
|
|
||||||
with open("./compose_viz/__init__.py", "r+") as init_file:
|
|
||||||
init_content: str = init_file.read()
|
|
||||||
|
|
||||||
version_number = init_content.split(" ")[-1].replace('"', "").strip()
|
|
||||||
major, minor, patch = version_number.split(".")
|
|
||||||
new_version_number = f"{major}.{minor}.{int(patch) + 1}"
|
|
||||||
|
|
||||||
init_file.seek(0)
|
|
||||||
init_file.write(
|
|
||||||
f"""__app_name__ = "compose_viz"
|
|
||||||
__version__ = "{new_version_number}"
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
with open("./pyproject.toml", "r+") as pyproject_file:
|
|
||||||
pyproject_content: str = pyproject_file.read()
|
|
||||||
|
|
||||||
pyproject_content = pyproject_content.replace(version_number, new_version_number)
|
|
||||||
|
|
||||||
pyproject_file.seek(0)
|
|
||||||
pyproject_file.write(pyproject_content)
|
|
||||||
|
|
||||||
print(f"Version number updated to {new_version_number} successfully!")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
revise_naming_convention()
|
|
||||||
update_version_number()
|
|
Loading…
Reference in a new issue