fix(forgejo): accept FORGEJO_ADMIN_TOKEN and document PAT setup
Align prune auth with railiance-apps forgejo tools and explain that package prune needs a Forgejo PAT, not the OpenBao backup lane.
This commit is contained in:
parent
715631dedd
commit
618641c984
2 changed files with 39 additions and 11 deletions
|
|
@ -283,16 +283,23 @@ def build_delete_plans(
|
|||
|
||||
|
||||
def load_token() -> str:
|
||||
token = os.environ.get("FORGEJO_TOKEN", "").strip()
|
||||
if token:
|
||||
return token
|
||||
token_file = os.environ.get("FORGEJO_TOKEN_FILE", "/tmp/forgejo-tegwick-api-token")
|
||||
for env_name in ("FORGEJO_TOKEN", "FORGEJO_ADMIN_TOKEN"):
|
||||
token = os.environ.get(env_name, "").strip()
|
||||
if token:
|
||||
return token
|
||||
token_file = os.environ.get(
|
||||
"FORGEJO_TOKEN_FILE",
|
||||
os.environ.get("FORGEJO_ADMIN_TOKEN_FILE", "/tmp/forgejo-tegwick-api-token"),
|
||||
)
|
||||
path = Path(token_file).expanduser()
|
||||
if path.is_file():
|
||||
return path.read_text(encoding="utf-8").strip()
|
||||
raise SystemExit(
|
||||
"ERROR: set FORGEJO_TOKEN or FORGEJO_TOKEN_FILE "
|
||||
"(Forgejo PAT with read:package and write:package)"
|
||||
"ERROR: Forgejo API token required (read:package + write:package).\n"
|
||||
" export FORGEJO_TOKEN=<pat> # or FORGEJO_ADMIN_TOKEN\n"
|
||||
" # or save PAT to /tmp/forgejo-tegwick-api-token (chmod 600)\n"
|
||||
" Generate: https://forgejo.coulomb.social/user/settings/applications\n"
|
||||
" See: railiance-platform/docs/forgejo-package-prune.md"
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue