Help us shape the future of Go! Take the 2026 Go Developer Survey

github

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashPayload

func HashPayload(secret string, payloadBody []byte) string

HashPayload hashes the payload

func IsValidPayload

func IsValidPayload(secret, headerHash string, payload []byte) bool

IsValidPayload validates the webhook payload

func Validate

func Validate(secret, headerHash string, payload []byte) error

Validate validates the webhook payload

Types

type Base

type Base struct {
	Ref string `json:"ref"`
}

Base is a reference of the base branch

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(userName 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 github

func (*Client) RegisterWebhook

func (c *Client) RegisterWebhook(url 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 Head struct {
	Ref string `json:"ref"`
	Sha string `json:"sha"`
}

Head is a reference of the head branch

type PullRequestWebhook

type PullRequestWebhook struct {
	Action string `json:"action"`
	Number int    `json:"number"`
	Sender Sender `json:"sender"`

	PullRequest struct {
		Title string `json:"title"`
		ID    int    `json:"id"`
		State string `json:"state"`
		Head  Head   `json:"head"`
		Base  Base   `json:"base"`
	} `json:"pull_request"`

	Repo Repo `json:"repository"`
}

PullRequestWebhook is a github-specific pull-request event webhook body

type PushWebhook

type PushWebhook struct {
	Ref    string `json:"ref"`
	Repo   Repo   `json:"repository"`
	Sender Sender `json:"sender"`
	Sha    string `json:"after"`
}

PushWebhook is a github-specific push event webhook body

type RegistrationWebhookBody

type RegistrationWebhookBody struct {
	Name   string                        `json:"name"`
	Active bool                          `json:"active"`
	Events []string                      `json:"events"`
	Config RegistrationWebhookBodyConfig `json:"config"`
}

RegistrationWebhookBody is a request body for registering webhook to remote git server

type RegistrationWebhookBodyConfig

type RegistrationWebhookBodyConfig struct {
	URL         string `json:"url"`
	ContentType string `json:"content_type"`
	InsecureSsl string `json:"insecure_ssl"`
	Secret      string `json:"secret"`
}

RegistrationWebhookBodyConfig is a config for the webhook

type Repo

type Repo struct {
	Name    string `json:"full_name"`
	HTMLURL string `json:"html_url"`
	Owner   struct {
		ID string `json:"login"`
	} `json:"owner"`
	Private bool `json:"private"`
}

Repo structure for webhook event

type Sender

type Sender struct {
	Name string `json:"login"`
	ID   int    `json:"id"`
}

Sender is a sender of the event

type UserInfo added in v0.1.4

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

UserInfo is a body of user get API

type WebhookEntry

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

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