ghclient

package
v0.32.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

View Source
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.

View Source
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

func Describe(err error, action string) error

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 FromEnv

func FromEnv(explicit string) (*github.Client, error)

FromEnv is New(Token(explicit)).

func New

func New(token string) (*github.Client, error)

New is a client with token, against $GITHUB_API_URL when set.

func RepoFromURL

func RepoFromURL(url string) (string, error)

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).

func SplitRepo

func SplitRepo(ownerRepo string) (owner, repo string, err error)

SplitRepo splits "owner/name".

func Token

func Token(explicit string) (string, error)

Token is explicit (a --git-token flag), else $GIT_TOKEN, $GITHUB_TOKEN, else gh's login. There is no anonymous fallback: the fleet repository is private.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL