Documentation
¶
Overview ¶
Package ghclient builds the go-github client claims talks to GitHub with (claims#108): the token, the API endpoint and errors that say what to do. The gh CLI is optional -- only a fallback for the token.
Index ¶
- Constants
- Variables
- func Describe(err error, action string) error
- func FromEnv(explicit string) (*github.Client, error)
- func New(token string) (*github.Client, error)
- func RepoFromURL(url string) (string, error)
- func SplitRepo(ownerRepo string) (owner, repo string, err error)
- func Token(explicit string) (string, error)
Constants ¶
const EnvAPIURL = "GITHUB_API_URL"
EnvAPIURL points the client at another API endpoint (GitHub Enterprise; tests). GitHub Actions sets it to https://api.github.com.
Variables ¶
var ErrNoToken = errors.New("no GitHub token: set GITHUB_TOKEN (or GIT_TOKEN), pass --git-token where the command has it, or log in with `gh auth login`")
ErrNoToken says how to give claims a token.
var GHAuthToken = func() (string, error) { if _, err := exec.LookPath("gh"); err != nil { return "", err } out, err := exec.Command("gh", "auth", "token").Output() return strings.TrimSpace(string(out)), err }
GHAuthToken asks the gh CLI for its token; a variable for tests.
Functions ¶
func Describe ¶
Describe turns the API's 401/403/404/422 into what to do about it. action says what failed ("starting dispatch-change-claim.yaml in o/r").
func RepoFromURL ¶
RepoFromURL is the owner/name of a git remote URL: https://host/o/r(.git), git@host:o/r(.git) or ssh://git@host/o/r(.git).
Types ¶
This section is empty.