github

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package github adapts the GitHub REST client to the host-neutral provider.Provider interface. Activated only when GLVALET_GITHUB_ENABLED=true. Pull requests are exposed via the MergeRequest surface; issues via the Issue surface. Epics and work items return provider.ErrUnsupported.

Index

Constants

This section is empty.

Variables

View Source
var ErrFeatureDisabled = errors.New("github: feature disabled; set GLVALET_GITHUB_ENABLED=true to enable")

ErrFeatureDisabled is returned when the GitHub provider is constructed without the GLVALET_GITHUB_ENABLED=true environment variable.

Functions

This section is empty.

Types

type GitHub

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

GitHub is the provider.Provider implementation for GitHub and GitHub Enterprise.

func New

func New(cfg *config.Config) (*GitHub, error)

New constructs a GitHub provider bound to cfg. Returns ErrFeatureDisabled when the GLVALET_GITHUB_ENABLED flag is not "true".

func NewWithClient

func NewWithClient(client *gh.Client, host string) *GitHub

NewWithClient is used in tests to inject a preconfigured gh.Client. It bypasses the feature-flag check and the HTTP client construction.

func (*GitHub) ApproveMergeRequest

func (g *GitHub) ApproveMergeRequest(ctx context.Context, project string, iid int) error

ApproveMergeRequest submits an APPROVE review on the pull request. GitHub models approvals as PR reviews, so this creates a review with Event=APPROVE.

func (*GitHub) CancelPipeline added in v0.4.0

func (g *GitHub) CancelPipeline(ctx context.Context, project string, id int) error

CancelPipeline cancels a running GitHub Actions workflow run.

func (*GitHub) CloseWorkItem added in v0.4.0

func (g *GitHub) CloseWorkItem(context.Context, string, int) error

CloseWorkItem returns ErrUnsupported on GitHub.

func (*GitHub) CreateGroupEpic

func (g *GitHub) CreateGroupEpic(ctx context.Context, groupID int, opts provider.CreateEpicOptions) (provider.Epic, error)

CreateGroupEpic is unsupported on GitHub (no first-class epic concept).

func (*GitHub) CreateGroupMilestone

func (g *GitHub) CreateGroupMilestone(ctx context.Context, groupID int, opts provider.CreateMilestoneOptions) (provider.Milestone, error)

CreateGroupMilestone is unsupported on GitHub because milestones are repo-scoped and the neutral interface carries a groupID with no repo mapping.

func (*GitHub) CreateIssue

func (g *GitHub) CreateIssue(ctx context.Context, project string, opts provider.CreateIssueOptions) (provider.Issue, error)

CreateIssue creates a new issue in the given project.

func (*GitHub) CreateIssueNote

func (g *GitHub) CreateIssueNote(ctx context.Context, project string, iid int, body string) (provider.Note, error)

CreateIssueNote adds a comment to an issue (GitHub issue comment).

func (*GitHub) CreateLabel

func (g *GitHub) CreateLabel(ctx context.Context, project string, opts provider.CreateLabelOptions) (provider.Label, error)

CreateLabel creates a new label in the given project. GitHub stores colors without a leading '#', so it is stripped before the call.

func (*GitHub) CreateMergeRequest

func (g *GitHub) CreateMergeRequest(ctx context.Context, project string, opts provider.CreateMergeRequestOptions) (provider.MergeRequest, error)

CreateMergeRequest opens a new pull request. AssigneeID is ignored because GitHub addresses assignees by login, not numeric ID.

func (*GitHub) CreateMilestone added in v0.4.0

func (g *GitHub) CreateMilestone(ctx context.Context, project string, opts provider.CreateMilestoneOptions) (provider.Milestone, error)

CreateMilestone creates a new repo-scoped milestone on GitHub.

func (*GitHub) CreateWorkItem added in v0.4.0

CreateWorkItem returns ErrUnsupported on GitHub.

func (*GitHub) DownloadArtifact added in v0.4.0

func (g *GitHub) DownloadArtifact(ctx context.Context, project string, artifactID int, destDir string) error

DownloadArtifact downloads a single GitHub Actions artifact to destDir.

func (*GitHub) GetIssue

func (g *GitHub) GetIssue(ctx context.Context, project string, iid int) (provider.Issue, error)

GetIssue retrieves a single issue by number.

func (*GitHub) GetJobLogs added in v0.4.0

func (g *GitHub) GetJobLogs(ctx context.Context, project string, jobID int) (string, error)

GetJobLogs returns the log output for a single GitHub Actions job.

func (*GitHub) GetMergeRequest

func (g *GitHub) GetMergeRequest(ctx context.Context, project string, iid int) (provider.MergeRequest, error)

GetMergeRequest retrieves a single pull request by number.

func (*GitHub) GetMergeRequestDiff

func (g *GitHub) GetMergeRequestDiff(ctx context.Context, project string, iid int) ([]provider.FileDiff, error)

GetMergeRequestDiff returns the per-file changes of a pull request via the ListFiles API, mapping GitHub's status string to the neutral flags.

func (*GitHub) GetMilestone added in v0.4.0

func (g *GitHub) GetMilestone(ctx context.Context, project string, id int) (provider.Milestone, error)

GetMilestone returns a single repo-scoped milestone by number.

func (*GitHub) GetPipeline added in v0.4.0

func (g *GitHub) GetPipeline(ctx context.Context, project string, id int) (provider.Pipeline, error)

GetPipeline returns a single GitHub Actions workflow run.

func (*GitHub) GetProject added in v0.4.0

func (g *GitHub) GetProject(ctx context.Context, project string) (provider.Project, error)

GetProject fetches repository metadata via the GitHub repos API.

func (*GitHub) Host

func (g *GitHub) Host() string

Host returns the bare host the provider talks to (e.g. "github.com").

func (*GitHub) Kind

func (g *GitHub) Kind() provider.Kind

Kind returns provider.KindGitHub.

func (*GitHub) LinkIssueToEpic

func (g *GitHub) LinkIssueToEpic(_ context.Context, _, _, _ int) error

LinkIssueToEpic is unsupported because GitHub has no first-class epic relation.

func (*GitHub) ListArtifacts added in v0.4.0

func (g *GitHub) ListArtifacts(ctx context.Context, project string, pipelineID int) ([]provider.Artifact, error)

ListArtifacts returns artifacts for a GitHub Actions workflow run.

func (*GitHub) ListEpicIssues added in v0.4.0

func (g *GitHub) ListEpicIssues(_ context.Context, _ int, _ int) ([]provider.Issue, error)

ListEpicIssues is unsupported on GitHub (no first-class epic relation).

func (*GitHub) ListGroupEpics

func (g *GitHub) ListGroupEpics(_ context.Context, _ int, _ provider.ListGroupEpicsOptions) ([]provider.Epic, error)

ListGroupEpics is unsupported on GitHub (no first-class epic concept).

func (*GitHub) ListGroupMilestones

func (g *GitHub) ListGroupMilestones(_ context.Context, _ int, _ provider.ListGroupMilestonesOptions) ([]provider.Milestone, error)

ListGroupMilestones is unsupported on GitHub because milestones are repo-scoped, not org/group-scoped; groupID has no equivalent in the GitHub API.

func (*GitHub) ListIssues

func (g *GitHub) ListIssues(ctx context.Context, project string, opts provider.ListIssuesOptions) ([]provider.Issue, error)

ListIssues lists issues for the given owner/repo project. Pull requests returned by the GitHub issues API are filtered out. A milestone title is resolved to its number via ListMilestones first.

func (*GitHub) ListLabels

func (g *GitHub) ListLabels(ctx context.Context, project string) ([]provider.Label, error)

ListLabels retrieves all labels for the given project.

func (*GitHub) ListMergeRequests

func (g *GitHub) ListMergeRequests(ctx context.Context, project string, opts provider.ListMergeRequestsOptions) ([]provider.MergeRequest, error)

ListMergeRequests lists pull requests for the given owner/repo project.

func (*GitHub) ListMilestones added in v0.3.0

func (g *GitHub) ListMilestones(ctx context.Context, project string, opts provider.ListMilestonesOptions) ([]provider.Milestone, error)

ListMilestones returns repo-scoped milestones for the given owner/repo project.

func (*GitHub) ListMyIssues

func (g *GitHub) ListMyIssues(ctx context.Context, opts provider.ListMyIssuesOptions) ([]provider.Issue, error)

ListMyIssues lists issues assigned to the authenticated user across all repositories visible to the token. Each issue's Project is recovered from its repository. GitHub uses "open" where the neutral surface uses "opened".

func (*GitHub) ListMyMergeRequests

func (g *GitHub) ListMyMergeRequests(ctx context.Context, opts provider.ListMyMergeRequestsOptions) ([]provider.MergeRequest, error)

ListMyMergeRequests lists pull requests assigned to the authenticated user across all repositories, using the GitHub Search API (issues endpoint with is:pr). Each result's Project is recovered from the issue's Repository field.

func (*GitHub) ListPipelineJobs added in v0.4.0

func (g *GitHub) ListPipelineJobs(ctx context.Context, project string, pipelineID int) ([]provider.Job, error)

ListPipelineJobs returns jobs (steps) for a GitHub Actions workflow run.

func (*GitHub) ListPipelines added in v0.4.0

func (g *GitHub) ListPipelines(ctx context.Context, project string, opts provider.ListPipelinesOptions) ([]provider.Pipeline, error)

ListPipelines returns GitHub Actions workflow runs for the given repo. On GitHub, a "pipeline" maps to a workflow run.

func (*GitHub) ListUsers

func (g *GitHub) ListUsers(ctx context.Context, opts provider.ListUsersOptions) ([]provider.User, error)

ListUsers searches users via the GitHub user search API. GitHub has no unfiltered user-listing endpoint, so an empty Search returns ErrUnsupported.

func (*GitHub) ListWorkItems added in v0.4.0

ListWorkItems returns ErrUnsupported on GitHub (no first-class work items).

func (*GitHub) MergeMergeRequest

func (g *GitHub) MergeMergeRequest(ctx context.Context, project string, iid int, opts provider.MergeOptions) (provider.MergeRequest, error)

MergeMergeRequest merges a pull request. Squash maps to the GitHub "squash" merge method; branch deletion is a separate Git ref operation and is not performed here.

func (*GitHub) ResolveGroup added in v0.3.0

func (g *GitHub) ResolveGroup(_ context.Context, _ string) (int, error)

ResolveGroup is unsupported on GitHub — orgs have numeric IDs but the GitHub adapter does not implement group-epic/group-milestone surfaces.

func (*GitHub) RetryPipeline added in v0.4.0

func (g *GitHub) RetryPipeline(ctx context.Context, project string, id int) (provider.Pipeline, error)

RetryPipeline reruns a failed GitHub Actions workflow run.

func (*GitHub) RunPipeline added in v0.4.0

func (g *GitHub) RunPipeline(ctx context.Context, project string, opts provider.RunPipelineOptions) (provider.Pipeline, error)

RunPipeline triggers a GitHub Actions workflow via workflow_dispatch. On GitHub, this requires the workflow file name (opts.Workflow) and the workflow must support workflow_dispatch triggers.

func (*GitHub) UpdateGroupEpic added in v0.4.0

func (g *GitHub) UpdateGroupEpic(_ context.Context, _ int, _ int, _ provider.UpdateEpicOptions) (provider.Epic, error)

UpdateGroupEpic is unsupported on GitHub (no first-class epic concept).

func (*GitHub) UpdateIssue

func (g *GitHub) UpdateIssue(ctx context.Context, project string, iid int, opts provider.UpdateIssueOptions) (provider.Issue, error)

UpdateIssue applies a partial update to an existing issue. The neutral State is translated to GitHub's state noun (open/closed). A milestone given by title (without MilestoneID) is resolved to its number via ListMilestones.

func (*GitHub) UpdateMergeRequest

func (g *GitHub) UpdateMergeRequest(ctx context.Context, project string, iid int, opts provider.UpdateMergeRequestOptions) (provider.MergeRequest, error)

UpdateMergeRequest applies a partial update to a pull request. The neutral State is translated to GitHub's state noun (open/closed).

func (*GitHub) UpdateMilestone added in v0.4.0

func (g *GitHub) UpdateMilestone(ctx context.Context, project string, id int, opts provider.UpdateMilestoneOptions) (provider.Milestone, error)

UpdateMilestone updates an existing repo-scoped milestone on GitHub.

Jump to

Keyboard shortcuts

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