mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 19:56:53 +00:00
3529 invalid comments in 528 files, grandfathered in while the linter only saw the working-tree diff. Removal ran through the linter's own collectors, so detection and deletion cannot drift: a comment whose opener line is blank before it and whose closer line is blank after it loses all its lines, anything else loses only the comment region, and a line left holding a bare delimiter goes with it. Five files keep their comments behind a nocheck marker instead. Four are upstream configs whose inline docs are upstream's own (mautrix, systemd journald, nextcloud-oidc-login, MediaWiki). In littlejs the commented-out entries ARE the deactivation mechanism for an example tile, so deleting them would delete configuration. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from ansible.plugins.lookup import LookupBase
|
|
|
|
from utils.roles.validation.invokable import list_invokable_app_ids
|
|
|
|
_STATUS_CACHE: dict[tuple, dict[str, list[str]]] = {}
|
|
|
|
_EPHEMERAL_RUNTIMES = frozenset({"act", "github"})
|
|
|
|
|
|
def _reset_cache_for_tests() -> None:
|
|
_STATUS_CACHE.clear()
|
|
|
|
|
|
def _coerce_to_list(raw: Any) -> list[str]:
|
|
if raw is None:
|
|
return []
|
|
if isinstance(raw, str):
|
|
return [item.strip() for item in raw.split(",") if item.strip()]
|
|
return [str(item) for item in raw]
|
|
|
|
|
|
class LookupModule(LookupBase):
|
|
def run(
|
|
self,
|
|
terms: list[Any],
|
|
variables: dict[str, Any] | None = None,
|
|
**kwargs: Any,
|
|
) -> list[dict[str, list[str]]]:
|
|
vars_ = variables or getattr(self._templar, "available_variables", {}) or {}
|
|
|
|
whitelist = _coerce_to_list(vars_.get("APPLICATIONS_WHITELIST"))
|
|
groups = _coerce_to_list(vars_.get("group_names"))
|
|
runtime = str(vars_.get("RUNTIME", "")).strip().lower()
|
|
key = (tuple(whitelist), tuple(groups), runtime)
|
|
|
|
cached = _STATUS_CACHE.get(key)
|
|
if cached is not None:
|
|
return [cached]
|
|
|
|
running = whitelist or groups
|
|
deployed = list(running) if runtime in _EPHEMERAL_RUNTIMES else list(groups)
|
|
result = {
|
|
"whitelist": whitelist,
|
|
"running": list(running),
|
|
"groups": groups,
|
|
"deployed": deployed,
|
|
"runtime": runtime,
|
|
"all": list(list_invokable_app_ids()),
|
|
}
|
|
_STATUS_CACHE[key] = result
|
|
return [result]
|