1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

refactor params.branding → params.web

This commit is contained in:
checktheroads
2020-01-28 09:14:47 -07:00
parent 9b9fd95061
commit 3b11cd65f2
12 changed files with 73 additions and 79 deletions

View File

@@ -144,7 +144,7 @@ try:
elif not user_config:
params = _params.Params()
try:
params.branding.text.subtitle = params.branding.text.subtitle.format(
params.web.text.subtitle = params.web.text.subtitle.format(
**params.dict(exclude={"branding", "features", "messages"})
)
except KeyError:
@@ -372,22 +372,20 @@ def _build_vrf_help():
content_vrf = _build_vrf_help()
content_help_params = copy.copy(content_params)
content_help_params["title"] = params.branding.help_menu.title
content_help_params["title"] = params.web.help_menu.title
content_help = asyncio.run(
get_markdown(
config_path=params.branding.help_menu,
config_path=params.web.help_menu,
default=DEFAULT_HELP,
params=content_help_params,
)
)
content_terms_params = copy.copy(content_params)
content_terms_params["title"] = params.branding.terms.title
content_terms_params["title"] = params.web.terms.title
content_terms = asyncio.run(
get_markdown(
config_path=params.branding.terms,
default=DEFAULT_TERMS,
params=content_terms_params,
config_path=params.web.terms, default=DEFAULT_TERMS, params=content_terms_params
)
)
content_credit = CREDIT

View File

@@ -18,16 +18,17 @@ from pydantic import validator
# Project Imports
from hyperglass.configuration.models._utils import HyperglassModel
from hyperglass.configuration.models.branding import Branding
from hyperglass.configuration.models.docs import Docs
from hyperglass.configuration.models.features import Features
from hyperglass.configuration.models.messages import Messages
from hyperglass.configuration.models.opengraph import OpenGraph
from hyperglass.configuration.models.web import Web
class Params(HyperglassModel):
"""Validation model for all configuration variables."""
# Top Level Params
debug: StrictBool = False
developer_mode: StrictBool = False
primary_asn: StrictStr = "65001"
@@ -50,8 +51,6 @@ class Params(HyperglassModel):
"network",
"isp",
]
opengraph: OpenGraph = OpenGraph()
docs: Docs = Docs()
google_analytics: StrictStr = ""
redis_host: StrictStr = "localhost"
redis_port: StrictInt = 6379
@@ -62,6 +61,13 @@ class Params(HyperglassModel):
log_file: Optional[FilePath]
cors_origins: List[StrictStr] = []
# Sub Level Params
docs: Docs = Docs()
features: Features = Features()
messages: Messages = Messages()
opengraph: OpenGraph = OpenGraph()
web: Web = Web()
@validator("listen_address", pre=True, always=True)
def validate_listen_address(cls, value, values):
"""Set default listen_address based on debug mode.
@@ -118,7 +124,3 @@ class Params(HyperglassModel):
f'/tmp/hyperglass_{now.strftime(r"%Y%M%d-%H%M%S")}.log' # noqa: S108
)
return value
features: Features = Features()
branding: Branding = Branding()
messages: Messages = Messages()

View File

@@ -19,7 +19,7 @@ from pydantic.color import Color
from hyperglass.configuration.models._utils import HyperglassModel
class Branding(HyperglassModel):
class Web(HyperglassModel):
"""Validation model for params.branding."""
class Colors(HyperglassModel):