FJ-37: org scope and get for fj actions variables #45
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/actions-variables-org-get-FJ-37"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Extends
fj actions variablesto organization scope and adds agetsubcommand (FJ-37), so org-level CI variables can be listed and verified from the CLI without hitting the REST API or web UI.fj actions variables list --org <ORG>lists org-level actions variables.fj actions variables get [--org <ORG> | -r <OWNER>/<NAME>] <NAME>reads a single variable's value. Plain output prints the value (scriptable);--jsonemits{name,value,owner_id,repo_id}.createanddeleteaccept--org <ORG>and target the org endpoints.--orgis mutually exclusive with--repo/--remote(clear error when combined) and does not require a resolvable repo, so it works outside a git checkout with just--host.fj auth add-keywithread:organization, instead of a bare403 Forbidden.How
All endpoints exist in forgejo-api 0.10.0 (
/api/v1/orgs/{org}/actions/variables...and the single-variable GETs), so no web-route handling is needed (unlike FJ-36 logs). New thin wrappers live infj_core::actions(list_org_variables,get_variable,get_org_variable,create_org_variable,update_org_variable,delete_org_variable). The binary resolves aVarScope(Repo vs Org) once pervariablesinvocation and routes each subcommand accordingly; the repo name is resolved lazily so non-org subcommands behave exactly as before.Verification
Built, clippy (
-D warnings), fmt, tests pass in the builder image. Exercised against dev.a8n.run:listregression:-r a8n-tools/rusty-linksreturns[](the var is org-scoped, the original symptom).getnonexistent var: cleannot found: variable not found(no panic).--org+-rtogether: clear mutual-exclusion error.list/get(incl.--json): return the clearread:organizationscope error, since the test token lacks that scope.getand documents--orgonvariablesand each subcommand.Note: the org success path and
create/deletemutation are not live-verified here because the available token lacksread:organization(and to avoid mutating org state). The 403-mapping path confirms the org requests reach the correct endpoints; a token re-issued with org read scope will exercise the success path.`fj actions variables` could only target a repository and had no way to read a single variable's value, so org-level CI variables (e.g. A8N_TOOLS_PRIVATE_PACKAGE_OWNER on a8n-tools) could not be listed or verified from the CLI. This adds a global `--org <ORG>` flag to the `variables` subcommands and a new `get` subcommand. - `--org <ORG>` targets the org-level endpoints (`/api/v1/orgs/{org}/actions/variables...`) for list/create/delete/get; it is mutually exclusive with `--repo`/`--remote` and errors clearly when combined. - `get <NAME>` reads a single variable's value for both repo and org scope; plain output prints the value, `--json` emits `{name,value,owner_id,repo_id}`. - `--org` operations no longer require a resolvable repo, so the repo name is resolved lazily per subcommand instead of up front. - A missing organization read scope (HTTP 403) is mapped to an actionable message pointing at `fj auth add-key` with `read:organization`, instead of a bare `403 Forbidden`. All endpoints exist in forgejo-api 0.10.0 (pure /api/v1), so no web-route handling is needed. New thin wrappers live in fj_core::actions; the binary resolves scope via a VarScope enum. #FJ-37 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>