github

package
v0.0.0-...-a27217f Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 20 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

This section is empty.

Functions

func ConnectivityCheck

func ConnectivityCheck() error

func GetPullRequest

func GetPullRequest(ctx context.Context, owner, repo string, prNum int) (scm.ChangeRequest, error)

GetPullRequest fetches the specified pull request. A branch the API did not return is left empty in the result; see scm.ChangeRequest.

func ListPullRequestFiles

func ListPullRequestFiles(ctx context.Context, owner, repo string, prNum int) ([]string, error)

Returns list of files in a pull request

func ProcessComment

func ProcessComment(payload []byte) (webhook.EventInfo, error)

Processes a comment created event received from github

func ProcessPullRequest

func ProcessPullRequest(payload []byte) (webhook.EventInfo, error)

Processes a pull_request event received from github

func Status

func Status(ctx context.Context, status scm.Status, description, repoOwner, repoName, commitSha string, dryRun bool) error

Helper that sets commit status for the request commit sha

func VerifySignature

func VerifySignature(payload []byte, headerSignature string, secret string) bool

verifySignature checks if the provided signature is valid for the given payload.

Types

type Provider

type Provider struct{}

Provider implements argo-diff's provider primitives on top of the GitHub API. It holds no state: the clients are package vars built in init(), which tests swap for httptest-backed ones.

func (Provider) ConnectivityCheck

func (Provider) ConnectivityCheck() error

func (Provider) CreateComment

func (Provider) CreateComment(ctx context.Context, repo scm.RepoRef, num int, body string) (scm.Comment, error)

func (Provider) CredentialsHint

func (Provider) CredentialsHint() string

CredentialsHint names the variables that enable this provider.

func (Provider) CurrentUser

func (Provider) CurrentUser(ctx context.Context) (string, error)

CurrentUser returns the comment author's login. Under GitHub Actions, or with the github connectivity check bypassed, it returns "" so comments are matched by marker alone: the token's identity can't be resolved there.

func (Provider) DetectCI

func (Provider) DetectCI() bool

DetectCI reports whether argo-diff is running as a GitHub Action step.

func (Provider) Dialect

func (Provider) Dialect() comment.Dialect

func (Provider) Enabled

func (Provider) Enabled() bool

Enabled reports whether any GitHub credential is set: a token, or any of the GitHub App variables. ValidateConfig() catches an incomplete App setup.

func (Provider) EventFromCIEnv

func (Provider) EventFromCIEnv() (webhook.EventInfo, error)

EventFromCIEnv builds the event from the variables GitHub Actions sets for a pull_request workflow. Refresh is set, so the head SHA and refs are re-read from the API rather than trusted from the environment.

func (Provider) GetChangeRequest

func (Provider) GetChangeRequest(ctx context.Context, repo scm.RepoRef, num int) (scm.ChangeRequest, error)

func (Provider) ListChangedFiles

func (Provider) ListChangedFiles(ctx context.Context, repo scm.RepoRef, num int) ([]string, error)

func (Provider) ListComments

func (Provider) ListComments(ctx context.Context, repo scm.RepoRef, num int) ([]scm.Comment, error)

ListComments returns every comment on the pull request, oldest first.

func (Provider) Name

func (Provider) Name() string

func (Provider) RepoHosts

func (Provider) RepoHosts() []string

RepoHosts is where GitHub repositories live, for matching ArgoCD application sources. GitHub Enterprise hosts match through argocd's host-agnostic owner/repo fallback.

func (Provider) SetStatus

func (Provider) SetStatus(ctx context.Context, repo scm.RepoRef, sha string, state scm.Status, description string, dryRun bool) error

SetStatus is a no-op under GitHub Actions; see Status().

func (Provider) UpdateComment

func (Provider) UpdateComment(ctx context.Context, repo scm.RepoRef, num int, id int64, body string) (scm.Comment, error)

UpdateComment edits an issue comment. GitHub addresses issue comments by ID alone, so num is unused.

func (Provider) ValidateConfig

func (Provider) ValidateConfig() error

ValidateConfig requires all three GitHub App variables when no token is set.

func (Provider) WebhookHandler

func (Provider) WebhookHandler() scm.WebhookHandler

type WebhookHandler

type WebhookHandler struct{}

WebhookHandler verifies and parses GitHub webhook requests.

func (WebhookHandler) CheckConfig

func (WebhookHandler) CheckConfig() error

CheckConfig requires GITHUB_WEBHOOK_SECRET, which Verify() needs.

func (WebhookHandler) EventName

func (WebhookHandler) EventName(h http.Header) string

func (WebhookHandler) Parse

func (WebhookHandler) Parse(h http.Header, body []byte) (scm.WebhookEvent, error)

Parse handles ping, pull_request and issue_comment events; every other event type is reported as scm.WebhookIgnored.

func (WebhookHandler) Verify

func (WebhookHandler) Verify(h http.Header, body []byte) error

Verify checks the X-Hub-Signature-256 HMAC against GITHUB_WEBHOOK_SECRET.

Jump to

Keyboard shortcuts

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