Help us shape the future of Go! Take the 2026 Go Developer Survey

github

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package github is a fake of the GitHub REST API subset Steadmesh uses: personal access tokens, a GitHub App (RS256 JWTs, scoped installation tokens, revocation), repositories, pull requests and issue comments. Installation tokens are enforced: each works only for its repositories and permissions, until it expires or is revoked.

Test endpoints:

GET  /_test/state      tokens, pull requests, comments and recorded requests
POST /_test/app        {"app_id","installation_id","public_key"} configures the App
POST /_test/tokens     {"valid":[...]} replaces the accepted PATs
POST /_test/reset      clears everything but the configuration

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	ID     int    `json:"id"`
	Repo   string `json:"repo"`
	Number int    `json:"number"`
	Body   string `json:"body"`
}

Comment is an issue comment.

type Pull

type Pull struct {
	Repo   string `json:"repo"`
	Number int    `json:"number"`
	Title  string `json:"title"`
	Head   string `json:"head"`
	Base   string `json:"base"`
	Body   string `json:"body"`
	State  string `json:"state"`
	Author string `json:"author"`
}

Pull is a pull request.

type Request

type Request struct {
	Method string `json:"method"`
	Path   string `json:"path"`
	Auth   string `json:"auth"` // pat:<token>, app, inst:<token>, or none
	Status int    `json:"status"`
}

Request is a recorded API request.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the fake.

func New

func New(repos []string, pats ...string) *Server

New returns a fake with the repositories owner/name and accepted PATs.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) SetApp

func (s *Server) SetApp(appID, installationID string, pub *rsa.PublicKey)

SetApp configures the GitHub App whose JWTs are accepted.

func (*Server) SetInstallationOwner added in v0.7.0

func (s *Server) SetInstallationOwner(owner string)

SetInstallationOwner overrides the installation account's login. By default it is the owner of the first configured repository.

func (*Server) State

func (s *Server) State() State

State returns a snapshot.

type State

type State struct {
	Tokens   []Token   `json:"tokens"`
	Pulls    []Pull    `json:"pulls"`
	Comments []Comment `json:"comments"`
	Requests []Request `json:"requests"`
}

State is the full fake state.

type Token

type Token struct {
	Token       string            `json:"token"`
	Repos       []string          `json:"repos,omitempty"` // names; empty: every installation repository
	Permissions map[string]string `json:"permissions,omitempty"`
	ExpiresAt   time.Time         `json:"expires_at"`
	Revoked     bool              `json:"revoked"`
}

Token is an issued installation token.

Jump to

Keyboard shortcuts

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