Documentation
¶
Index ¶
- Constants
- func AppInstallationURL(properties core.IntegrationPropertyStorageReader, installationID string) (string, error)
- func AppURL(properties core.IntegrationPropertyStorageReader, appSlug string) (string, error)
- func EnsureRepoInMetadata(ctx core.MetadataWriter, integration core.IntegrationContext, ...) error
- func ExtractAction(data map[string]any) (string, bool)
- func FindSecret(ctx core.IntegrationContext, secretName string) (string, error)
- func HostedAppConfigured() bool
- func HostedAppInstallURL(slug, state string) string
- func HostedInstallationSettingsURL(tx *gorm.DB, integrationID uuid.UUID) (string, error)
- func InstallationSettingsURL(installation models.VCSProviderInstallation) string
- func IsExpression(s string) bool
- func IsForbiddenError(err error) bool
- func IsNotFoundError(err error) bool
- func LegacyAppPrivateKey(ctx core.IntegrationContext, metadata Metadata) (string, error)
- func ListInstallationBranchNames(httpCtx core.HTTPContext, appID int64, privateKey string, ...) ([]string, error)
- func RestrictHostedAppTransport(transport *ghinstallation.Transport, repositoryIDs []int64) error
- func SanitizeAssignees(assignees []string) []string
- func SignHostedAppInstallState(secret string, organizationID uuid.UUID) (string, error)
- func StatusCode(err error) int
- func VerifyHostedAppInstallState(secret, state string) (uuid.UUID, error)
- func VerifySignature(ctx core.WebhookRequestContext) (int, error)
- func WhitelistedAction(data map[string]any, allowed []string) bool
- func WithWebhookLogger(ctx core.WebhookRequestContext, triggerName string) core.WebhookRequestContext
- type Client
- func (c *Client) AddIssueAssignees(ctx context.Context, repository string, issueNumber int, assignees []string) (*github.Issue, *github.Response, error)
- func (c *Client) AddLabelsToIssue(ctx context.Context, repository string, issueNumber int, labels []string) ([]*github.Label, *github.Response, error)
- func (c *Client) AddPullRequestReviewers(ctx context.Context, repository string, pullNumber int, ...) (*github.PullRequest, *github.Response, error)
- func (c *Client) CancelWorkflowRun(repository string, workflowRunID int64) (*github.Response, error)
- func (c *Client) CreateDeployment(ctx context.Context, repository string, request *github.DeploymentRequest) (*github.Deployment, *github.Response, error)
- func (c *Client) CreateDeploymentStatus(ctx context.Context, repository string, deploymentID int64, ...) (*github.DeploymentStatus, *github.Response, error)
- func (c *Client) CreateHook(ctx context.Context, repository string, hook *github.Hook) (*github.Hook, *github.Response, error)
- func (c *Client) CreateIssue(ctx context.Context, repository string, issue *github.IssueRequest) (*github.Issue, *github.Response, error)
- func (c *Client) CreateIssueComment(ctx context.Context, repository string, issueNumber int, ...) (*github.IssueComment, *github.Response, error)
- func (c *Client) CreateIssueReaction(ctx context.Context, repository string, commentID int64, content string) (*github.Reaction, *github.Response, error)
- func (c *Client) CreatePullRequest(ctx context.Context, repository string, pullRequest *github.NewPullRequest) (*github.PullRequest, *github.Response, error)
- func (c *Client) CreatePullRequestReview(ctx context.Context, repository string, pullNumber int, ...) (*github.PullRequestReview, *github.Response, error)
- func (c *Client) CreateRelease(ctx context.Context, repository string, release *github.RepositoryRelease) (*github.RepositoryRelease, *github.Response, error)
- func (c *Client) CreateReviewCommentReaction(ctx context.Context, repository string, commentID int64, content string) (*github.Reaction, *github.Response, error)
- func (c *Client) CreateStatus(ctx context.Context, repository string, sha string, status github.RepoStatus) (*github.RepoStatus, *github.Response, error)
- func (c *Client) CreateWorkflowDispatchEvent(ctx context.Context, repository string, workflowFile string, ...) (*github.WorkflowDispatchRunDetails, *github.Response, error)
- func (c *Client) DeleteHook(ctx context.Context, repository string, hookID int64) (*github.Response, error)
- func (c *Client) DeleteRef(ctx context.Context, repository string, ref string) (*github.Response, error)
- func (c *Client) DeleteRelease(ctx context.Context, repository string, id int64) (*github.Response, error)
- func (c *Client) EditIssue(ctx context.Context, repository string, issueNumber int, ...) (*github.Issue, *github.Response, error)
- func (c *Client) EditIssueComment(ctx context.Context, repository string, commentID int64, ...) (*github.IssueComment, *github.Response, error)
- func (c *Client) EditPullRequest(ctx context.Context, repository string, pullNumber int, ...) (*github.PullRequest, *github.Response, error)
- func (c *Client) EditRelease(ctx context.Context, repository string, id int64, ...) (*github.RepositoryRelease, *github.Response, error)
- func (c *Client) FindRepository(repository string) (*github.Repository, error)
- func (c *Client) GenerateReleaseNotes(ctx context.Context, repository string, options *github.GenerateNotesOptions) (*github.RepositoryReleaseNotes, *github.Response, error)
- func (c *Client) GetBranchProtection(ctx context.Context, repository, branch string) (*github.Protection, error)
- func (c *Client) GetCombinedStatus(ctx context.Context, repository string, ref string, opts *github.ListOptions) (*github.CombinedStatus, *github.Response, error)
- func (c *Client) GetDependabotAlert(ctx context.Context, repository string, number int) (*github.DependabotAlert, *github.Response, error)
- func (c *Client) GetIssue(ctx context.Context, repository string, issueNumber int) (*github.Issue, *github.Response, error)
- func (c *Client) GetLatestRelease(ctx context.Context, repository string) (*github.RepositoryRelease, *github.Response, error)
- func (c *Client) GetOrganizationUsageReport() (*github.UsageReport, *github.Response, error)
- func (c *Client) GetPullRequest(ctx context.Context, repository string, pullNumber int) (*github.PullRequest, *github.Response, error)
- func (c *Client) GetRef(repository string, ref string) (*github.Reference, *github.Response, error)
- func (c *Client) GetRelease(ctx context.Context, repository string, id int64) (*github.RepositoryRelease, *github.Response, error)
- func (c *Client) GetReleaseByTag(ctx context.Context, repository string, tag string) (*github.RepositoryRelease, *github.Response, error)
- func (c *Client) GetRepositoryPermissionLevel(ctx context.Context, repository string, username string) (*github.RepositoryPermissionLevel, *github.Response, error)
- func (c *Client) GetWorkflowRun(repository string, workflowRunID int64) (*github.WorkflowRun, *github.Response, error)
- func (c *Client) HTTPDo(req *http.Request) (*http.Response, error)
- func (c *Client) HeadFilter(repository, branch string) string
- func (c *Client) ListAllOpenDependabotAlerts(ctx context.Context, repository string) ([]*github.DependabotAlert, error)
- func (c *Client) ListBranches(ctx context.Context, repository string, opts *github.BranchListOptions) ([]*github.Branch, *github.Response, error)
- func (c *Client) ListCheckRunsForRef(ctx context.Context, repository string, ref string, ...) (*github.ListCheckRunsResults, *github.Response, error)
- func (c *Client) ListCommits(ctx context.Context, repository string, opts *github.CommitsListOptions) ([]*github.RepositoryCommit, *github.Response, error)
- func (c *Client) ListIssueComments(ctx context.Context, repository string, issueNumber int) ([]*github.IssueComment, error)
- func (c *Client) ListLabelsForIssue(ctx context.Context, repository string, issueNumber int) ([]*github.Label, *github.Response, error)
- func (c *Client) ListLabelsForRepository(ctx context.Context, repository string, opts *github.ListOptions) ([]*github.Label, *github.Response, error)
- func (c *Client) ListNewestOpenIssues(ctx context.Context, repository string, limit int) ([]*github.Issue, error)
- func (c *Client) ListOpenDependabotAlerts(ctx context.Context, repository string, limit int) ([]*github.DependabotAlert, *github.Response, error)
- func (c *Client) ListPullRequestComments(ctx context.Context, repository string, pullNumber int) ([]*github.PullRequestComment, error)
- func (c *Client) ListPullRequestReviewComments(ctx context.Context, repository string, pullNumber int, reviewID int64) ([]*github.PullRequestComment, error)
- func (c *Client) ListPullRequests(ctx context.Context, repository string, opts *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error)
- func (c *Client) ListReleases(ctx context.Context, repository string, options *github.ListOptions) ([]*github.RepositoryRelease, *github.Response, error)
- func (c *Client) ListRepositories() ([]*github.Repository, error)
- func (c *Client) ListReviews(ctx context.Context, repository string, pullNumber int) ([]*github.PullRequestReview, error)
- func (c *Client) MarkPullRequestReadyForReview(ctx context.Context, pullRequestID string) error
- func (c *Client) MergePullRequest(ctx context.Context, repository string, pullNumber int, commitMessage string, ...) (*github.PullRequestMergeResult, *github.Response, error)
- func (c *Client) RemoveIssueAssignees(ctx context.Context, repository string, issueNumber int, assignees []string) (*github.Issue, *github.Response, error)
- func (c *Client) RemoveLabelForIssue(ctx context.Context, repository string, issueNumber int, label string) (*github.Response, error)
- func (c *Client) SearchIssues(ctx context.Context, query string, opts *github.SearchOptions) (*github.IssuesSearchResult, *github.Response, error)
- type GitHubAppMetadata
- type HostedApp
- type HostedAppBinding
- type InstallRequest
- type Metadata
- type NodeMetadata
- type Repository
- type WebhookConfiguration
Constants ¶
const ( EnvGitHubAppID = config.EnvGitHubAppID EnvGitHubAppSlug = config.EnvGitHubAppSlug EnvGitHubAppPrivateKey = config.EnvGitHubAppPrivateKey EnvGitHubAppWebhookSecret = config.EnvGitHubAppWebhookSecret )
const AuthMethodApp = "app"
const AuthMethodPAT = "pat"
const GitHubAppClientSecret = "clientSecret"
const GitHubAppPEM = "pem"
* These are the legacy secrets
const GitHubAppWebhookSecret = "webhookSecret"
const OwnerTypeOrganization = "Organization"
const OwnerTypeUser = "User Account"
const PropertyAppClientID = "appClientID"
const PropertyAppID = "appID"
* When connecting to the owner with a GitHub App, * these are the properties we get back from GitHub, * through the app creation / installation flow.
const PropertyAppInstallationID = "appInstallationID"
const PropertyAppInstallationURL = "appInstallationURL"
const PropertyAppSlug = "appSlug"
const PropertyAppState = "appState"
const PropertyAppURL = "appURL"
const PropertyAuthMethod = "authMethod"
* Two authentication methods are supported: * - Personal Access Token (PAT) * - GitHub App
const PropertyOwner = "owner"
const PropertyOwnerType = "ownerType"
* An integration can be connected to: * - A user account * - An organization
const SecretAppClientSecret = "appClientSecret"
const SecretAppPEM = "appPEM"
const SecretAppWebhookSecret = "appWebhookSecret"
const SecretPAT = "pat"
* Secrets for the integration: * - Personal Access Token (PAT) * - GitHub App private key (App) * - GitHub App client secret (App) * - GitHub App webhook secret (App)
Variables ¶
This section is empty.
Functions ¶
func AppInstallationURL ¶ added in v0.20.0
func AppInstallationURL(properties core.IntegrationPropertyStorageReader, installationID string) (string, error)
func AppURL ¶ added in v0.20.0
func AppURL(properties core.IntegrationPropertyStorageReader, appSlug string) (string, error)
func EnsureRepoInMetadata ¶
func EnsureRepoInMetadata(ctx core.MetadataWriter, integration core.IntegrationContext, httpCtx core.HTTPContext, configuration any) error
func FindSecret ¶
func FindSecret(ctx core.IntegrationContext, secretName string) (string, error)
func HostedAppConfigured ¶
func HostedAppConfigured() bool
func HostedAppInstallURL ¶
func InstallationSettingsURL ¶
func InstallationSettingsURL(installation models.VCSProviderInstallation) string
InstallationSettingsURL is the GitHub page where an admin manages this App installation. GitHub's html_url wins. Account login and type fill the same page when catalog sync has not stored that URL yet.
func IsExpression ¶ added in v0.20.0
IsExpression reports whether the given string contains an expression placeholder (e.g. `{{ ... }}`). Useful in Setup paths to skip strict validation of values that will only be known at execution time.
func IsForbiddenError ¶
func IsNotFoundError ¶ added in v0.20.0
func LegacyAppPrivateKey ¶
func LegacyAppPrivateKey(ctx core.IntegrationContext, metadata Metadata) (string, error)
LegacyAppPrivateKey returns the PEM for a legacy GitHub App connection. Hosted connections use the process key. Customer-created apps use the integration secret.
func ListInstallationBranchNames ¶
func ListInstallationBranchNames( httpCtx core.HTTPContext, appID int64, privateKey string, installationID, repositoryID int64, repository string, ) ([]string, error)
ListInstallationBranchNames returns branch names visible to a GitHub App installation. Callers pass the repository ID so the token can read that repository before a binding grant is committed.
func RestrictHostedAppTransport ¶
func RestrictHostedAppTransport(transport *ghinstallation.Transport, repositoryIDs []int64) error
func SanitizeAssignees ¶
func StatusCode ¶
func VerifySignature ¶
func VerifySignature(ctx core.WebhookRequestContext) (int, error)
func WithWebhookLogger ¶
func WithWebhookLogger(ctx core.WebhookRequestContext, triggerName string) core.WebhookRequestContext
Types ¶
type Client ¶ added in v0.20.0
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(ctx core.IntegrationContext, httpCtx core.HTTPContext) (*Client, error)
func (*Client) AddIssueAssignees ¶ added in v0.20.0
func (*Client) AddLabelsToIssue ¶ added in v0.20.0
func (*Client) AddPullRequestReviewers ¶ added in v0.26.0
func (*Client) CancelWorkflowRun ¶ added in v0.20.0
func (*Client) CreateDeployment ¶ added in v0.21.0
func (*Client) CreateDeploymentStatus ¶ added in v0.21.0
func (*Client) CreateHook ¶ added in v0.20.0
func (*Client) CreateIssue ¶ added in v0.20.0
func (*Client) CreateIssueComment ¶ added in v0.20.0
func (*Client) CreateIssueReaction ¶ added in v0.20.0
func (*Client) CreatePullRequest ¶ added in v0.20.0
func (*Client) CreatePullRequestReview ¶ added in v0.20.0
func (*Client) CreateRelease ¶ added in v0.20.0
func (*Client) CreateReviewCommentReaction ¶ added in v0.20.0
func (*Client) CreateStatus ¶ added in v0.20.0
func (*Client) CreateWorkflowDispatchEvent ¶ added in v0.20.0
func (*Client) DeleteHook ¶ added in v0.20.0
func (*Client) DeleteRelease ¶ added in v0.20.0
func (*Client) EditIssueComment ¶ added in v0.26.0
func (*Client) EditPullRequest ¶ added in v0.30.0
func (*Client) EditRelease ¶ added in v0.20.0
func (*Client) FindRepository ¶ added in v0.20.0
func (c *Client) FindRepository(repository string) (*github.Repository, error)
func (*Client) GenerateReleaseNotes ¶ added in v0.20.0
func (*Client) GetBranchProtection ¶
func (c *Client) GetBranchProtection(ctx context.Context, repository, branch string) (*github.Protection, error)
GetBranchProtection returns required status checks for a branch. A missing or unreadable rule is not an error: GitHub answers 404 when the branch is open, and 403 when the installation cannot read Administration rules.
func (*Client) GetCombinedStatus ¶ added in v0.25.0
func (*Client) GetDependabotAlert ¶
func (*Client) GetLatestRelease ¶ added in v0.20.0
func (*Client) GetOrganizationUsageReport ¶ added in v0.20.0
func (*Client) GetPullRequest ¶ added in v0.29.0
func (*Client) GetRelease ¶ added in v0.20.0
func (*Client) GetReleaseByTag ¶ added in v0.20.0
func (*Client) GetRepositoryPermissionLevel ¶ added in v0.20.0
func (*Client) GetWorkflowRun ¶ added in v0.20.0
func (*Client) HeadFilter ¶
HeadFilter builds the "owner:branch" value GitHub's pull request list "head" filter requires, using repository to resolve the owner the same way every other call on this client does. If branch already carries an "owner:" prefix (for example, a cross-repository head), it is returned unchanged.
func (*Client) ListAllOpenDependabotAlerts ¶
func (*Client) ListBranches ¶ added in v0.20.0
func (*Client) ListCheckRunsForRef ¶ added in v0.25.0
func (*Client) ListCommits ¶
func (c *Client) ListCommits( ctx context.Context, repository string, opts *github.CommitsListOptions, ) ([]*github.RepositoryCommit, *github.Response, error)
ListCommits returns one page of a repository's commits.
The commit message carries the trailers a squashed merge collected, which name the co-authors of the work. A pull request listing does not include them.
func (*Client) ListIssueComments ¶
func (c *Client) ListIssueComments(ctx context.Context, repository string, issueNumber int) ([]*github.IssueComment, error)
ListIssueComments returns an issue's comments oldest first, paginating through every page. It uses the REST Issues.ListComments endpoint, which returns issue comments only, never pull request review comments.
func (*Client) ListLabelsForIssue ¶ added in v0.20.0
func (*Client) ListLabelsForRepository ¶
func (c *Client) ListLabelsForRepository(ctx context.Context, repository string, opts *github.ListOptions) ([]*github.Label, *github.Response, error)
ListLabelsForRepository lists the labels defined in a repository, not the labels of a single issue. Settings screens use it to offer the labels that exist instead of a hardcoded list.
func (*Client) ListNewestOpenIssues ¶
func (c *Client) ListNewestOpenIssues(ctx context.Context, repository string, limit int) ([]*github.Issue, error)
ListNewestOpenIssues reads the newest open issues of a repository, newest first.
It asks GraphQL instead of the REST issue list because REST answers that list with pull requests in the same page. A caller that wants N issues then has to read a larger page and drop the pull requests, and a repository with many open pull requests returns few issues, or none.
func (*Client) ListOpenDependabotAlerts ¶
func (c *Client) ListOpenDependabotAlerts(ctx context.Context, repository string, limit int) ([]*github.DependabotAlert, *github.Response, error)
ListOpenDependabotAlerts reads open Dependabot alerts for a repository, newest first. GitHub returns 403 when alerts are turned off or the app cannot read them.
func (*Client) ListPullRequestComments ¶
func (*Client) ListPullRequestReviewComments ¶
func (*Client) ListPullRequests ¶
func (c *Client) ListPullRequests( ctx context.Context, repository string, opts *github.PullRequestListOptions, ) ([]*github.PullRequest, *github.Response, error)
ListPullRequests returns one page of a repository's pull requests.
This is the plain REST endpoint, which draws on the 5000-per-hour budget. Prefer it over a Search query, because Search allows only 30 requests a minute per installation.
func (*Client) ListReleases ¶ added in v0.20.0
func (*Client) ListRepositories ¶ added in v0.20.0
func (c *Client) ListRepositories() ([]*github.Repository, error)
func (*Client) ListReviews ¶
func (*Client) MarkPullRequestReadyForReview ¶ added in v0.29.0
MarkPullRequestReadyForReview takes a pull request out of the draft state. GitHub exposes this only through the GraphQL API, so it is the one pull request operation that cannot delegate to the REST client. It takes the pull request node ID (github.PullRequest.NodeID), not the pull request number.
func (*Client) MergePullRequest ¶ added in v0.25.0
func (*Client) RemoveIssueAssignees ¶ added in v0.20.0
func (*Client) RemoveLabelForIssue ¶ added in v0.20.0
func (*Client) SearchIssues ¶
func (c *Client) SearchIssues(ctx context.Context, query string, opts *github.SearchOptions) (*github.IssuesSearchResult, *github.Response, error)
SearchIssues wraps the /search/issues endpoint. The Velocity page uses it to list a repository's merged pull requests within a window; keeping the SDK pass-through thin means callers can build any query GitHub Search supports (issues, PRs, drafts, authors) without a new helper per shape.
type GitHubAppMetadata ¶
type HostedApp ¶
HostedApp is SuperPlane Cloud's public GitHub App. The process holds the credentials. Organization integrations reference a global installation.
func HostedAppFromEnv ¶
HostedAppFromEnv returns the public GitHub App from process environment.
type HostedAppBinding ¶
type HostedAppBinding struct {
App HostedApp
Installation *models.VCSProviderInstallation
ID int64
RepositoryIDs []int64
}
func ResolveHostedAppBinding ¶
func ResolveHostedAppBinding(ctx core.IntegrationContext) (*HostedAppBinding, error)
type InstallRequest ¶
type InstallRequest struct {
ID string `mapstructure:"id" json:"id,omitempty"`
AccountLogin string `mapstructure:"accountLogin" json:"accountLogin,omitempty"`
RequesterLogin string `mapstructure:"requesterLogin" json:"requesterLogin,omitempty"`
CreatedAt string `mapstructure:"createdAt" json:"createdAt,omitempty"`
}
type Metadata ¶
type Metadata struct {
InstallationID string `mapstructure:"installationId" json:"installationId"`
State string `mapstructure:"state" json:"state"`
Owner string `mapstructure:"owner" json:"owner"`
Repositories []Repository `mapstructure:"repositories" json:"repositories"`
GitHubApp GitHubAppMetadata `mapstructure:"githubApp" json:"githubApp"`
// HostedApp is true when this connection installs SuperPlane's public
// GitHub App. Credentials stay on the process, not on the integration.
HostedApp bool `mapstructure:"hostedApp" json:"hostedApp"`
// InstallRequested is true when a non-admin asked a GitHub org admin to
// install the app. Setup then returned setup_action=request.
InstallRequested bool `mapstructure:"installRequested" json:"installRequested,omitempty"`
// InstallRequestedAccount is the GitHub organization (or user) login the
// member asked an admin to approve.
InstallRequestedAccount string `mapstructure:"installRequestedAccount" json:"installRequestedAccount,omitempty"`
// InstallRequests contains every open GitHub App installation request for
// the member who started this connection. The legacy scalar fields above
// mirror this collection for compatibility with older clients.
InstallRequests []InstallRequest `mapstructure:"installRequests" json:"installRequests,omitempty"`
// SetupReturnPath is the in-app path to open after GitHub setup. Callbacks
// use it when the browser cookie is missing, for example localhost to ngrok.
SetupReturnPath string `mapstructure:"setupReturnPath" json:"setupReturnPath,omitempty"`
}
func (Metadata) CurrentInstallRequests ¶
func (m Metadata) CurrentInstallRequests() []InstallRequest
func (Metadata) HasInstallRequests ¶
func (*Metadata) SetInstallRequests ¶
func (m *Metadata) SetInstallRequests(requests []InstallRequest)
type NodeMetadata ¶
type NodeMetadata struct {
Repository *Repository `json:"repository"`
}