gitlab

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SecretTokenLength is the length of secret token.
	SecretTokenLength = 16
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FileCommit

type FileCommit struct {
	Branch        string `json:"branch"`
	Content       string `json:"content"`
	CommitMessage string `json:"commit_message"`
	LastCommitID  string `json:"last_commit_id,omitempty"`
}

FileCommit is the API message for file commit.

type FileMeta

type FileMeta struct {
	LastCommitID string `json:"last_commit_id"`
}

FileMeta is the API message for file metadata.

type ProjectRole

type ProjectRole string

ProjectRole is the role of the project member

const (
	ProjectRoleOwner         ProjectRole = "Owner"
	ProjectRoleMaintainer    ProjectRole = "Maintainer"
	ProjectRoleDeveloper     ProjectRole = "Developer"
	ProjectRoleReporter      ProjectRole = "Reporter"
	ProjectRoleGuest         ProjectRole = "Guest"
	ProjectRoleMinimalAccess ProjectRole = "MinimalAccess"
	ProjectRoleNoAccess      ProjectRole = "NoAccess"
)

Gitlab Role type

func (ProjectRole) String

func (e ProjectRole) String() string

type Provider

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

Provider is the GitLab self host provider.

func (*Provider) APIURL

func (provider *Provider) APIURL(instanceURL string) string

APIURL returns the API URL path of a GitLab instance.

func (*Provider) CreateFile

func (provider *Provider) CreateFile(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string, filePath string, fileCommitCreate vcs.FileCommitCreate) error

CreateFile creates a file.

func (*Provider) CreateWebhook

func (provider *Provider) CreateWebhook(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string, payload []byte) (string, error)

CreateWebhook creates a webhook in a GitLab project.

func (*Provider) DeleteWebhook

func (provider *Provider) DeleteWebhook(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string, webhookID string) error

DeleteWebhook deletes a webhook in a GitLab project.

func (*Provider) FetchRepositoryActiveMemberList

func (provider *Provider) FetchRepositoryActiveMemberList(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string) ([]*vcs.RepositoryMember, error)

FetchRepositoryActiveMemberList fetch all active members of a repository

func (*Provider) FetchUserInfo

func (provider *Provider) FetchUserInfo(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, userID int) (*vcs.UserInfo, error)

FetchUserInfo will fetch user info from GitLab. If userID is set to nil, the user info of the current oauth would be returned.

func (*Provider) OverwriteFile

func (provider *Provider) OverwriteFile(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string, filePath string, fileCommitCreate vcs.FileCommitCreate) error

OverwriteFile overwrite the content of a file.

func (*Provider) PatchWebhook

func (provider *Provider) PatchWebhook(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string, webhookID string, payload []byte) error

PatchWebhook patches a webhook in a GitLab project.

func (*Provider) ReadFile

func (provider *Provider) ReadFile(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string, filePath string, commitID string) (string, error)

ReadFile reads the content of a file.

func (*Provider) ReadFileMeta

func (provider *Provider) ReadFileMeta(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string, filePath string, branch string) (*vcs.FileMeta, error)

ReadFileMeta reads the metadata of a file.

func (*Provider) TryLogin

func (provider *Provider) TryLogin(ctx context.Context, oauthCtx common.OauthContext, instanceURL string) (*vcs.UserInfo, error)

TryLogin will try to fetch the user info from the current OAuth content of GitLab.

type WebhookCommit

type WebhookCommit struct {
	ID        string              `json:"id"`
	Title     string              `json:"title"`
	Message   string              `json:"message"`
	Timestamp string              `json:"timestamp"`
	URL       string              `json:"url"`
	Author    WebhookCommitAuthor `json:"author"`
	AddedList []string            `json:"added"`
}

WebhookCommit is the API message for webhook commit.

type WebhookCommitAuthor

type WebhookCommitAuthor struct {
	Name string `json:"name"`
}

WebhookCommitAuthor is the API message for webhook commit author.

type WebhookInfo

type WebhookInfo struct {
	ID int `json:"id"`
}

WebhookInfo is the API message for webhook info.

type WebhookPost

type WebhookPost struct {
	URL         string `json:"url"`
	SecretToken string `json:"token"`
	// This is set to true
	PushEvents bool `json:"push_events"`
	// For now, there is no native dry run DDL support in mysql/postgres. One may wonder if we could wrap the DDL
	// in a transaction and just not commit at the end, unfortunately there are side effects which are hard to control.
	// See https://www.postgresql.org/message-id/CAMsr%2BYGiYQ7PYvYR2Voio37YdCpp79j5S%2BcmgVJMOLM2LnRQcA%40mail.gmail.com
	// So we can't possibly display useful info when reviewing a MR, thus we don't enable this event.
	// Saying that, delivering a souding dry run solution would be great and hopefully we can achieve that one day.
	// MergeRequestsEvents  bool   `json:"merge_requests_events"`
	PushEventsBranchFilter string `json:"push_events_branch_filter"`
	// TODO(tianzhou): This is set to false, be lax to not enable_ssl_verification
	EnableSSLVerification bool `json:"enable_ssl_verification"`
}

WebhookPost is the API message for webhook POST.

type WebhookProject

type WebhookProject struct {
	ID       int    `json:"id"`
	WebURL   string `json:"web_url"`
	FullPath string `json:"path_with_namespace"`
}

WebhookProject is the API message for webhook project.

type WebhookPushEvent

type WebhookPushEvent struct {
	ObjectKind WebhookType     `json:"object_kind"`
	Ref        string          `json:"ref"`
	AuthorName string          `json:"user_name"`
	Project    WebhookProject  `json:"project"`
	CommitList []WebhookCommit `json:"commits"`
}

WebhookPushEvent is the API message for webhook push event.

type WebhookPut

type WebhookPut struct {
	URL                    string `json:"url"`
	PushEventsBranchFilter string `json:"push_events_branch_filter"`
}

WebhookPut is the API message for webhook PUT.

type WebhookType

type WebhookType string

WebhookType is the gitlab webhook type.

const (
	// WebhookPush is the webhook type for push.
	WebhookPush WebhookType = "push"
)

func (WebhookType) String

func (e WebhookType) String() string

Jump to

Keyboard shortcuts

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