mirror of
https://github.com/thatmattlove/hyperglass.git
synced 2026-01-17 00:38:06 +00:00
fix container file handling
This commit is contained in:
parent
58b51b7c8e
commit
594d2e90f8
4 changed files with 18 additions and 11 deletions
|
|
@ -7,6 +7,7 @@ ENV HYPERGLASS_DEBUG=false
|
||||||
ENV HYPERGLASS_DEV_MODE=false
|
ENV HYPERGLASS_DEV_MODE=false
|
||||||
ENV HYPERGLASS_REDIS_HOST=redis
|
ENV HYPERGLASS_REDIS_HOST=redis
|
||||||
ENV HYPEGLASS_DISABLE_UI=true
|
ENV HYPEGLASS_DISABLE_UI=true
|
||||||
|
ENV HYPERGLASS_CONTAINER=true
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
FROM base as ui
|
FROM base as ui
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ services:
|
||||||
- HYPERGLASS_DEV_MODE=${HYPERGLASS_DEV_MODE-false}
|
- HYPERGLASS_DEV_MODE=${HYPERGLASS_DEV_MODE-false}
|
||||||
- HYPERGLASS_REDIS_HOST=${HYPERGLASS_REDIS_HOST-redis}
|
- HYPERGLASS_REDIS_HOST=${HYPERGLASS_REDIS_HOST-redis}
|
||||||
- HYPEGLASS_DISABLE_UI=${HYPEGLASS_DISABLE_UI-false}
|
- HYPEGLASS_DISABLE_UI=${HYPEGLASS_DISABLE_UI-false}
|
||||||
|
- HYPERGLASS_CONTAINER=${HYPERGLASS_CONTAINER-true}
|
||||||
|
- HYPERGLASS_ORIGINAL_APP_PATH=${HYPERGLASS_APP_PATH}
|
||||||
build: .
|
build: .
|
||||||
ports:
|
ports:
|
||||||
- "${HYPERGLASS_PORT-8001}:${HYPERGLASS_PORT-8001}"
|
- "${HYPERGLASS_PORT-8001}:${HYPERGLASS_PORT-8001}"
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ from hyperglass.types import Series
|
||||||
|
|
||||||
MultiModelT = t.TypeVar("MultiModelT", bound=BaseModel)
|
MultiModelT = t.TypeVar("MultiModelT", bound=BaseModel)
|
||||||
|
|
||||||
|
PathTypeT = t.TypeVar("PathTypeT")
|
||||||
|
|
||||||
|
|
||||||
def alias_generator(field: str) -> str:
|
def alias_generator(field: str) -> str:
|
||||||
"""Remove unsupported characters from field names.
|
"""Remove unsupported characters from field names.
|
||||||
|
|
@ -44,26 +46,28 @@ class HyperglassModel(BaseModel):
|
||||||
alias_generator=alias_generator,
|
alias_generator=alias_generator,
|
||||||
)
|
)
|
||||||
|
|
||||||
def convert_paths(self, value: t.Any):
|
def convert_paths(self, value: t.Type[PathTypeT]) -> PathTypeT:
|
||||||
"""Change path to relative to app_path."""
|
"""Change path to relative to app_path.
|
||||||
|
|
||||||
|
This is required when running hyperglass in a container so that
|
||||||
|
the original app_path on the host system is not passed through
|
||||||
|
to the container.
|
||||||
|
"""
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.settings import Settings
|
from hyperglass.settings import Settings
|
||||||
|
|
||||||
if isinstance(value, Path):
|
if isinstance(value, Path):
|
||||||
if Settings.container:
|
if Settings.container:
|
||||||
return str(
|
return Settings.default_app_path.joinpath(
|
||||||
Settings.default_app_path.joinpath(
|
*(p for p in value.parts if p not in Settings.original_app_path.parts)
|
||||||
*(p for p in value.parts if p not in Settings.app_path.parts)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
path = Path(value)
|
if Settings.container:
|
||||||
if path.exists() and Settings.container:
|
path = Path(value)
|
||||||
# if path.exists():
|
|
||||||
return str(
|
return str(
|
||||||
Settings.default_app_path.joinpath(
|
Settings.default_app_path.joinpath(
|
||||||
*(p for p in path.parts if p not in Settings.app_path.parts)
|
*(p for p in path.parts if p not in Settings.original_app_path.parts)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class HyperglassSettings(BaseSettings):
|
||||||
|
|
||||||
config_file_names: t.ClassVar[t.Tuple[str, ...]] = ("config", "devices", "directives")
|
config_file_names: t.ClassVar[t.Tuple[str, ...]] = ("config", "devices", "directives")
|
||||||
default_app_path: t.ClassVar[Path] = _default_app_path
|
default_app_path: t.ClassVar[Path] = _default_app_path
|
||||||
_original_app_path: DirectoryPath = _default_app_path
|
original_app_path: Path = _default_app_path
|
||||||
|
|
||||||
debug: bool = False
|
debug: bool = False
|
||||||
dev_mode: bool = False
|
dev_mode: bool = False
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue