# README
githubapp
A small Go package for handling authentication with a Github App using owner login and repository names instead of UUIDs. Installations and repositories are
cached internally and refreshed (lazily) on a set interval, to reduce the number of List*
API calls against the Apps API.
Usage
package main
import (
"github.com/telia-oss/githubapp"
"github.com/google/go-github/v45/github"
)
func main() {
client, err := githubapp.NewClient(911, []byte("private-key"))
if err != nil {
panic(err)
}
app := githubapp.New(client)
token, err := app.CreateInstallationToken(
"telia-oss",
[]string{"githubapp"},
&githubapp.Permissions{
Metadata: github.String("read"),
},
)
if err != nil {
panic(err)
}
}
# Packages
Code generated by counterfeiter.
# Functions
New returns a new App.
NewClient returns a client for the Github V3 (REST) AppsAPI authenticated with a private key.
NewInstallationClient returns a new client.
WithInstallationClientFactory sets the function used to create new installation clients internally, and can be used to inject test fakes.
WithUpdateInterval can be used to override the default update interval for installations and repositories.
# Structs
App wraps the AppsAPI client and caches the installations and repositories for the installation.
InstallationClient is authenticated with an installation token and includes a client for both the V3 and V4 Github APIs.
Token is re-exported to prevent issues with conflicting go-github versions.
# Interfaces
AppsJWTAPI is the interface that is satisfied by the Apps client when authenticated with a JWT.
AppsTokenAPI is the interface that is satisfied by the Apps client when authenticated with an installation token.
# Type aliases
ErrInstallationNotFound is returned if the requested App installation is not found.
Permissions is re-exported to prevent issues with conflicting go-github versions.