gitee_utils

package
v0.0.0-...-d433b81 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogInstance = logrus.New()

Functions

func ConfigFile

func ConfigFile()

func DoByFixTime

func DoByFixTime()

func PathExists

func PathExists(path string) (bool, error)

func ValidateWebhook

func ValidateWebhook(w http.ResponseWriter, r *http.Request) (string, string, []byte, bool, int)

ValidateWebhook ensures that the provided request conforms to the format of a Gitee webhook and the payload can be validated with the provided hmac secret. It returns the event type, the event guid, the payload of the request, whether the webhook is valid or not, and finally the resultant HTTP status code

Types

type CSTFormatter

type CSTFormatter struct {
	logrus.Formatter
}

func (CSTFormatter) Format

func (u CSTFormatter) Format(e *logrus.Entry) ([]byte, error)

type Client

type Client interface {
	CreatePullRequest(org, repo, title, body, head, base string, canModify bool) (sdk.PullRequest, error)
	GetPullRequests(org, repo string, opts ListPullRequestOpt) ([]sdk.PullRequest, error)
	UpdatePullRequest(org, repo string, number int32, param sdk.PullRequestUpdateParam) (sdk.PullRequest, error)

	GetRef(org, repo, ref string) (string, error)
	GetPRLabels(org, repo string, number int) ([]sdk.Label, error)
	ListPRComments(org, repo string, number int) ([]sdk.PullRequestComments, error)
	ListPrIssues(org, repo string, number int32) ([]sdk.Issue, error)
	DeletePRComment(org, repo string, ID int) error
	CreatePRComment(org, repo string, number int, comment string) error
	UpdatePRComment(org, repo string, commentID int, comment string) error
	AddPRLabel(org, repo string, number int, labels []string) error
	RemovePRLabel(org, repo string, number int, label string) error

	AssignPR(owner, repo string, number int, logins []string) error
	UnassignPR(owner, repo string, number int, logins []string) error
	GetPRCommits(org, repo string, number int) ([]sdk.PullRequestCommits, error)

	AssignGiteeIssue(org, repo, labels string, number string, login string) error
	UnassignGiteeIssue(org, repo, labels string, number string, login string) error
	CreateGiteeIssueComment(org, repo string, number string, comment string) error

	IsCollaborator(owner, repo, login string) (bool, error)
	IsMember(org, login string) (bool, error)
	GetGiteePullRequest(org, repo string, number int) (sdk.PullRequest, error)
	GetGiteeRepo(org, repo string) (sdk.Project, error)
	MergePR(owner, repo string, number int, opt sdk.PullRequestMergePutParam) error

	GetRepos(org string) ([]sdk.Project, error)
	RemoveIssueLabel(org, repo, number, label string) error
	AddIssueLabel(org, repo, number string, label []string) error
	AddIssueAssignee(org, repo, number, token, assignee string) error
	GetUserOrg(login string) ([]sdk.Group, error)
	GetUserEnt(ent, login string) (sdk.EnterpriseMember, error)

	ListIssues(owner, repo, state, since, createAt string, page, perPage int) ([]sdk.Issue, *http.Response, error)
	ListLabels(owner, repo string) ([]sdk.Label, error)
}

Client interface for Gitee API

func NewClient

func NewClient(getToken func() []byte) Client

type Consumer

type Consumer struct {
	Rabbit *Rabbit
	// contains filtered or unexported fields
}

func NewConsumer

func NewConsumer(config ConsumerConfig, rabbit *Rabbit) *Consumer

NewConsumer returns a consumer instance.

func (*Consumer) Start

func (c *Consumer) Start() error

Start declares all the necessary components of the consumer and runs the consumers. This is called one at the application start up or when consumer needs to reconnects to the server.

type ConsumerConfig

type ConsumerConfig struct {
	ExchangeName  string
	ExchangeType  string
	RoutingKey    string
	QueueName     string
	ConsumerName  string
	ConsumerCount int
	PrefetchCount int
	Reconnect     struct {
		MaxAttempt int
		Interval   time.Duration
	}
}

type ErrorForbidden

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

func (ErrorForbidden) Error

func (e ErrorForbidden) Error() string

type InfoContent

type InfoContent struct {
	ChineseContent string `json:"Chinese"`
	EnglishContent string `json:"English"`
	GeneralContent string `json:"general_content"`
}

type Issue

type Issue struct {
	IssueID          string     `json:"issueID"`
	EventType        string     `json:"eventType"`
	TargetInfo       TargetInfo `json:"targetInfo"`
	TargetLabel      string     `json:"targetLabel"`
	TargetAssigneeID string     `json:"targetAssigneeID"`
	PushTime         string     `json:"pushTime"`
	RepoInfo         RepoInfo   `json:"repoInfo"`
}

type ListPullRequestOpt

type ListPullRequestOpt struct {
	State           string
	Head            string
	Base            string
	Sort            string
	Direction       string
	MilestoneNumber int
	Labels          []string
}

type Rabbit

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

func NewRabbit

func NewRabbit(config RabbitConfig) *Rabbit

NewRabbit returns a RabbitMQ instance.

func (*Rabbit) Channel

func (r *Rabbit) Channel() (*amqp.Channel, error)

Channel returns a new `*amqp.Channel` instance.

func (*Rabbit) Connect

func (r *Rabbit) Connect() error

Connect connects to RabbitMQ server.

func (*Rabbit) Connection

func (r *Rabbit) Connection() (*amqp.Connection, error)

Connection returns exiting `*amqp.Connection` instance.

type RabbitConfig

type RabbitConfig struct {
	Schema         string
	Username       string
	Password       string
	Host           string
	Port           string
	VHost          string
	ConnectionName string
}

type RepoInfo

type RepoInfo struct {
	Org  string `json:"org"`
	Repo string `json:"repo"`
	Ent  string `json:"ent"`
}

type TargetInfo

type TargetInfo struct {
	TargetUser  []string    `json:"targetUser"`
	InfoType    string      `json:"infoType"`
	InfoContent InfoContent `json:"infoContent"`
}

Jump to

Keyboard shortcuts

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