githubapp

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 23 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

Index

Constants

This section is empty.

Variables

View Source
var ErrSBOMMalformed = errors.New("GitHub SBOM export envelope is malformed")
View Source
var ErrSBOMTooLarge = errors.New("GitHub SBOM export exceeds the configured limit")
View Source
var ErrUnconfiguredHost = errors.New("GitHub request host is not configured")

Functions

func EndpointURL

func EndpointURL(base *url.URL, segments ...string) string

func NewHTTPClient

func NewHTTPClient(caPEM []byte, endpoints Endpoints, timeout time.Duration) (*http.Client, error)

func SetAPIHeaders

func SetAPIHeaders(header http.Header, apiVersion string)

Types

type Client

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

func NewClient

func NewClient(endpoints Endpoints, httpClient *http.Client, signer *Signer, apiVersion string, maxBytes int64, now func() time.Time, metricSet ...*observability.Metrics) *Client

func (*Client) DefaultBranchSHA

func (c *Client) DefaultBranchSHA(ctx context.Context, installationID int64, owner, name, branch string) (string, error)

func (*Client) DependencySBOM

func (c *Client) DependencySBOM(ctx context.Context, installationID int64, owner, name string) (SBOM, bool, error)

DependencySBOM is the compatibility reader used by SCIP cross-repository package mapping. It keeps its historical contract: identifiers, PURLs and relationships only, with HTTP 403/404 reported as unavailable.

func (*Client) DependencySBOMDocument added in v0.6.0

func (c *Client) DependencySBOMDocument(ctx context.Context, installationID int64, owner, name string, maxBytes int64) (SBOMDocument, error)

DependencySBOMDocument fetches the SPDX SBOM export losslessly. It returns the SPDX member bytes verbatim (no reserialization), the HTTP status, and throttling headers. maxBytes bounds the whole HTTP body; a larger response is ErrSBOMTooLarge. Non-2xx statuses are returned as SBOMError so callers can classify forbidden, not found, rate limited, and transient outcomes.

func (*Client) DownloadArchive

func (c *Client) DownloadArchive(ctx context.Context, owner, repository, sha, token string) (io.ReadCloser, error)

func (*Client) InstallationRepositories

func (c *Client) InstallationRepositories(ctx context.Context, installationID int64) ([]Repository, error)

func (*Client) InstallationToken

func (c *Client) InstallationToken(ctx context.Context, installationID int64, repositoryIDs []int64) (Token, error)

func (*Client) Installations

func (c *Client) Installations(ctx context.Context) ([]Installation, error)

func (*Client) ReadContents

func (c *Client) ReadContents(ctx context.Context, installationID int64, owner, name, path, ref string, maxBytes int64) (Content, error)

func (*Client) SearchCode

func (c *Client) SearchCode(ctx context.Context, installationID int64, query string, repositoryIDs []int64) (api.SearchResponse, error)

SearchCode performs a deliberately best-effort installation-scoped code search. GitHub does not provide an exact-commit consistency guarantee here.

type Content

type Content struct {
	Type     string `json:"type"`
	Encoding string `json:"encoding"`
	Content  string `json:"content"`
	SHA      string `json:"sha"`
	Size     int64  `json:"size"`
}

type Endpoints

type Endpoints struct {
	Web, API, Upload, Git, Archive *url.URL
}

type HTTPStatusError

type HTTPStatusError struct {
	StatusCode  int
	RateLimited bool
}

func (HTTPStatusError) Error

func (err HTTPStatusError) Error() string

func (HTTPStatusError) HTTPStatus

func (err HTTPStatusError) HTTPStatus() int

func (HTTPStatusError) IsRateLimited

func (err HTTPStatusError) IsRateLimited() bool

type Installation

type Installation struct {
	ID           int64
	AccountLogin string
	AccountType  string
	Status       string
	SuspendedAt  *time.Time
}

type RateLimit added in v0.6.0

type RateLimit struct {
	Limited   bool
	Remaining int
	ResetAt   time.Time
}

RateLimit carries GitHub's rate-limit headers when present so a 403 caused by throttling can be told apart from missing access.

type ReconcileAPI

type ReconcileAPI interface {
	Installations(context.Context) ([]Installation, error)
	InstallationRepositories(context.Context, int64) ([]Repository, error)
	DefaultBranchSHA(context.Context, int64, string, string, string) (string, error)
}

type ReconcileStore

type ReconcileStore interface {
	InstallationIDs(context.Context) ([]int64, error)
	ReconcileInstallation(context.Context, Installation, []Repository) error
	DisableInstallation(context.Context, int64, string) error
}

type Reconciler

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

func NewReconciler

func NewReconciler(client *Client, store ReconcileStore) *Reconciler

func (*Reconciler) All

func (r *Reconciler) All(ctx context.Context) error

func (*Reconciler) Installation

func (r *Reconciler) Installation(ctx context.Context, installationID int64) error

type Repository

type Repository struct {
	ID             int64
	InstallationID int64
	SizeBytes      int64
	FullName       string
	Owner          string
	Name           string
	CloneURL       string
	HTMLURL        string
	DefaultBranch  string
	DefaultSHA     string
	ErrorCode      string
	Private        bool
	Archived       bool
	Disabled       bool
}

type SBOM

type SBOM struct {
	DocumentSPDXID    string
	DocumentDescribes []string
	Packages          []SBOMPackage
	Relationships     []SBOMRelationship
}

type SBOMDocument added in v0.6.0

type SBOMDocument struct {
	Body       []byte
	MediaType  string
	Status     int
	FetchedAt  time.Time
	RateLimit  RateLimit
	RetryAfter time.Duration
}

SBOMDocument is one lossless observation of a repository's dependency-graph SBOM export. Body is the exact bytes of the SPDX JSON member as GitHub sent them; the HTTP envelope around it is not retained. FetchedAt is GraphNest's clock, never the document's own creation time.

type SBOMError added in v0.6.0

type SBOMError struct {
	Status     int
	RateLimit  RateLimit
	RetryAfter time.Duration
}

SBOMError is a non-2xx SBOM export response. It preserves the status and throttling signals and carries no response body.

func (SBOMError) Error added in v0.6.0

func (err SBOMError) Error() string

func (SBOMError) IsRateLimited added in v0.6.0

func (err SBOMError) IsRateLimited() bool

IsRateLimited reports whether the failure is throttling (429, or a 403 with exhausted rate-limit headers) rather than a permission or availability failure. A plain 403 or 404 does not prove the dependency graph is disabled.

type SBOMPackage

type SBOMPackage struct {
	SPDXID string
	PURLs  []string
}

type SBOMRelationship

type SBOMRelationship struct {
	SPDXElementID      string
	Type               string
	RelatedSPDXElement string
}

type Signer

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

func NewSigner

func NewSigner(appID int64, pemBytes []byte, now func() time.Time) (*Signer, error)

func (*Signer) JWT

func (signer *Signer) JWT() (string, error)

type Token

type Token struct {
	Value     string
	ExpiresAt time.Time
}

Jump to

Keyboard shortcuts

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