github

package
v1.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderGithubSignature = "x-hub-signature-256"
	HeaderRunnerSignature = "x-deepsource-signature-256"
	HeaderRunnerID        = "x-deepsource-runner-id"
	HeaderAppID           = "x-deepsource-app-id"
	HeaderContentType     = "Content-Type"
)
View Source
const (
	HeaderInstallationID = "X-Installation-Id"
)
View Source
const (
	HeaderValueGithubAccept = "application/vnd.github+json"
)

Variables

View Source
var (
	GithubURLAccessTokenFmt = "/app/installations/%s/access_tokens"

	ErrAppNotFound = fmt.Errorf("app not found")
)
View Source
var (
	ErrInvalidSignature     = errors.New("invalid signature")
	ErrMandatoryArgsMissing = errors.New("mandatory args missing")
)
View Source
var (
	ErrConfigNotFound = errors.New("config not found")
)

Functions

This section is empty.

Types

type APIProxy

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

func (*APIProxy) GenerateAccessToken

func (c *APIProxy) GenerateAccessToken(requestToken string) (string, error)

GenerateAccessToken generates a short lived access token for the Github App using the JWT token.

func (*APIProxy) GenerateJWT

func (c *APIProxy) GenerateJWT() (string, error)

GenerateJWT generates a signed JWT token for the Github App.

func (*APIProxy) InstallationURL

func (c *APIProxy) InstallationURL() string

func (*APIProxy) Proxy

func (c *APIProxy) Proxy(req *http.Request) (*http.Response, error)

Proxy proxies the request to the Github API after adding the required authentication headers.

func (*APIProxy) ProxyURL

func (c *APIProxy) ProxyURL(path string) string

ProxyURL generates the Github API URL by removing the Runner API prefix from the request URL.

type APIProxyFactory

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

func NewAPIProxyFactory

func NewAPIProxyFactory(apps map[string]*App, client *http.Client) *APIProxyFactory

func (*APIProxyFactory) NewProxy

func (f *APIProxyFactory) NewProxy(appID string, installationID string) (*APIProxy, error)

type APIRequest

type APIRequest struct {
	AppID          string
	InstallationID string
}

type App

type App struct {
	ID string

	// Github App configuration.
	AppID         string
	AppSlug       string
	WebhookSecret string
	BaseHost      url.URL
	APIHost       url.URL
	PrivateKey    *rsa.PrivateKey
}

type Handler

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

func NewHandler

func NewHandler(apiF *APIProxyFactory, webhookF *WebhookProxyFactory) (*Handler, error)

func (*Handler) AuthenticatedRemoteURL

func (h *Handler) AuthenticatedRemoteURL(appID, installationID string, srcURL string) (string, error)

func (*Handler) HandleAPI

func (h *Handler) HandleAPI(c echo.Context) error

HandleAPI handles the API request from DeepSource Cloud to Github.

func (*Handler) HandleInstallation

func (h *Handler) HandleInstallation(c echo.Context) error

HandleInstallation redirects the user to the installation page on Github.

func (*Handler) HandleWebhook

func (h *Handler) HandleWebhook(c echo.Context) error

HandleWebhook handles the webhook request from Github to DeepSource Cloud.

type InstallationRequest

type InstallationRequest struct {
	AppID string `param:"app_id"`
}

type WebhookProxy

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

func NewWebhookProxy

func NewWebhookProxy(app *App, runner *model.Runner, deepsource *model.DeepSource, client *http.Client) (*WebhookProxy, error)

func (*WebhookProxy) Proxy

func (p *WebhookProxy) Proxy(r *http.Request) (*http.Response, error)

func (*WebhookProxy) VerifySignature

func (p *WebhookProxy) VerifySignature(signature string, body []byte) error

type WebhookProxyFactory

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

func NewWebhookProxyFactory

func NewWebhookProxyFactory(runner *model.Runner, deepsource *model.DeepSource, apps map[string]*App, client *http.Client) *WebhookProxyFactory

func (*WebhookProxyFactory) New

func (g *WebhookProxyFactory) New(appID string) (*WebhookProxy, error)

type WebhookRequest

type WebhookRequest struct {
	AppID string `param:"app_id"`
}

Jump to

Keyboard shortcuts

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