issues

package
v0.0.0-...-210767f Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package issues provides a general way to interact with issues, and a client for interacting with the GitHub issues API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	GitHub *github.Client
	Owner  string
	Repo   string
}

Client is a shallow client for a github.Client.

func NewClient

func NewClient(ctx context.Context, cfg *Config) *Client

NewClient creates a Client that will create issues in the a GitHub repo.

func NewTestClient

func NewTestClient(ctx context.Context, cfg *Config, baseURL *url.URL) *Client

NewTestClient creates a Client for use in tests.

func (*Client) CreateIssue

func (c *Client) CreateIssue(ctx context.Context, iss *Issue) (number int, err error)

CreateIssue creates a new issue.

func (*Client) Destination

func (c *Client) Destination() string

Destination returns the URL of the Github repo.

func (*Client) Issue

func (c *Client) Issue(ctx context.Context, number int) (_ *Issue, err error)

Issue returns the issue with the given issue number.

func (*Client) IssueExists

func (c *Client) IssueExists(ctx context.Context, number int) (_ bool, err error)

IssueExists reports whether an issue with the given ID exists.

func (*Client) Issues

func (c *Client) Issues(ctx context.Context, opts IssuesOptions) (_ []*Issue, err error)

Issues returns all Github issues that match the filters in opts.

func (*Client) Reference

func (c *Client) Reference(num int) string

Reference returns the URL of the given issue.

type Config

type Config struct {
	// Owner is the owner of a GitHub repo. For example, "golang" is the owner
	// for github.com/khulnasoft-lab/go-vulndb.
	Owner string

	// Repo is the name of a GitHub repo. For example, "vulndb" is the repo
	// name for github.com/khulnasoft-lab/go-vulndb.
	Repo string

	// Token is access token that authorizes and authenticates
	// requests to the GitHub API.
	Token string
}

Config is used to initialize a new Client.

type Issue

type Issue struct {
	Number    int
	Title     string
	Body      string
	State     string
	Labels    []string
	CreatedAt time.Time
}

Issue represents a GitHub issue.

func (*Issue) NewGoID

func (iss *Issue) NewGoID() string

NewGoID creates a Go advisory ID based on the issue number and time of issue creation.

type IssuesOptions

type IssuesOptions struct {
	// State filters issues based on their state. Possible values are: open,
	// closed, all. Default is "open".
	State string

	// Labels filters issues based on their label.
	Labels []string
}

IssuesOptions are options for Issues

Directories

Path Synopsis
Package githubtest provides a test client and server for testing the GitHub API client.
Package githubtest provides a test client and server for testing the GitHub API client.

Jump to

Keyboard shortcuts

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