Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoAppCredentials = errors.New("no GitHub App credentials")
ErrNoAppCredentials reports that App credentials were not supplied, so there is no app to ask about. Callers that only make sense under App auth test for it rather than matching on the message.
Functions ¶
func AppClient ¶ added in v0.6.1
AppClient returns a client authenticated as the GitHub App itself, for the endpoints that belong to the app rather than to one of its installations.
It never falls back to GITHUB_TOKEN: a personal access token authenticates a person, and a person has no app installations, so a PAT here would produce a confusing 401 rather than an answer. Callers get ErrNoAppCredentials and can say something useful instead.
Types ¶
type Client ¶
type Client struct {
REST *github.Client
// GraphQLURL is the endpoint used by DoGraphQL. Empty means GitHub's public
// GraphQL API. Tests may override it to point at a local server.
GraphQLURL string
// contains filtered or unexported fields
}
func NewClientFromEnv ¶
func NewClientWithHTTP ¶ added in v0.4.2
NewClientWithHTTP builds a Client around an HTTP client the caller already has.
DoGraphQL needs that client and the field is unexported, so without this there is no way to construct a GraphQL-capable Client outside this package — which left the GraphQL paths untestable.
type Installation ¶ added in v0.6.1
type Installation struct {
// Org is the organization's login, lowercased, because every other org
// name in gomgr is compared lowercased.
Org string
// ID is the installation ID, which is what the token endpoints want.
ID int64
// RepositorySelection is "all" or "selected". An app installed on a
// selected subset can be installed on the org and still be unable to see
// the repository a config names, so the two are not the same answer.
RepositorySelection string
}
Installation is one organization a GitHub App is installed on.
func ListInstallations ¶ added in v0.6.1
ListInstallations returns every organization the authenticated GitHub App is installed on, sorted by org.
This answers to the app, not to one of its installations, so it needs a client from AppClient — an installation token cannot see its siblings, which is the whole reason this is worth a separate call.
It needs no enterprise scope. That matters: it is the one honest answer gomgr can give to "which organizations does this reach" without a credential that could also rewrite them.