Skip to main content

Module container_verbs

Module container_verbs 

Source
Expand description

The gh commands a container agent cannot run with its own token, and what it does instead.

A container’s GitHub token reads contents and writes pull requests, issues and the rest; it cannot write contents. Two kinds of gh command need that:

  • gh pr merge merges a pull request. srv does it for the container (POST /api/v1/github/pr-merge) with the host’s gh-agent, from a repository, a number and three options. Anything else a merge takes is refused here, with what to do.
  • A raw gh api write that changes a ref, a tag, a release or a file (DELETE .../git/refs/heads/x, PUT .../contents/f, POST .../releases) would only fail at GitHub with “Resource not accessible by integration”. It is refused here instead, naming the command that does the job: git push, gh pr merge --delete-branch.

github-container -- <gh args> is what the gh function calls for a container’s command. It exits 0 when it did the job, 1 when it refused or failed (the reason on stderr), and 3 when the command is not one of these and gh should run as usual.

Structs§

Merge
A merge as the container asked for it.

Enums§

Parsed
What gh pr merge <args> means: a merge srv can do, Help for --help, or why it cannot be done here.

Constants§

BY_NUMBER 🔒
MERGE_TIMEOUT 🔒
srv runs the merge on the host and may wait on GitHub and a merge queue.
NOT_HANDLED
Exit status meaning “not for this command: run gh as usual”.
RELEASE 🔒

Functions§

ask_merge 🔒
lead_repo_flag
A repository flag in front of the command word (gh -R o/r pr merge 7, which gh accepts): the repository it names, and the arguments without it. None for a command that does not start with one, or whose flag is not OWNER/REPO (then gh itself says what is wrong).
merge_body
The request srv gets: the repository, the number and the three options, nothing else.
merge_repo 🔒
The repository a merge is on: the one the merge names, else a leading -R, else GH_REPO, else the working directory’s. A GH_REPO that is not a plain repository is refused, not replaced by the working directory’s.
narrowing_machine
Whether this container’s machine narrows its GitHub tokens: it has a gh-agent (AGENTMUX_PUBLISH_GUARD is 1, or older-gh-agent where it is installed but too old to narrow, which srv then says out loud). With 0, no value or any other value there is no gh-agent on the machine, the container’s token comes from the person’s own GitHub connection, and its gh commands run as they always did.
parse_merge
gh pr merge’s arguments (args start with pr merge).
refused_api 🔒
refused_command
The refusal for a raw gh api write a container’s token cannot make, with the command that does the job; None for every other gh command. args are gh’s own, starting with api.
repo_of_flag 🔒
The repository a -R/--repo/GH_REPO value names. The whole spec must be OWNER/REPO or github.com/OWNER/REPO: another host, or a longer path, names a repository this step cannot merge on, and is never cut down to its first two parts (that would merge on a different repository than the one named).
run_github_container
github-container -- <gh args>.
unsupported 🔒