github

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package github provides a client for syncing compliance findings with GitHub issues.

It wraps go-github to:

  • Create tracking issues for findings
  • Discover linked issues/PRs from comments
  • Sync issue state back to finding status
  • Collect evidence from closed issues/PRs (merge info)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps the GitHub API for compliance operations.

func New

func New(ctx context.Context) (*Client, error)

New creates a Client. It expects GITHUB_TOKEN in the environment (via go-github default).

func NewWithToken

func NewWithToken(ctx context.Context, token string) *Client

NewWithToken creates a Client with an explicit token.

func (*Client) AddLabels added in v0.6.0

func (c *Client) AddLabels(ctx context.Context, repo string, number int, labels []string) error

AddLabels adds labels to an existing issue.

func (*Client) CreateIssue

func (c *Client) CreateIssue(ctx context.Context, repo, title, body string, labels []string) (int, error)

CreateIssue creates a new GitHub issue and returns the issue number.

func (c *Client) DiscoverCommentLinks(ctx context.Context, repo string, number int) ([]IssueRef, []IssueRef, error)

DiscoverCommentLinks finds issue/PR references in comments on a tracking issue. Returns (issues, prs) that are not self-references.

func (*Client) EnsureLabels

func (c *Client) EnsureLabels(ctx context.Context, repo string, labels map[string]string) error

EnsureLabels creates labels that don't exist yet.

func (*Client) GetIssueState

func (c *Client) GetIssueState(ctx context.Context, repo string, number int) (*IssueState, error)

GetIssueState fetches the state of a single issue.

func (*Client) GetPRMergeInfo

func (c *Client) GetPRMergeInfo(ctx context.Context, repo string, number int) (bool, string, string, error)

GetPRMergeInfo returns merge metadata for a pull request. Returns (merged bool, mergedAt string, mergeCommitSHA string, err).

type IssueRef

type IssueRef struct {
	Repo   string
	Number int
}

IssueRef is a (repo, number) pair.

type IssueState

type IssueState struct {
	Number      int
	State       string // OPEN, CLOSED
	StateReason string // COMPLETED, NOT_PLANNED, REOPENED
	Labels      []string
	MergedAt    string // for PRs only
}

IssueState holds the state of a GitHub issue relevant to compliance sync.

Jump to

Keyboard shortcuts

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