Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The project doesn't use version numbers. Each entry is one merge into `master`,

Nothing yet.

## 2026-11-11 · [#6](https://github.com/tronyx/HealthChecks-Linux/pull/6)

### Fixed

- `--migrate` puts a blank line before the first `[[check]]` table in the file that it writes. Before, that table came right after the last line of `[hosts]` or of an `[auth.<name>]` table. The file worked the same, but it was harder to read.

## 2026-11-10 · [#5](https://github.com/tronyx/HealthChecks-Linux/pull/5)

HealthChecks Linux is rewritten in Python. The checks are mostly the same, but you must move your settings to a new configuration file. Read the lines marked **Breaking** before you update.
Expand Down
4 changes: 2 additions & 2 deletions healthchecks_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
print(f"healthchecks-linux: Python 3.10 or newer is needed, but this is Python {_version}", file=sys.stderr)
sys.exit(2)

__version__ = "2026-11-10"
__version__ = "2026-11-11"

EXIT_OK = 0
EXIT_ERROR = 1
Expand Down Expand Up @@ -1132,7 +1132,7 @@ def render_migration(migration: Migration, source: Path) -> str:
f"password = {_toml(credentials.password)}",
"",
]
return "\n".join(lines) + "\n".join(migration.checks)
return "\n".join([*lines, *migration.checks])


def write_migrated_config(target: Path, text: str) -> None:
Expand Down
18 changes: 18 additions & 0 deletions tests/test_migrate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests for --migrate: writing healthchecks.toml from a configured copy of the Bash script."""

import itertools
import stat
from pathlib import Path

Expand Down Expand Up @@ -186,6 +187,23 @@ def test_migrated_hosts(migrated: tuple[Path, str]) -> None:
assert '[hosts]\ndomain = "example.test"\ndocker = "10.0.0.5"\nunifi_nvr = "10.0.0.6"\nempty = ""\n' in text


@pytest.mark.parametrize(
("text", "has_auth"),
[(CONFIGURED, True), (CONFIGURED.replace(" check_nagios\n", ""), False)],
ids=["checks after the auth tables", "checks after the hosts"],
)
def test_migrated_tables_follow_a_blank_line(tmp_path: Path, text: str, has_auth: bool) -> None:
script = tmp_path / "application_healthchecks_generic.sh"
script.write_text(text, encoding="utf-8")
target = tmp_path / "healthchecks.toml"
assert main(["--migrate", str(script), "-c", str(target)], {}) == 0
migrated = target.read_text(encoding="utf-8")
assert ("\n[auth." in migrated) is has_auth
lines = migrated.split("\n")
assert [line for before, line in itertools.pairwise(lines) if line.startswith("[") and before] == []
assert migrated.endswith("]\n")


def test_migration_report(migrated: tuple[Path, str]) -> None:
out = migrated[1]
for line in (
Expand Down