ilyshin

package
Version: v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseHook

func ParseHook(eventType EventType, payload []byte) (event interface{}, err error)

Types

type Author

type Author struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

type BasicUser

type BasicUser struct {
	ID        int        `json:"id"`
	Username  string     `json:"username"`
	Name      string     `json:"name"`
	State     string     `json:"state"`
	CreatedAt *time.Time `json:"created_at"`
	AvatarURL string     `json:"avatar_url"`
	WebURL    string     `json:"web_url"`
}

type Branch

type Branch struct {
	Name               string  `json:"name"`
	Protected          bool    `json:"protected"`
	Merged             bool    `json:"merged"`
	Default            bool    `json:"default"`
	CanPush            bool    `json:"can_push"`
	DevelopersCanPush  bool    `json:"developers_can_push"`
	DevelopersCanMerge bool    `json:"developers_can_merge"`
	Commit             *Commit `json:"commit"`
}

type Changes

type Changes struct {
	OldPath     string `json:"old_path"`
	NewPath     string `json:"new_path"`
	AMode       string `json:"a_mode"`
	BMode       string `json:"b_mode"`
	Diff        string `json:"diff"`
	NewFile     bool   `json:"new_file"`
	RenamedFile bool   `json:"renamed_file"`
	DeletedFile bool   `json:"deleted_file"`
}

type Client

type Client struct {
	*httpclient.Client
	Address     string
	AccessToken string
}

func NewClient

func NewClient(address, accessToken string) *Client

func (*Client) AddProjectHook

func (c *Client) AddProjectHook(owner, repo, hookURL, token string) (*ProjectHook, error)

func (*Client) Compare

func (c *Client) Compare(projectID int, from, to string) ([]*Diff, error)

func (*Client) DeleteProjectHook

func (c *Client) DeleteProjectHook(owner, repo string, id int) error

func (*Client) GetFile

func (c *Client) GetFile(owner, repo string, ref, path string) (*File, error)

func (*Client) GetLatestCommit

func (c *Client) GetLatestCommit(owner, repo, branch, path string, log *zap.SugaredLogger) (*Commit, error)

func (*Client) GetLatestPRCommitList

func (c *Client) GetLatestPRCommitList(projectID string, pr int, log *zap.SugaredLogger) (*Commit, error)

func (*Client) GetRawFile

func (c *Client) GetRawFile(owner, repo string, sha string, fileName string) ([]byte, error)

func (*Client) ListBranches

func (c *Client) ListBranches(owner, repo string, log *zap.SugaredLogger) ([]*Branch, error)

func (*Client) ListChangedFiles

func (c *Client) ListChangedFiles(event *MergeEvent) ([]string, error)

func (*Client) ListGroupProjects

func (c *Client) ListGroupProjects(namespace, keyword string, log *zap.SugaredLogger) ([]*Project, error)

func (*Client) ListNamespaces

func (c *Client) ListNamespaces(keyword string, log *zap.SugaredLogger) ([]*Project, error)

func (*Client) ListOpenedProjectMergeRequests

func (c *Client) ListOpenedProjectMergeRequests(owner, repo, targetBranch string, log *zap.SugaredLogger) ([]*MergeRequest, error)

func (*Client) ListProjectHooks

func (c *Client) ListProjectHooks(owner, repo string, log *zap.SugaredLogger) ([]*ProjectHook, error)

func (*Client) ListTags

func (c *Client) ListTags(owner, repo string, log *zap.SugaredLogger) ([]*Tag, error)

func (*Client) ListTree

func (c *Client) ListTree(owner, repo string, ref string, path string) ([]*TreeNode, error)

type Commit

type Commit struct {
	ID             string     `json:"id"`
	ShortID        string     `json:"short_id"`
	Title          string     `json:"title"`
	Message        string     `json:"message"`
	AuthorName     string     `json:"author_name"`
	AuthorEmail    string     `json:"author_email"`
	AuthoredDate   *time.Time `json:"authored_date"`
	CommitterName  string     `json:"committer_name"`
	CommitterEmail string     `json:"committer_email"`
	CommittedDate  *time.Time `json:"committed_date"`
	CreatedAt      *time.Time `json:"created_at"`
}

type Commits

type Commits struct {
	ID        string     `json:"id"`
	Message   string     `json:"message"`
	Timestamp *time.Time `json:"timestamp"`
	URL       string     `json:"url"`
	Author    Author     `json:"author"`
	Added     []string   `json:"added"`
	Modified  []string   `json:"modified"`
	Removed   []string   `json:"removed"`
}

type Diff

type Diff struct {
	Diff        string `json:"diff"`
	NewPath     string `json:"new_path"`
	OldPath     string `json:"old_path"`
	AMode       string `json:"a_mode"`
	BMode       string `json:"b_mode"`
	NewFile     bool   `json:"new_file"`
	RenamedFile bool   `json:"renamed_file"`
	DeletedFile bool   `json:"deleted_file"`
}

type EventType

type EventType string

EventType represents a ilyshin event type.

const (
	EventTypeMergeRequest EventType = "Merge Request Hook"
	EventTypePush         EventType = "Push Hook"
	EventTypeTagPush      EventType = "Tag Push Hook"
)

List of available event types.

func HookEventType

func HookEventType(r *http.Request) EventType

HookEventType returns the event type for the given request.

type File

type File struct {
	FileName     string `json:"file_name"`
	FilePath     string `json:"file_path"`
	Size         int    `json:"size"`
	Encoding     string `json:"encoding"`
	Content      string `json:"content"`
	Ref          string `json:"ref"`
	BlobID       string `json:"blob_id"`
	CommitID     string `json:"commit_id"`
	SHA256       string `json:"content_sha256"`
	LastCommitID string `json:"last_commit_id"`
}

type Hook

type Hook struct {
	URL                   string `url:"url,omitempty" json:"url,omitempty"`
	Name                  string `url:"name,omitempty" json:"name,omitempty"`
	Token                 string `url:"token,omitempty" json:"token,omitempty"`
	PushEvents            bool   `url:"push_events,omitempty" json:"push_events,omitempty"`
	MergeRequestsEvents   bool   `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"`
	TagPushEvents         bool   `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"`
	EnableSSLVerification bool   `url:"enable_ssl_verification,omitempty" json:"enable_ssl_verification,omitempty"`
}

type LastCommit

type LastCommit struct {
	ID        string     `json:"id"`
	Message   string     `json:"message"`
	Timestamp *time.Time `json:"timestamp"`
	URL       string     `json:"url"`
	Author    Author     `json:"author"`
}

type MergeEvent

type MergeEvent struct {
	ObjectKind       string           `json:"object_kind"`
	Project          ProjectEvent     `json:"project"`
	ObjectAttributes ObjectAttributes `json:"object_attributes"`
}

type MergeRequest

type MergeRequest struct {
	ID              int        `json:"id"`
	IID             int        `json:"iid"`
	ProjectID       int        `json:"project_id"`
	Title           string     `json:"title"`
	State           string     `json:"state"`
	CreatedAt       *time.Time `json:"created_at"`
	UpdatedAt       *time.Time `json:"updated_at"`
	SourceBranch    string     `json:"source_branch"`
	TargetBranch    string     `json:"target_branch"`
	SourceProjectID int        `json:"source_project_id"`
	TargetProjectID int        `json:"target_project_id"`
	Description     string     `json:"description"`
	Author          *BasicUser `json:"author"`
	Changes         []Changes  `json:"changes"`
}

type ObjectAttributes

type ObjectAttributes struct {
	ID                       int         `json:"id"`
	TargetBranch             string      `json:"target_branch"`
	SourceBranch             string      `json:"source_branch"`
	SourceProjectID          int         `json:"source_project_id"`
	AuthorID                 int         `json:"author_id"`
	AssigneeID               int         `json:"assignee_id"`
	AssigneeIDs              []int       `json:"assignee_ids"`
	Title                    string      `json:"title"`
	StCommits                []*Commit   `json:"st_commits"`
	MilestoneID              int         `json:"milestone_id"`
	State                    string      `json:"state"`
	MergeStatus              string      `json:"merge_status"`
	TargetProjectID          int         `json:"target_project_id"`
	IID                      int         `json:"iid"`
	Description              string      `json:"description"`
	Position                 int         `json:"position"`
	LockedAt                 string      `json:"locked_at"`
	UpdatedByID              int         `json:"updated_by_id"`
	MergeError               string      `json:"merge_error"`
	MergeWhenBuildSucceeds   bool        `json:"merge_when_build_succeeds"`
	MergeUserID              int         `json:"merge_user_id"`
	MergeCommitSHA           string      `json:"merge_commit_sha"`
	DeletedAt                string      `json:"deleted_at"`
	ApprovalsBeforeMerge     string      `json:"approvals_before_merge"`
	RebaseCommitSHA          string      `json:"rebase_commit_sha"`
	InProgressMergeCommitSHA string      `json:"in_progress_merge_commit_sha"`
	LockVersion              int         `json:"lock_version"`
	TimeEstimate             int         `json:"time_estimate"`
	Target                   *Repository `json:"target"`
	LastCommit               LastCommit  `json:"last_commit"`
	WorkInProgress           bool        `json:"work_in_progress"`
	URL                      string      `json:"url"`
	Action                   string      `json:"action"`
	OldRev                   string      `json:"oldrev"`
}

type Project

type Project struct {
	ID                int               `json:"id"`
	Description       string            `json:"description"`
	Name              string            `json:"name"`
	NameWithNamespace string            `json:"name_with_namespace"`
	Path              string            `json:"path"`
	PathWithNamespace string            `json:"path_with_namespace"`
	CreatedAt         *time.Time        `json:"created_at,omitempty"`
	Archived          bool              `json:"archived"`
	DefaultBranch     string            `json:"default_branch"`
	Namespace         *ProjectNamespace `json:"namespace"`
}

type ProjectEvent

type ProjectEvent struct {
	ID                int    `json:"id"`
	Name              string `json:"name"`
	Description       string `json:"description"`
	AvatarURL         string `json:"avatar_url"`
	GitSSHURL         string `json:"git_ssh_url"`
	GitHTTPURL        string `json:"git_http_url"`
	Namespace         string `json:"namespace"`
	PathWithNamespace string `json:"path_with_namespace"`
	DefaultBranch     string `json:"default_branch"`
	Homepage          string `json:"homepage"`
	URL               string `json:"url"`
	SSHURL            string `json:"ssh_url"`
	HTTPURL           string `json:"http_url"`
	WebURL            string `json:"web_url"`
}

type ProjectHook

type ProjectHook struct {
	ID                       int        `json:"id"`
	URL                      string     `json:"url"`
	ConfidentialNoteEvents   bool       `json:"confidential_note_events"`
	ProjectID                int        `json:"project_id"`
	PushEvents               bool       `json:"push_events"`
	PushEventsBranchFilter   string     `json:"push_events_branch_filter"`
	IssuesEvents             bool       `json:"issues_events"`
	ConfidentialIssuesEvents bool       `json:"confidential_issues_events"`
	MergeRequestsEvents      bool       `json:"merge_requests_events"`
	TagPushEvents            bool       `json:"tag_push_events"`
	NoteEvents               bool       `json:"note_events"`
	JobEvents                bool       `json:"job_events"`
	PipelineEvents           bool       `json:"pipeline_events"`
	WikiPageEvents           bool       `json:"wiki_page_events"`
	DeploymentEvents         bool       `json:"deployment_events"`
	ReleasesEvents           bool       `json:"releases_events"`
	EnableSSLVerification    bool       `json:"enable_ssl_verification"`
	CreatedAt                *time.Time `json:"created_at"`
}

type ProjectNamespace

type ProjectNamespace struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	Path     string `json:"path"`
	Kind     string `json:"kind"`
	FullPath string `json:"full_path"`
}

type PushEvent

type PushEvent struct {
	ObjectKind        string       `json:"object_kind"`
	Before            string       `json:"before"`
	After             string       `json:"after"`
	Ref               string       `json:"ref"`
	CheckoutSHA       string       `json:"checkout_sha"`
	UserID            int          `json:"user_id"`
	UserName          string       `json:"user_name"`
	UserUsername      string       `json:"user_username"`
	UserEmail         string       `json:"user_email"`
	UserAvatar        string       `json:"user_avatar"`
	ProjectID         int          `json:"project_id"`
	Project           ProjectEvent `json:"project"`
	Commits           []Commits    `json:"commits"`
	TotalCommitsCount int          `json:"total_commits_count"`
}

type ReleaseNote

type ReleaseNote struct {
	TagName     string `json:"tag_name"`
	Description string `json:"description"`
}

type Repository

type Repository struct {
	Name              string `json:"name"`
	Description       string `json:"description"`
	WebURL            string `json:"web_url"`
	AvatarURL         string `json:"avatar_url"`
	GitSSHURL         string `json:"git_ssh_url"`
	GitHTTPURL        string `json:"git_http_url"`
	Namespace         string `json:"namespace"`
	PathWithNamespace string `json:"path_with_namespace"`
	DefaultBranch     string `json:"default_branch"`
	Homepage          string `json:"homepage"`
	URL               string `json:"url"`
	SSHURL            string `json:"ssh_url"`
	HTTPURL           string `json:"http_url"`
}

type Tag

type Tag struct {
	Name    string       `json:"name"`
	Message string       `json:"message"`
	Release *ReleaseNote `json:"release"`
	Commit  *Commit      `json:"commit"`
}

type TreeNode

type TreeNode struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"`
	Path string `json:"path"`
	Mode string `json:"mode"`
}

Jump to

Keyboard shortcuts

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