github

package
v4.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: MIT Imports: 13 Imported by: 0

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.

View Source
const EnvToken = "GITHUB_TOKEN" //nolint:gosec

EnvToken is GitHub API Token

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)
	IssuesEditComment(ctx context.Context, commentID int64, comment *github.IssueComment) (*github.IssueComment, *github.Response, error)
	IssuesListLabels(ctx context.Context, number int, opt *github.ListOptions) ([]*github.Label, *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)
	IssuesUpdateLabel(ctx context.Context, label, color string) (*github.Label, *github.Response, error)
	RepositoriesCreateComment(ctx context.Context, sha string, comment *github.RepositoryComment) (*github.RepositoryComment, *github.Response, error)
	PullRequestsListPullRequestsWithCommit(ctx context.Context, sha string, opt *github.ListOptions) ([]*github.PullRequest, *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
	User    *UserService

	API API
	// contains filtered or unexported fields
}

Client is a API client for GitHub

func NewClient

func NewClient(ctx context.Context, 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) List

func (g *CommentService) List(ctx context.Context, owner, repo string, number int) ([]*IssueComment, error)

func (*CommentService) Patch

func (g *CommentService) Patch(ctx context.Context, body string, commentID int64) error

func (*CommentService) Post

func (g *CommentService) Post(ctx context.Context, 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) PRNumber

func (g *CommitsService) PRNumber(ctx context.Context, sha string) (int, error)

type Config

type Config struct {
	Token           string
	BaseURL         string
	GraphQLEndpoint string
	Owner           string
	Repo            string
	PR              PullRequest
	CI              string
	Parser          terraform.Parser
	// Template is used for all Terraform command output
	Template           *terraform.Template
	ParseErrorTemplate *terraform.Template
	// ResultLabels is a set of labels to apply depending on the plan result
	ResultLabels     ResultLabels
	Vars             map[string]string
	EmbeddedVarNames []string
	Templates        map[string]string
	UseRawOutput     bool
	Patch            bool
	SkipNoChanges    bool
}

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

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) IssuesEditComment

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

func (*GitHub) IssuesListLabels

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

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) IssuesUpdateLabel

func (g *GitHub) IssuesUpdateLabel(ctx context.Context, label, color string) (*github.Label, *github.Response, error)

IssuesUpdateLabel is a wrapper of https://pkg.go.dev/github.com/google/go-github/github#IssuesService.EditLabel

func (*GitHub) PullRequestsListPullRequestsWithCommit

func (g *GitHub) PullRequestsListPullRequestsWithCommit(ctx context.Context, sha string, opt *github.ListOptions) ([]*github.PullRequest, *github.Response, error)

type IssueComment

type IssueComment struct {
	DatabaseID  int
	Body        string
	IsMinimized bool
}

type ListOptions

type ListOptions struct {
	PRNumber int
	Owner    string
	Repo     string
}

type Metadata

type Metadata struct {
	Target  string
	Program string
	Command string
}

type NotifyService

type NotifyService service

NotifyService handles communication with the notification related methods of GitHub API

func (*NotifyService) Apply

func (g *NotifyService) Apply(ctx context.Context, param *notifier.ParamExec) error

Apply posts comment optimized for notifications

func (*NotifyService) Plan

func (g *NotifyService) Plan(ctx context.Context, param *notifier.ParamExec) error

Plan 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
	Number   int
}

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

type ResultLabels struct {
	AddOrUpdateLabel      string
	DestroyLabel          string
	NoChangesLabel        string
	PlanErrorLabel        string
	AddOrUpdateLabelColor string
	DestroyLabelColor     string
	NoChangesLabelColor   string
	PlanErrorLabelColor   string
}

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

func (*ResultLabels) HasAnyLabelDefined

func (r *ResultLabels) HasAnyLabelDefined() bool

HasAnyLabelDefined returns true if any of the internal labels are set

func (*ResultLabels) IsResultLabel

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

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

type UserService

type UserService service

func (*UserService) Get

func (g *UserService) Get(ctx context.Context) (string, error)

Jump to

Keyboard shortcuts

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