gitlab

package
v0.0.0-...-c8c72b8 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package gitlab provides a webhook.Provider implementation for GitLab webhooks. It handles event type detection via the X-Gitlab-Event header and secret token verification via the X-Gitlab-Token header (plain string comparison).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RepoURL

func RepoURL(payload []byte) string

RepoURL extracts the project web_url from a raw JSON payload without fully unmarshaling the event. Falls back to http_url if web_url is empty.

Types

type Commit

type Commit struct {
	ID      string `json:"id"`
	Message string `json:"message"`
}

Commit contains commit details from a GitLab push event.

type MergeRequestAttrs

type MergeRequestAttrs struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	State       string `json:"state"`
	MergeCommit string `json:"merge_commit_sha"`
	URL         string `json:"url"`
	Action      string `json:"action"`
}

MergeRequestAttrs contains merge request details from a GitLab webhook event.

type MergeRequestEvent

type MergeRequestEvent struct {
	ObjectAttrs MergeRequestAttrs `json:"object_attributes"`
	Project     Project           `json:"project"`
}

MergeRequestEvent represents a GitLab merge_request webhook payload.

type Project

type Project struct {
	WebURL  string `json:"web_url"`
	HTTPURL string `json:"http_url"`
	Name    string `json:"name"`
	PathNS  string `json:"path_with_namespace"`
}

Project contains project details from a GitLab webhook event.

type Provider

type Provider struct{}

Provider implements webhook.Provider for GitLab webhooks.

func (*Provider) EventType

func (p *Provider) EventType(r *http.Request) string

EventType returns the value of the X-Gitlab-Event header.

func (*Provider) VerifySignature

func (p *Provider) VerifySignature(payload []byte, r *http.Request, secret string) bool

VerifySignature checks the X-Gitlab-Token header against the given secret using plain string comparison (GitLab does not use HMAC).

type PushEvent

type PushEvent struct {
	Ref     string   `json:"ref"`
	Commits []Commit `json:"commits"`
	Project Project  `json:"project"`
}

PushEvent represents a GitLab push webhook payload.

Jump to

Keyboard shortcuts

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