diff --git a/README.md b/README.md index 0183f67..c2da513 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,9 @@ Podstawowe komendy tokenow: `tokens scan` wypisuje waska tabele. Dla jednego endpointu zobaczysz osobny wiersz `source=repo` oraz osobny wiersz `source=tokens.json`. Ten sam numer `item` laczy oba wiersze w pare dla jednego endpointu. +Kolumny `has_token` i `sync` pokazuja, gdzie jest token i czy repo zgadza sie +z `tokens.json`. Kolumna `id` pokazuje `r1` dla tokena w repo albo `t1` dla +tokena w `tokens.json`, bez pokazywania sekretu. ## Fetch i switch diff --git a/doc/rvctl.md b/doc/rvctl.md index 89dd99c..3bc73bd 100644 --- a/doc/rvctl.md +++ b/doc/rvctl.md @@ -305,20 +305,22 @@ Typowy wynik: ```text items -item source remote kind user token_ref result status url ----- ----------- ---------- -------- ---------- ---------- ---------------- ----------- -------------------------------- -1 repo r1 auth u1 remote existing in_sync http://77.90.8.171:3001 -1 tokens.json store u1 t1 present in_sync http://77.90.8.171:3001 +item source id credential user has_token sync endpoint +---- ----------- ---------- ---------- ---------- --------- ----- -------------------------------- +1 repo r1 auth u1 yes yes http://77.90.8.171:3001 +1 tokens.json t1 store u1 yes yes http://77.90.8.171:3001 ``` Jesli remote istnieje, ale ma URL bez `LOGIN:TOKEN@`, wynik bedzie mial -w wierszu `repo` wartosci `kind=plain` i `result=no_credentials`. Jezeli -ten sam endpoint istnieje w `tokens.json`, drugi wiersz tego samego `item` -pokaze `source=tokens.json`, `token=t1` i `result=present`. +w wierszu `repo` wartosci `credential=plain` i `has_token=no`. Jezeli ten sam +endpoint istnieje w `tokens.json`, drugi wiersz tego samego `item` pokaze +`source=tokens.json`, `id=t1` i `has_token=yes`. Ten sam numer `item` oznacza jedna pare logiczna dla jednego endpointu. Wiersz `source=repo` pokazuje stan remote, a wiersz `source=tokens.json` pokazuje stan -lokalnego store. +lokalnego store. Kolumna `sync` jest flaga zgodnosci calej pary repo/store. +Kolumna `id` pokazuje identyfikator miejsca przechowywania tokena: dla repo jest +to nazwa remota, na przyklad `r1`, a dla store nazwa tokenu, na przyklad `t1`. Przyklad: @@ -382,10 +384,10 @@ repo_root... token_path... items -item source remote kind user token_ref result status url ----- ----------- ---------- -------- ---------- ---------- ---------------- ----------- -------------------------------- -1 repo r1 plain no_credentials store_ahead http://77.90.8.171:3001 -1 tokens.json store u1 t1 present store_ahead http://77.90.8.171:3001 +item source id credential user has_token sync endpoint +---- ----------- ---------- ---------- ---------- --------- ----- -------------------------------- +1 repo r1 plain no no http://77.90.8.171:3001 +1 tokens.json t1 store u1 yes no http://77.90.8.171:3001 status itemvalue diff --git a/doc/tokens.md b/doc/tokens.md index ec96b27..aced407 100644 --- a/doc/tokens.md +++ b/doc/tokens.md @@ -104,13 +104,16 @@ Kolumny w tabeli `items`: - `item` - numer porownywanego endpointu - `source` - `repo` albo `tokens.json` -- `remote` - nazwa remote, na przyklad `r1`; tylko dla `source=repo` -- `kind` - `auth`, `plain`, `store` albo `missing` +- `id` - identyfikator miejsca tokena: remote `r1` dla repo albo token `t1` dla `tokens.json` +- `credential` - typ wpisu: `auth`, `plain`, `store` albo `missing` - `user` - login odczytany z URL albo ze store -- `token_ref` - referencja bez sekretu: `remote` dla tokenu w URL albo nazwa tokenu ze store, na przyklad `t1` -- `result` - `added`, `existing`, `present`, `no_credentials` albo `missing` -- `status` - relacja repo do `tokens.json`, na przyklad `in_sync` albo `store_ahead` -- `url` - endpoint serwera bez sekretu, trzymany jako ostatnia kolumna i przycinany do szerokosci tabeli +- `has_token` - `yes` albo `no`, czyli czy dane zrodlo ma token dla endpointu +- `sync` - `yes` albo `no`, czyli czy para repo/store jest zgodna +- `endpoint` - endpoint serwera bez sekretu, trzymany jako ostatnia kolumna i przycinany do szerokosci tabeli + +Tabela nie wypisuje sekretu tokena. Jezeli token jest w remote, `id` pokazuje +nazwe remota, na przyklad `r1`. Jezeli token jest w `tokens.json`, `id` +pokazuje nazwe tokenu, na przyklad `t1`. Przyklad: diff --git a/rvctl.py b/rvctl.py index 7b2eb2a..ff3c5a3 100644 --- a/rvctl.py +++ b/rvctl.py @@ -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, } )