Skip to content

Commit

Permalink
fix path config
Browse files Browse the repository at this point in the history
Change-Id: I18cbad8a772096149476134312db52655d39b235
  • Loading branch information
mo-ki committed Nov 17, 2023
1 parent a21aabf commit 06bc95f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
26 changes: 25 additions & 1 deletion packages/cmk-mkp-tool/cmk/mkp_tool/_parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,31 @@ class PathConfig:

@classmethod
def from_toml(cls, content: str) -> Self:
return cls(**tomllib.loads(content)["paths"])
raw = tomllib.loads(content)["paths"]
return cls(
agent_based_plugins_dir=Path(raw["agent_based_plugins_dir"]),
agents_dir=Path(raw["agents_dir"]),
alert_handlers_dir=Path(raw["alert_handlers_dir"]),
bin_dir=Path(raw["bin_dir"]),
check_manpages_dir=Path(raw["check_manpages_dir"]),
checks_dir=Path(raw["checks_dir"]),
doc_dir=Path(raw["doc_dir"]),
gui_plugins_dir=Path(raw["gui_plugins_dir"]),
inventory_dir=Path(raw["inventory_dir"]),
lib_dir=Path(raw["lib_dir"]),
locale_dir=Path(raw["locale_dir"]),
mib_dir=Path(raw["mib_dir"]),
mkp_rule_pack_dir=Path(raw["mkp_rule_pack_dir"]),
notifications_dir=Path(raw["notifications_dir"]),
pnp_templates_dir=Path(raw["pnp_templates_dir"]),
web_dir=Path(raw["web_dir"]),
installed_packages_dir=Path(raw["installed_packages_dir"]),
local_root=Path(raw["local_root"]),
packages_enabled_dir=Path(raw["packages_enabled_dir"]),
packages_local_dir=Path(raw["packages_local_dir"]),
packages_shipped_dir=Path(raw["packages_shipped_dir"]),
tmp_dir=Path(raw["tmp_dir"]),
)

def get_path(self, part: PackagePart) -> Path:
match part:
Expand Down
3 changes: 0 additions & 3 deletions packages/cmk-mkp-tool/tests/test_parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@

from pathlib import Path

import pytest

from cmk.mkp_tool import PathConfig


@pytest.mark.skip(reason="typing is broken, PathConfig's paths are plain strings")
def test_config_from_toml() -> None:
assert (
PathConfig.from_toml(
Expand Down

0 comments on commit 06bc95f

Please sign in to comment.