Clarify token scan identity columns
This commit is contained in:
@@ -159,6 +159,9 @@ Podstawowe komendy tokenow:
|
|||||||
`tokens scan` wypisuje waska tabele. Dla jednego endpointu zobaczysz
|
`tokens scan` wypisuje waska tabele. Dla jednego endpointu zobaczysz
|
||||||
osobny wiersz `source=repo` oraz osobny wiersz `source=tokens.json`.
|
osobny wiersz `source=repo` oraz osobny wiersz `source=tokens.json`.
|
||||||
Ten sam numer `item` laczy oba wiersze w pare dla jednego endpointu.
|
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
|
## Fetch i switch
|
||||||
|
|
||||||
|
|||||||
+14
-12
@@ -305,20 +305,22 @@ Typowy wynik:
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
items
|
items
|
||||||
item source remote kind user token_ref result status url
|
item source id credential user has_token sync endpoint
|
||||||
---- ----------- ---------- -------- ---------- ---------- ---------------- ----------- --------------------------------
|
---- ----------- ---------- ---------- ---------- --------- ----- --------------------------------
|
||||||
1 repo r1 auth u1 remote existing in_sync http://77.90.8.171:3001
|
1 repo r1 auth u1 yes yes http://77.90.8.171:3001
|
||||||
1 tokens.json store u1 t1 present in_sync 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
|
Jesli remote istnieje, ale ma URL bez `LOGIN:TOKEN@`, wynik bedzie mial
|
||||||
w wierszu `repo` wartosci `kind=plain` i `result=no_credentials`. Jezeli
|
w wierszu `repo` wartosci `credential=plain` i `has_token=no`. Jezeli ten sam
|
||||||
ten sam endpoint istnieje w `tokens.json`, drugi wiersz tego samego `item`
|
endpoint istnieje w `tokens.json`, drugi wiersz tego samego `item` pokaze
|
||||||
pokaze `source=tokens.json`, `token=t1` i `result=present`.
|
`source=tokens.json`, `id=t1` i `has_token=yes`.
|
||||||
|
|
||||||
Ten sam numer `item` oznacza jedna pare logiczna dla jednego endpointu. Wiersz
|
Ten sam numer `item` oznacza jedna pare logiczna dla jednego endpointu. Wiersz
|
||||||
`source=repo` pokazuje stan remote, a wiersz `source=tokens.json` pokazuje stan
|
`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:
|
Przyklad:
|
||||||
|
|
||||||
@@ -382,10 +384,10 @@ repo_root<TAB>...
|
|||||||
token_path<TAB>...
|
token_path<TAB>...
|
||||||
|
|
||||||
items
|
items
|
||||||
item source remote kind user token_ref result status url
|
item source id credential user has_token sync endpoint
|
||||||
---- ----------- ---------- -------- ---------- ---------- ---------------- ----------- --------------------------------
|
---- ----------- ---------- ---------- ---------- --------- ----- --------------------------------
|
||||||
1 repo r1 plain no_credentials store_ahead http://77.90.8.171:3001
|
1 repo r1 plain no no http://77.90.8.171:3001
|
||||||
1 tokens.json store u1 t1 present store_ahead http://77.90.8.171:3001
|
1 tokens.json t1 store u1 yes no http://77.90.8.171:3001
|
||||||
|
|
||||||
status
|
status
|
||||||
item<TAB>value
|
item<TAB>value
|
||||||
|
|||||||
+9
-6
@@ -104,13 +104,16 @@ Kolumny w tabeli `items`:
|
|||||||
|
|
||||||
- `item` - numer porownywanego endpointu
|
- `item` - numer porownywanego endpointu
|
||||||
- `source` - `repo` albo `tokens.json`
|
- `source` - `repo` albo `tokens.json`
|
||||||
- `remote` - nazwa remote, na przyklad `r1`; tylko dla `source=repo`
|
- `id` - identyfikator miejsca tokena: remote `r1` dla repo albo token `t1` dla `tokens.json`
|
||||||
- `kind` - `auth`, `plain`, `store` albo `missing`
|
- `credential` - typ wpisu: `auth`, `plain`, `store` albo `missing`
|
||||||
- `user` - login odczytany z URL albo ze store
|
- `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`
|
- `has_token` - `yes` albo `no`, czyli czy dane zrodlo ma token dla endpointu
|
||||||
- `result` - `added`, `existing`, `present`, `no_credentials` albo `missing`
|
- `sync` - `yes` albo `no`, czyli czy para repo/store jest zgodna
|
||||||
- `status` - relacja repo do `tokens.json`, na przyklad `in_sync` albo `store_ahead`
|
- `endpoint` - endpoint serwera bez sekretu, trzymany jako ostatnia kolumna i przycinany do szerokosci tabeli
|
||||||
- `url` - 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:
|
Przyklad:
|
||||||
|
|
||||||
|
|||||||
@@ -670,22 +670,21 @@ def print_status_counts(status_counts: dict[str, int]) -> None:
|
|||||||
TOKEN_ITEM_COLUMNS = [
|
TOKEN_ITEM_COLUMNS = [
|
||||||
("item", 4),
|
("item", 4),
|
||||||
("source", 11),
|
("source", 11),
|
||||||
("remote", 10),
|
("id", 10),
|
||||||
("kind", 8),
|
("credential", 10),
|
||||||
("user", 10),
|
("user", 10),
|
||||||
("token_ref", 10),
|
("has_token", 9),
|
||||||
("result", 16),
|
("sync", 5),
|
||||||
("status", 12),
|
("endpoint", 32),
|
||||||
("url", 32),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def fit_cell(value: str, width: int) -> str:
|
def fit_cell(value: str, width: int) -> str:
|
||||||
if len(value) <= width:
|
if len(value) <= width:
|
||||||
return value.ljust(width)
|
return value.ljust(width)
|
||||||
if width <= 1:
|
if width <= 3:
|
||||||
return value[:width]
|
return value[:width]
|
||||||
return f"{value[:width - 1]}…"
|
return f"{value[:width - 3]}..."
|
||||||
|
|
||||||
|
|
||||||
def print_token_item_table(rows: list[dict[str, str]]) -> None:
|
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))
|
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(
|
def print_token_item_rows(
|
||||||
endpoint_names: list[str],
|
endpoint_names: list[str],
|
||||||
repo_servers: dict[str, dict],
|
repo_servers: dict[str, dict],
|
||||||
@@ -727,13 +730,12 @@ def print_token_item_rows(
|
|||||||
{
|
{
|
||||||
"item": item_id,
|
"item": item_id,
|
||||||
"source": "repo",
|
"source": "repo",
|
||||||
"remote": row["remote"],
|
"id": row["remote"],
|
||||||
"kind": row["url_kind"],
|
"credential": row["url_kind"],
|
||||||
"user": row["user"],
|
"user": row["user"],
|
||||||
"token_ref": token_label,
|
"has_token": "yes" if token_label else "no",
|
||||||
"result": row["result"],
|
"sync": sync_flag(status_name),
|
||||||
"status": status_name,
|
"endpoint": endpoint,
|
||||||
"url": endpoint,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
elif repo_entry is None:
|
elif repo_entry is None:
|
||||||
@@ -741,10 +743,10 @@ def print_token_item_rows(
|
|||||||
{
|
{
|
||||||
"item": item_id,
|
"item": item_id,
|
||||||
"source": "repo",
|
"source": "repo",
|
||||||
"kind": "missing",
|
"credential": "missing",
|
||||||
"result": "missing",
|
"has_token": "no",
|
||||||
"status": status_name,
|
"sync": sync_flag(status_name),
|
||||||
"url": endpoint,
|
"endpoint": endpoint,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -753,17 +755,17 @@ def print_token_item_rows(
|
|||||||
repo_users = token_name_rows(repo_entry.get("users", {}))
|
repo_users = token_name_rows(repo_entry.get("users", {}))
|
||||||
if repo_users:
|
if repo_users:
|
||||||
for user_name, _ in repo_users:
|
for user_name, _ in repo_users:
|
||||||
|
token_label = "remote" if repo_kind == "auth" else ""
|
||||||
item_rows.append(
|
item_rows.append(
|
||||||
{
|
{
|
||||||
"item": item_id,
|
"item": item_id,
|
||||||
"source": "repo",
|
"source": "repo",
|
||||||
"remote": remote_names,
|
"id": remote_names,
|
||||||
"kind": repo_kind,
|
"credential": repo_kind,
|
||||||
"user": user_name,
|
"user": user_name,
|
||||||
"token_ref": "remote",
|
"has_token": "yes" if token_label else "no",
|
||||||
"result": repo_result,
|
"sync": sync_flag(status_name),
|
||||||
"status": status_name,
|
"endpoint": endpoint,
|
||||||
"url": endpoint,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -771,11 +773,11 @@ def print_token_item_rows(
|
|||||||
{
|
{
|
||||||
"item": item_id,
|
"item": item_id,
|
||||||
"source": "repo",
|
"source": "repo",
|
||||||
"remote": remote_names,
|
"id": remote_names,
|
||||||
"kind": repo_kind,
|
"credential": repo_kind,
|
||||||
"result": repo_result,
|
"has_token": "yes" if repo_result == "present" else "no",
|
||||||
"status": status_name,
|
"sync": sync_flag(status_name),
|
||||||
"url": endpoint,
|
"endpoint": endpoint,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -784,10 +786,10 @@ def print_token_item_rows(
|
|||||||
{
|
{
|
||||||
"item": item_id,
|
"item": item_id,
|
||||||
"source": "tokens.json",
|
"source": "tokens.json",
|
||||||
"kind": "missing",
|
"credential": "missing",
|
||||||
"result": "missing",
|
"has_token": "no",
|
||||||
"status": status_name,
|
"sync": sync_flag(status_name),
|
||||||
"url": endpoint,
|
"endpoint": endpoint,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
@@ -798,10 +800,10 @@ def print_token_item_rows(
|
|||||||
{
|
{
|
||||||
"item": item_id,
|
"item": item_id,
|
||||||
"source": "tokens.json",
|
"source": "tokens.json",
|
||||||
"kind": "store",
|
"credential": "store",
|
||||||
"result": "empty",
|
"has_token": "no",
|
||||||
"status": status_name,
|
"sync": sync_flag(status_name),
|
||||||
"url": endpoint,
|
"endpoint": endpoint,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
@@ -811,12 +813,12 @@ def print_token_item_rows(
|
|||||||
{
|
{
|
||||||
"item": item_id,
|
"item": item_id,
|
||||||
"source": "tokens.json",
|
"source": "tokens.json",
|
||||||
"kind": "store",
|
"credential": "store",
|
||||||
"user": user_name,
|
"user": user_name,
|
||||||
"token_ref": token_name,
|
"id": token_name,
|
||||||
"result": "present",
|
"has_token": "yes" if token_name else "no",
|
||||||
"status": status_name,
|
"sync": sync_flag(status_name),
|
||||||
"url": endpoint,
|
"endpoint": endpoint,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user