gitlabop

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// OAuth2AppID and OAuth2AppSecret
	// DONE(@yeqown) These two parameters should be passed from build parameters to keep application safety.
	// go build -ldflags="-X package/sub.OAuth2AppID=XXX -X package/sub.OAuth2AppSecret=XXX" ./cmd/gitlab-flow
	OAuth2AppID     string
	OAuth2AppSecret string
)

Functions

This section is empty.

Types

type Config added in v1.7.0

type Config struct {
	AppID        string
	AppSecret    string
	AccessToken  string
	RefreshToken string
	Host         string
	ApiURL       string
}

type CreateBranchRequest

type CreateBranchRequest struct {
	TargetBranch string
	SrcBranch    string
	ProjectID    int
}

CreateBranchRequest

type CreateBranchResult

type CreateBranchResult struct {
	Name   string
	WebURL string
}

type CreateIssueRequest

type CreateIssueRequest struct {
	Title, Desc, RelatedBranch string
	MilestoneID                int
	ProjectID                  int
}

CreateIssueRequest

type CreateIssueResult

type CreateIssueResult struct {
	ID     int
	IID    int
	WebURL string
}

type CreateMergeRequest

type CreateMergeRequest struct {
	Title, Desc, SrcBranch, TargetBranch string
	MilestoneID, IssueIID                int
	ProjectID                            int
}

CreateMergeRequest

type CreateMergeResult

type CreateMergeResult struct {
	ID     int
	WebURL string
}

type CreateMilestoneRequest

type CreateMilestoneRequest struct {
	Title     string
	Desc      string
	ProjectID int
}

CreateMilestoneRequest

type CreateMilestoneResult

type CreateMilestoneResult struct {
	ID     int
	WebURL string
}

type GetMilestoneIssuesRequest

type GetMilestoneIssuesRequest struct {
	MilestoneID int
	ProjectID   int
}

GetMilestoneIssuesRequest

type GetMilestoneIssuesResult

type GetMilestoneIssuesResult struct {
	Data []IssueShort
}

type GetMilestoneMergeRequestsRequest

type GetMilestoneMergeRequestsRequest struct {
	MilestoneID int
	ProjectID   int
}

GetMilestoneMergeRequestsRequest

type GetMilestoneMergeRequestsResult

type GetMilestoneMergeRequestsResult struct {
	Data []MergeRequestShort
}

type GetMilestoneRequest

type GetMilestoneRequest struct {
	MilestoneID int
	ProjectID   int
}

GetMilestoneRequest .

type GetMilestoneResult

type GetMilestoneResult struct {
	ID          int
	Title       string
	Description string
	WebURL      string
}

type IGitlabOauth2Support added in v1.7.0

type IGitlabOauth2Support interface {
	// Enter is an asynchronous process that would not return accessToken and refreshToken synchronized.
	// IGitlabOauth2Support.Load will return the refreshToken and accessToken after signaling.
	Enter(refreshToken string) (err error)

	// Load only use this after any signal from Enter channel. blocked method.
	Load() (accessToken, refreshToken string)
}

func NewOAuth2Support added in v1.7.0

func NewOAuth2Support(c *OAuth2Config) IGitlabOauth2Support

type IGitlabOperator

type IGitlabOperator interface {
	// CreateBranch create a branch on remote gitlab repository, but this would check remote
	// resource if create failed.
	CreateBranch(ctx context.Context, req *CreateBranchRequest) (*CreateBranchResult, error)

	// CreateMilestone create a milestone on remote gitlab repository, but this would check remote
	// resource if create failed.
	CreateMilestone(ctx context.Context, req *CreateMilestoneRequest) (*CreateMilestoneResult, error)
	GetMilestone(ctx context.Context, req *GetMilestoneRequest) (*GetMilestoneResult, error)
	GetMilestoneMergeRequests(
		ctx context.Context, req *GetMilestoneMergeRequestsRequest) (*GetMilestoneMergeRequestsResult, error)
	GetMilestoneIssues(ctx context.Context, req *GetMilestoneIssuesRequest) (*GetMilestoneIssuesResult, error)

	// CreateIssue create an issue on remote repository, but this would check remote
	// resource if create failed.
	CreateIssue(ctx context.Context, req *CreateIssueRequest) (*CreateIssueResult, error)
	// CreateMergeRequest create an merge request on remote repository, but this would check remote
	// resource if create failed.
	CreateMergeRequest(ctx context.Context, req *CreateMergeRequest) (*CreateMergeResult, error)

	ListMilestones(ctx context.Context, req *ListMilestoneRequest) (*ListMilestoneResult, error)
	ListProjects(ctx context.Context, req *ListProjectRequest) (*ListProjectResult, error)
}

IGitlabOperator contains all operations those manage repository, milestones, branch, issue and merge requests.

func NewGitlabOperator

func NewGitlabOperator(accessToken, apiURL string) IGitlabOperator

NewGitlabOperator generate IGitlabOperator.

type IssueShort

type IssueShort struct {
	ID          int
	IID         int
	Title       string
	Description string
	WebURL      string
	ProjectID   int
	MilestoneID int
}

type ListMilestoneRequest

type ListMilestoneRequest struct {
	Page      int
	PerPage   int
	ProjectID int
}

ListMilestoneRequest

type ListMilestoneResult

type ListMilestoneResult struct {
	Data []MilestoneShort
}

type ListProjectRequest

type ListProjectRequest struct {
	Page        int
	PerPage     int
	ProjectName string
}

type ListProjectResult

type ListProjectResult struct {
	Data []ProjectShort
}

type MergeRequestShort

type MergeRequestShort struct {
	ID           int
	Title        string
	Description  string
	WebURL       string
	SourceBranch string
	TargetBranch string
}

type MilestoneShort

type MilestoneShort struct {
	ID          int
	IID         int
	Name        string
	WebURL      string
	Description string
}

type OAuth2Config added in v1.7.0

type OAuth2Config struct {
	// Host of gitlab code repository web application, such as: https://git.example.com
	Host string

	// ServeAddr indicates which port will gitlabOAuth2Support will listen
	// to receive callback request from gitlab oauth server.
	ServeAddr string

	// AccessToken, RefreshToken represent tokens stored before,
	// if they are empty, means authorization is needed.
	AccessToken, RefreshToken string
}

OAuth2Config helps construct gitlab OAuth2 support.

type ProjectShort

type ProjectShort struct {
	ID     int
	Name   string
	WebURL string
}

Jump to

Keyboard shortcuts

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