modulepackage
0.1.2
Repository: https://github.com/datadog/ghinstallation.git
Documentation: pkg.go.dev
# README
ghinstallation
ghinstallation
provides Transport
, which implements http.RoundTripper
to provide authentication as an installation
for GitHub Apps.
This library is designed to provide automatic authentication for https://github.com/google/go-github or your own HTTP client.
Example
Get the package:
go get -u github.com/bradleyfalzon/ghinstallation
Usage:
import "github.com/bradleyfalzon/ghinstallation"
func main() {
// Shared transport to reuse TCP connections.
tr := http.DefaultTransport
// Wrap the shared transport for use with the integration ID 1 authenticating with installation ID 99.
itr, err := ghinstallation.NewKeyFromFile(tr, 1, 99, "2016-10-19.private-key.pem")
if err != nil {
log.Fatal(err)
}
// Use installation transport with github.com/google/go-github
client := github.NewClient(&http.Client{Transport: itr})
}
License
Unlicense - feel free to copy/paste without attribution/preservation of license etc.
Dependencies
# Functions
New returns an Transport using private key.
NewAppsTransport returns a AppsTransport using private key.
NewAppsTransportKeyFromFile returns a AppsTransport using a private key from file.
NewKeyFromFile returns a Transport using a private key from file.
# Structs
AppsTransport provides a http.RoundTripper by wrapping an existing http.RoundTripper and provides GitHub Apps authentication as a GitHub App.
Transport provides a http.RoundTripper by wrapping an existing http.RoundTripper and provides GitHub Apps authentication as an installation.
# Interfaces
Client is a HTTP client which sends a http.Request and returns a http.Response or an error.