gitlab

package
v0.1.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(secret, headerToken string) error

Validate validates the webhook payload

Types

type Client

type Client struct {
	IntegrationConfig *cicdv1.IntegrationConfig
	K8sClient         client.Client
}

Client is a gitlab client struct

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(id int) error

DeleteWebhook deletes registered webhook

func (*Client) GetUserInfo added in v0.1.4

func (c *Client) GetUserInfo(userID string) (*git.User, error)

GetUserInfo gets a user's information

func (*Client) ListWebhook

func (c *Client) ListWebhook() ([]git.WebhookEntry, error)

ListWebhook lists registered webhooks

func (*Client) ParseWebhook

func (c *Client) ParseWebhook(header http.Header, jsonString []byte) (*git.Webhook, error)

ParseWebhook parses a webhook body for gitlab

func (*Client) RegisterWebhook

func (c *Client) RegisterWebhook(uri string) error

RegisterWebhook registers our webhook server to the remote git server

func (*Client) SetCommitStatus

func (c *Client) SetCommitStatus(integrationJob *cicdv1.IntegrationJob, context string, state git.CommitStatusState, description, targetURL string) error

SetCommitStatus sets commit status for the specific commit

type CommitStatusBody

type CommitStatusBody struct {
	State       string `json:"state"`
	TargetURL   string `json:"target_url"`
	Description string `json:"description"`
	Context     string `json:"context"`
}

CommitStatusBody is an API body for setting commits' status

type LastCommit

type LastCommit struct {
	Sha string `json:"id"`
}

LastCommit is a commit hash for the last commit of the pull request

type MergeRequestWebhook

type MergeRequestWebhook struct {
	Kind            string          `json:"kind"`
	User            User            `json:"user"`
	ObjectAttribute ObjectAttribute `json:"object_attributes"`
	Project         Project         `json:"project"`
}

MergeRequestWebhook is a gitlab-specific merge-request event webhook body

type ObjectAttribute

type ObjectAttribute struct {
	Title      string     `json:"title"`
	ID         int        `json:"id"`
	BaseRef    string     `json:"target_branch"`
	HeadRef    string     `json:"source_branch"`
	LastCommit LastCommit `json:"last_commit"`
	State      string     `json:"state"`
	Action     string     `json:"action"`
}

ObjectAttribute is a core body for pull request webhook

type Project

type Project struct {
	Name   string `json:"path_with_namespace"`
	WebURL string `json:"web_url"`
}

Project is a name/url for the repository

type PushWebhook

type PushWebhook struct {
	Kind     string  `json:"object_kind"`
	Ref      string  `json:"ref"`
	Project  Project `json:"project"`
	UserName string  `json:"user_name"`
	UserID   int     `json:"user_id"`
	Sha      string  `json:"after"`
}

PushWebhook is a gitlab-specific push event webhook body

type RegistrationWebhookBody

type RegistrationWebhookBody struct {
	EnableSSLVerification   bool   `json:"enable_ssl_verification"`
	ConfidentialIssueEvents bool   `json:"confidential_issues_events"`
	ConfidentialNoteEvents  bool   `json:"confidential_note_events"`
	DeploymentEvents        bool   `json:"deployment_events"`
	ID                      string `json:"id"`
	IssueEvents             bool   `json:"issues_events"`
	JobEvents               bool   `json:"job_events"`
	MergeRequestEvents      bool   `json:"merge_requests_events"`
	NoteEvents              bool   `json:"note_events"`
	PipeLineEvents          bool   `json:"pipeline_events"`
	PushEvents              bool   `json:"push_events"`
	TagPushEvents           bool   `json:"tag_push_events"`
	WikiPageEvents          bool   `json:"wiki_page_events"`
	URL                     string `json:"url"`
	Token                   string `json:"token"`
}

RegistrationWebhookBody is a body for requesting webhook registration for the remote git server

type User added in v0.1.4

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

User is a user who triggered merge request event

type UserInfo added in v0.1.4

type UserInfo struct {
	ID          int    `json:"id"`
	UserName    string `json:"username"`
	PublicEmail string `json:"public_email"`
	Email       string `json:"email"`
}

UserInfo is a body of user get API

type WebhookEntry

type WebhookEntry struct {
	ID  int    `json:"id"`
	URL string `json:"url"`
}

WebhookEntry is a body of list of registered webhooks

Jump to

Keyboard shortcuts

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