github

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: MIT Imports: 12 Imported by: 10 modules, 8 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

View Source
const EnvBaseURL = "GITHUB_BASE_URL"

EnvBaseURL is GitHub base URL. This can be set to a domain endpoint to use with GitHub Enterprise.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	IssuesCreateComment(ctx context.Context, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error)
	IssuesDeleteComment(ctx context.Context, commentID int64) (*github.Response, error)
	IssuesListLabels(ctx context.Context, number int, opt *github.ListOptions) ([]*github.Label, *github.Response, error)
	IssuesListComments(ctx context.Context, number int, opt *github.IssueListCommentsOptions) ([]*github.IssueComment, *github.Response, error)
	IssuesAddLabels(ctx context.Context, number int, labels []string) ([]*github.Label, *github.Response, error)
	IssuesRemoveLabel(ctx context.Context, number int, label string) (*github.Response, error)
	RepositoriesCreateComment(ctx context.Context, sha string, comment *github.RepositoryComment) (*github.RepositoryComment, *github.Response, error)
	RepositoriesListCommits(ctx context.Context, opt *github.CommitsListOptions) ([]*github.RepositoryCommit, *github.Response, error)
	RepositoriesGetCommit(ctx context.Context, sha string) (*github.RepositoryCommit, *github.Response, error)
}

API is GitHub API interface

type Client

type Client struct {
	*github.Client
	Debug bool

	Config Config

	Comment *CommentService
	Commits *CommitsService
	Notify  *NotifyService

	API API
	// contains filtered or unexported fields
}

Client is a API client for GitHub

func NewClient

func NewClient(cfg Config) (*Client, error)

NewClient returns Client initialized with Config

type CommentService

type CommentService service

CommentService handles communication with the comment related methods of GitHub API

func (*CommentService) Delete

func (g *CommentService) Delete(id int) error

Delete deletes comment on GitHub issues/pull requests

func (*CommentService) DeleteDuplicates

func (g *CommentService) DeleteDuplicates(title string)

DeleteDuplicates deletes duplicate comments containing arbitrary character strings

func (*CommentService) List

func (g *CommentService) List(number int) ([]*github.IssueComment, error)

List lists comments on GitHub issues/pull requests

func (*CommentService) Post

func (g *CommentService) Post(body string, opt PostOptions) error

Post posts comment

type CommitsService

type CommitsService service

CommitsService handles communication with the commits related methods of GitHub API

func (*CommitsService) List

func (g *CommitsService) List(revision string) ([]string, error)

List lists commits on a repository

func (*CommitsService) MergedPRNumber added in v0.5.2

func (g *CommitsService) MergedPRNumber(revision string) (int, error)

type Config

type Config struct {
	Token        string
	BaseURL      string
	Owner        string
	Repo         string
	PR           PullRequest
	CI           string
	Parser       terraform.Parser
	UseRawOutput bool
	WarnDestroy  bool
	// Template is used for all Terraform command output
	Template terraform.Template
	// DestroyWarningTemplate is used only for additional warning
	// the plan result contains destroy operation
	DestroyWarningTemplate terraform.Template
	// ResultLabels is a set of labels to apply depending on the plan result
	ResultLabels ResultLabels
}

Config is a configuration for GitHub client

type GitHub

type GitHub struct {
	*github.Client
	// contains filtered or unexported fields
}

GitHub represents the attribute information necessary for requesting GitHub API

func (*GitHub) IssuesAddLabels added in v0.6.1

func (g *GitHub) IssuesAddLabels(ctx context.Context, number int, labels []string) ([]*github.Label, *github.Response, error)

IssuesAddLabels is a wrapper of https://godoc.org/github.com/google/go-github/github#IssuesService.AddLabelsToIssue

func (*GitHub) IssuesCreateComment

func (g *GitHub) IssuesCreateComment(ctx context.Context, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error)

IssuesCreateComment is a wrapper of https://godoc.org/github.com/google/go-github/github#IssuesService.CreateComment

func (*GitHub) IssuesDeleteComment

func (g *GitHub) IssuesDeleteComment(ctx context.Context, commentID int64) (*github.Response, error)

IssuesDeleteComment is a wrapper of https://godoc.org/github.com/google/go-github/github#IssuesService.DeleteComment

func (*GitHub) IssuesListLabels added in v0.6.2

func (g *GitHub) IssuesListLabels(ctx context.Context, number int, opt *github.ListOptions) ([]*github.Label, *github.Response, error)

IssuesListLabels is a wrapper of https://godoc.org/github.com/google/go-github/github#IssuesService.ListLabelsByIssue

func (*GitHub) IssuesRemoveLabel added in v0.6.1

func (g *GitHub) IssuesRemoveLabel(ctx context.Context, number int, label string) (*github.Response, error)

IssuesRemoveLabel is a wrapper of https://godoc.org/github.com/google/go-github/github#IssuesService.RemoveLabelForIssue

func (*GitHub) RepositoriesGetCommit added in v0.5.2

func (g *GitHub) RepositoriesGetCommit(ctx context.Context, sha string) (*github.RepositoryCommit, *github.Response, error)

RepositoriesGetCommit is a wrapper of https://godoc.org/github.com/google/go-github/github#RepositoriesService.GetCommit

type NotifyService

type NotifyService service

NotifyService handles communication with the notification related methods of GitHub API

func (*NotifyService) Notify

func (g *NotifyService) Notify(body string) (exit int, err error)

Notify posts comment optimized for notifications

type PostOptions

type PostOptions struct {
	Number   int
	Revision string
}

PostOptions specifies the optional parameters to post comments to a pull request

type PullRequest

type PullRequest struct {
	Revision              string
	Title                 string
	Message               string
	Number                int
	DestroyWarningTitle   string
	DestroyWarningMessage string
}

PullRequest represents GitHub Pull Request metadata

func (*PullRequest) IsNumber

func (pr *PullRequest) IsNumber() bool

IsNumber returns true if PullRequest is Pull Request build

type ResultLabels added in v0.6.2

type ResultLabels struct {
	AddOrUpdateLabel string
	DestroyLabel     string
	NoChangesLabel   string
	PlanErrorLabel   string
}

ResultLabels represents the labels to add to the PR depending on the plan result

func (*ResultLabels) HasAnyLabelDefined added in v0.6.2

func (r *ResultLabels) HasAnyLabelDefined() bool

HasAnyLabelDefined returns true if any of the internal labels are set

func (*ResultLabels) IsResultLabel added in v0.6.2

func (r *ResultLabels) IsResultLabel(label string) bool

IsResultLabel returns true if a label matches any of the internal labels

Jump to

Keyboard shortcuts

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