29 lines
651 B
Python
29 lines
651 B
Python
from dataclasses import dataclass
|
|
from typing import final
|
|
|
|
from docker_compose.compose.net_args_yaml import NetArgsYaml
|
|
|
|
|
|
@final
|
|
@dataclass(frozen=True, slots=True)
|
|
class NetArgs:
|
|
name: str
|
|
external: bool | None
|
|
|
|
@property
|
|
def as_dict(self) -> NetArgsYaml:
|
|
yaml_dict = NetArgsYaml(
|
|
name=self.name,
|
|
)
|
|
if self.external is not None:
|
|
yaml_dict["external"] = self.external
|
|
return yaml_dict
|
|
|
|
@staticmethod
|
|
def is_proxy_check(name: str) -> bool:
|
|
return name.endswith("proxy")
|
|
|
|
@property
|
|
def is_proxy(self) -> bool:
|
|
return self.is_proxy_check(self.name)
|