Clarify token scan identity columns

This commit is contained in:
mpabi
2026-04-26 20:02:43 +02:00
parent 758e4871fb
commit 5f0da59aa2
4 changed files with 70 additions and 60 deletions
+44 -42
View File
@@ -670,22 +670,21 @@ def print_status_counts(status_counts: dict[str, int]) -> None:
TOKEN_ITEM_COLUMNS = [
("item", 4),
("source", 11),
("remote", 10),
("kind", 8),
("id", 10),
("credential", 10),
("user", 10),
("token_ref", 10),
("result", 16),
("status", 12),
("url", 32),
("has_token", 9),
("sync", 5),
("endpoint", 32),
]
def fit_cell(value: str, width: int) -> str:
if len(value) <= width:
return value.ljust(width)
if width <= 1:
if width <= 3:
return value[:width]
return f"{value[:width - 1]}"
return f"{value[:width - 3]}..."
def print_token_item_table(rows: list[dict[str, str]]) -> None:
@@ -696,6 +695,10 @@ def print_token_item_table(rows: list[dict[str, str]]) -> None:
print(" ".join(fit_cell(row.get(name, ""), width) for name, width in TOKEN_ITEM_COLUMNS))
def sync_flag(status_name: str) -> str:
return "yes" if status_name == "in_sync" else "no"
def print_token_item_rows(
endpoint_names: list[str],
repo_servers: dict[str, dict],
@@ -727,13 +730,12 @@ def print_token_item_rows(
{
"item": item_id,
"source": "repo",
"remote": row["remote"],
"kind": row["url_kind"],
"id": row["remote"],
"credential": row["url_kind"],
"user": row["user"],
"token_ref": token_label,
"result": row["result"],
"status": status_name,
"url": endpoint,
"has_token": "yes" if token_label else "no",
"sync": sync_flag(status_name),
"endpoint": endpoint,
}
)
elif repo_entry is None:
@@ -741,10 +743,10 @@ def print_token_item_rows(
{
"item": item_id,
"source": "repo",
"kind": "missing",
"result": "missing",
"status": status_name,
"url": endpoint,
"credential": "missing",
"has_token": "no",
"sync": sync_flag(status_name),
"endpoint": endpoint,
}
)
else:
@@ -753,17 +755,17 @@ def print_token_item_rows(
repo_users = token_name_rows(repo_entry.get("users", {}))
if repo_users:
for user_name, _ in repo_users:
token_label = "remote" if repo_kind == "auth" else ""
item_rows.append(
{
"item": item_id,
"source": "repo",
"remote": remote_names,
"kind": repo_kind,
"id": remote_names,
"credential": repo_kind,
"user": user_name,
"token_ref": "remote",
"result": repo_result,
"status": status_name,
"url": endpoint,
"has_token": "yes" if token_label else "no",
"sync": sync_flag(status_name),
"endpoint": endpoint,
}
)
else:
@@ -771,11 +773,11 @@ def print_token_item_rows(
{
"item": item_id,
"source": "repo",
"remote": remote_names,
"kind": repo_kind,
"result": repo_result,
"status": status_name,
"url": endpoint,
"id": remote_names,
"credential": repo_kind,
"has_token": "yes" if repo_result == "present" else "no",
"sync": sync_flag(status_name),
"endpoint": endpoint,
}
)
@@ -784,10 +786,10 @@ def print_token_item_rows(
{
"item": item_id,
"source": "tokens.json",
"kind": "missing",
"result": "missing",
"status": status_name,
"url": endpoint,
"credential": "missing",
"has_token": "no",
"sync": sync_flag(status_name),
"endpoint": endpoint,
}
)
continue
@@ -798,10 +800,10 @@ def print_token_item_rows(
{
"item": item_id,
"source": "tokens.json",
"kind": "store",
"result": "empty",
"status": status_name,
"url": endpoint,
"credential": "store",
"has_token": "no",
"sync": sync_flag(status_name),
"endpoint": endpoint,
}
)
continue
@@ -811,12 +813,12 @@ def print_token_item_rows(
{
"item": item_id,
"source": "tokens.json",
"kind": "store",
"credential": "store",
"user": user_name,
"token_ref": token_name,
"result": "present",
"status": status_name,
"url": endpoint,
"id": token_name,
"has_token": "yes" if token_name else "no",
"sync": sync_flag(status_name),
"endpoint": endpoint,
}
)