ghclient

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GITHUB_TOEKN_ENV_VAR = "GITHUB_TOKEN"
)

Variables

View Source
var ErrGithubClientInitFailed = errors.New("failed to init github client")
View Source
var ErrGithubTokenNotFound = errors.New("github token is not found, unable to init github client")

Functions

This section is empty.

Types

type Client

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

Client github client

func NewClient

func NewClient(options *ClientOptions, logger *logr.Logger) *Client

NewClient create github client, init if not exist

func (*Client) AddPullRequestComment

func (c *Client) AddPullRequestComment(ctx context.Context, owner string, name string, number int, content string) error

AddPullRequestComment add comment to pull request

func (*Client) AddReviewComment

func (c *Client) AddReviewComment(ctx context.Context, owner, name string, number int, content string) (int64, error)

AddReviewComment add review comment

func (*Client) ClosePullRequest

func (c *Client) ClosePullRequest(ctx context.Context, owner string, name string, number int) error

ClosePullRequest close pull request

func (*Client) CreateAndPushCommit

func (c *Client) CreateAndPushCommit(ctx context.Context, owner string, name string, branch string, message string, contents map[string]string) error

CreateAndPushCommit create a commit with files (tree) to a ref(branch)

func (*Client) CreateBranch

func (c *Client) CreateBranch(ctx context.Context, owner string, name string, branch string) error

CreateBranch create a branch

func (*Client) CreatePullRequest

func (c *Client) CreatePullRequest(ctx context.Context, owner string, name string, subject string, description string, baseBranch string, headBranch string) (int, error)

CreatePullRequest create pull request

func (*Client) CreateRepository

func (c *Client) CreateRepository(ctx context.Context, owner string, name string, options map[string]string) (*Repository, error)

CreateRepository create repository

func (*Client) CreateSecretInRepository added in v0.0.12

func (c *Client) CreateSecretInRepository(ctx context.Context, owner string, name string, secretName string, secretValue string) error

func (*Client) DeleteBranch

func (c *Client) DeleteBranch(ctx context.Context, owner string, name string, branch string) error

DeleteBranch delete a branch TODO support delete branch

func (*Client) GetCurrentUser

func (c *Client) GetCurrentUser(ctx context.Context) string

func (*Client) GetOwner

func (c *Client) GetOwner(ctx context.Context, organizationName string) string

func (*Client) GetRepository

func (c *Client) GetRepository(ctx context.Context, owner string, name string) (*Repository, error)

GetRepository get repository by name

func (*Client) ListRepositories

func (c *Client) ListRepositories(ctx context.Context, owner string, filter string) ([]Repository, error)

ListRepositories list repository

func (*Client) MergePullRequest

func (c *Client) MergePullRequest(ctx context.Context, owner string, name string, number int)

MergePullRequest merge pull request

func (*Client) Publish added in v0.0.12

func (c *Client) Publish(ctx context.Context, owner string, name string, branchName string, path string, customDomain string) error

func (*Client) SubmitReview

func (c *Client) SubmitReview(ctx context.Context, owner string, name string, number int, content string) error

SubmitReview submit a review: comment, approve or request change

type ClientOptions

type ClientOptions struct {
	Endpoint    string `json:"endpoint" yaml:"endpoint"`
	TokenEnvVar string `json:"tokenEnvVar" yaml:"tokenEnvVar"`
	Author      string `json:"author" yaml:"author"`
	Email       string `json:"email" yaml:"email"`
}

type Repository

type Repository struct {
	Name     string `json:"name"`
	FullName string `json:"fullName"`
	URL      string `json:"url"`
	CloneURL string `json:"cloneUrl"`
}

Repository general infomration about repository

Jump to

Keyboard shortcuts

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