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 ¶
- Variables
- type GitHub
- func (g *GitHub) ApproveMergeRequest(ctx context.Context, project string, iid int) error
- func (g *GitHub) CancelPipeline(ctx context.Context, project string, id int) error
- func (g *GitHub) CloseWorkItem(context.Context, string, int) error
- func (g *GitHub) CreateGroupEpic(ctx context.Context, groupID int, opts provider.CreateEpicOptions) (provider.Epic, error)
- func (g *GitHub) CreateGroupMilestone(ctx context.Context, groupID int, opts provider.CreateMilestoneOptions) (provider.Milestone, error)
- func (g *GitHub) CreateIssue(ctx context.Context, project string, opts provider.CreateIssueOptions) (provider.Issue, error)
- func (g *GitHub) CreateIssueNote(ctx context.Context, project string, iid int, body string) (provider.Note, error)
- func (g *GitHub) CreateLabel(ctx context.Context, project string, opts provider.CreateLabelOptions) (provider.Label, error)
- func (g *GitHub) CreateMergeRequest(ctx context.Context, project string, opts provider.CreateMergeRequestOptions) (provider.MergeRequest, error)
- func (g *GitHub) CreateMilestone(ctx context.Context, project string, opts provider.CreateMilestoneOptions) (provider.Milestone, error)
- func (g *GitHub) CreateWorkItem(context.Context, string, provider.CreateWorkItemOptions) (provider.WorkItem, error)
- func (g *GitHub) DownloadArtifact(ctx context.Context, project string, artifactID int, destDir string) error
- func (g *GitHub) GetIssue(ctx context.Context, project string, iid int) (provider.Issue, error)
- func (g *GitHub) GetJobLogs(ctx context.Context, project string, jobID int) (string, error)
- func (g *GitHub) GetMergeRequest(ctx context.Context, project string, iid int) (provider.MergeRequest, error)
- func (g *GitHub) GetMergeRequestDiff(ctx context.Context, project string, iid int) ([]provider.FileDiff, error)
- func (g *GitHub) GetMilestone(ctx context.Context, project string, id int) (provider.Milestone, error)
- func (g *GitHub) GetPipeline(ctx context.Context, project string, id int) (provider.Pipeline, error)
- func (g *GitHub) GetProject(ctx context.Context, project string) (provider.Project, error)
- func (g *GitHub) Host() string
- func (g *GitHub) Kind() provider.Kind
- func (g *GitHub) LinkIssueToEpic(_ context.Context, _, _, _ int) error
- func (g *GitHub) ListArtifacts(ctx context.Context, project string, pipelineID int) ([]provider.Artifact, error)
- func (g *GitHub) ListEpicIssues(_ context.Context, _ int, _ int) ([]provider.Issue, error)
- func (g *GitHub) ListGroupEpics(_ context.Context, _ int, _ provider.ListGroupEpicsOptions) ([]provider.Epic, error)
- func (g *GitHub) ListGroupMilestones(_ context.Context, _ int, _ provider.ListGroupMilestonesOptions) ([]provider.Milestone, error)
- func (g *GitHub) ListIssues(ctx context.Context, project string, opts provider.ListIssuesOptions) ([]provider.Issue, error)
- func (g *GitHub) ListLabels(ctx context.Context, project string) ([]provider.Label, error)
- func (g *GitHub) ListMergeRequests(ctx context.Context, project string, opts provider.ListMergeRequestsOptions) ([]provider.MergeRequest, error)
- func (g *GitHub) ListMilestones(ctx context.Context, project string, opts provider.ListMilestonesOptions) ([]provider.Milestone, error)
- func (g *GitHub) ListMyIssues(ctx context.Context, opts provider.ListMyIssuesOptions) ([]provider.Issue, error)
- func (g *GitHub) ListMyMergeRequests(ctx context.Context, opts provider.ListMyMergeRequestsOptions) ([]provider.MergeRequest, error)
- func (g *GitHub) ListPipelineJobs(ctx context.Context, project string, pipelineID int) ([]provider.Job, error)
- func (g *GitHub) ListPipelines(ctx context.Context, project string, opts provider.ListPipelinesOptions) ([]provider.Pipeline, error)
- func (g *GitHub) ListUsers(ctx context.Context, opts provider.ListUsersOptions) ([]provider.User, error)
- func (g *GitHub) ListWorkItems(context.Context, string, provider.ListWorkItemsOptions) ([]provider.WorkItem, error)
- func (g *GitHub) MergeMergeRequest(ctx context.Context, project string, iid int, opts provider.MergeOptions) (provider.MergeRequest, error)
- func (g *GitHub) ResolveGroup(_ context.Context, _ string) (int, error)
- func (g *GitHub) RetryPipeline(ctx context.Context, project string, id int) (provider.Pipeline, error)
- func (g *GitHub) RunPipeline(ctx context.Context, project string, opts provider.RunPipelineOptions) (provider.Pipeline, error)
- func (g *GitHub) UpdateGroupEpic(_ context.Context, _ int, _ int, _ provider.UpdateEpicOptions) (provider.Epic, error)
- func (g *GitHub) UpdateIssue(ctx context.Context, project string, iid int, opts provider.UpdateIssueOptions) (provider.Issue, error)
- func (g *GitHub) UpdateMergeRequest(ctx context.Context, project string, iid int, ...) (provider.MergeRequest, error)
- func (g *GitHub) UpdateMilestone(ctx context.Context, project string, id int, ...) (provider.Milestone, error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
New constructs a GitHub provider bound to cfg. Returns ErrFeatureDisabled when the GLVALET_GITHUB_ENABLED flag is not "true".
func NewWithClient ¶
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 ¶
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
CancelPipeline cancels a running GitHub Actions workflow run.
func (*GitHub) CloseWorkItem ¶ added in v0.4.0
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
func (g *GitHub) CreateWorkItem(context.Context, string, provider.CreateWorkItemOptions) (provider.WorkItem, error)
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) GetJobLogs ¶ added in v0.4.0
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
GetProject fetches repository metadata via the GitHub repos API.
func (*GitHub) LinkIssueToEpic ¶
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
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 ¶
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
func (g *GitHub) ListWorkItems(context.Context, string, provider.ListWorkItemsOptions) ([]provider.WorkItem, error)
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
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).