github

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRepoNames added in v0.8.0

func GetRepoNames(repositoryURLs []string) ([]string, error)

func MustRegisterSigner added in v0.10.0

func MustRegisterSigner()

MustRegisterSigner registers the delegating signer for RS256. This must be called before any JWT signing operations. It panics if registration fails, as this indicates a fundamental configuration error that prevents the application from functioning.

func NewAppTokenSource added in v0.10.0

func NewAppTokenSource(signingKey any, appID string) oauth2.TokenSource

NewAppTokenSource creates a new AppTokenSource with the given signing key and app ID. The signingKey must be either a jwk.Key (from PEM parsing) or a kmsSigningKey. The returned TokenSource is wrapped in ReuseTokenSource for automatic caching.

func NewInstallationTokenSource added in v0.10.0

func NewInstallationTokenSource(installationID int64, appTokenSource oauth2.TokenSource, opts ...InstallationTokenSourceOption) oauth2.TokenSource

NewInstallationTokenSource creates an oauth2.TokenSource that produces GitHub App installation tokens. It uses the provided app token source to authenticate as the app, then exchanges for installation-specific tokens via the GitHub API.

The appTokenSource should be created via NewAppTokenSource() which handles caching. The returned TokenSource handles its own caching via go-githubauth.

func RepoForPath

func RepoForPath(path string) (string, string)

func RepoForURL

func RepoForURL(u url.URL) (string, string)

func ValidateScope added in v0.9.0

func ValidateScope(scope string) error

ValidateScope validates a colon-separated scope string in the format "field:action". It checks that the field exists in InstallationPermissions and that the action is one of the allowed values ("read" or "write"). Returns an error if the scope is malformed or contains invalid field or action values.

func WithAppTransport added in v0.8.0

func WithAppTransport(clientConfig *ClientConfig)

func WithTokenTransport added in v0.8.0

func WithTokenTransport(clientConfig *ClientConfig)

Types

type Client

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

func New

func New(ctx context.Context, cfg appconfig.GithubConfig, config ...ClientOption) (Client, error)

func (Client) CreateAccessToken

func (c Client) CreateAccessToken(ctx context.Context, repoNames []string, scopes []string) (string, time.Time, error)

func (Client) GetFileContent added in v0.9.0

func (c Client) GetFileContent(ctx context.Context, owner string, repo string, path string) (string, error)

type ClientConfig added in v0.8.0

type ClientConfig struct {
	TransportFactory func(context.Context, appconfig.GithubConfig, http.RoundTripper) (http.RoundTripper, error)
}

type ClientOption added in v0.8.0

type ClientOption func(*ClientConfig)

type FieldMapper added in v0.9.0

type FieldMapper[T any] struct {
	// contains filtered or unexported fields
}

FieldMapper provides a generic way to map JSON field names to struct fields and set values on struct instances using reflection. Only string and *string fields are supported.

func MustFieldMapper added in v0.9.0

func MustFieldMapper[T any]() *FieldMapper[T]

MustFieldMapper is like NewFieldMapper but panics if there is an error. Since types don't change at runtime, this is the generally recommended way to create a FieldMapper so long as it's exercised in unit tests.

func NewFieldMapper added in v0.9.0

func NewFieldMapper[T any]() (*FieldMapper[T], error)

NewFieldMapper creates a new FieldMapper for type T. It builds a map of JSON field names to reflect.StructField for all string and *string fields in T.

func (*FieldMapper[T]) Has added in v0.9.0

func (fm *FieldMapper[T]) Has(field string) bool

Has returns true if the field exists in T.

func (*FieldMapper[T]) SetAll added in v0.9.0

func (fm *FieldMapper[T]) SetAll(fieldValues []string) (T, error)

SetAll creates a new instance of T and sets fields based on colon-separated field name and value pairs. Each string in fieldValues should be in the format "fieldName:value".

type InstallationTokenSourceOption added in v0.10.0

type InstallationTokenSourceOption func(*installationTokenSourceOptions)

InstallationTokenSourceOption configures the installation token source.

func WithEnterpriseURL added in v0.10.0

func WithEnterpriseURL(url string) InstallationTokenSourceOption

WithEnterpriseURL sets the GitHub Enterprise Server URL.

func WithHTTPClient added in v0.10.0

func WithHTTPClient(client *http.Client) InstallationTokenSourceOption

WithHTTPClient sets the HTTP client for GitHub API calls.

type KMSClient

type KMSClient interface {
	Sign(ctx context.Context, in *kms.SignInput, optFns ...func(*kms.Options)) (*kms.SignOutput, error)
}

KMSClient defines the AWS API surface required for KMS signing.

type TokenIssuanceError added in v0.11.0

type TokenIssuanceError struct {
	Cause error
}

func (TokenIssuanceError) Error added in v0.11.0

func (e TokenIssuanceError) Error() string

func (TokenIssuanceError) Status added in v0.11.0

func (e TokenIssuanceError) Status() (int, string)

func (TokenIssuanceError) Unwrap added in v0.11.0

func (e TokenIssuanceError) Unwrap() error

Jump to

Keyboard shortcuts

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