github

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 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

func IsValidPayload

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

func Validate

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

Types

type Base

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

type Client

type Client struct {
}

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(integrationConfig *cicdv1.IntegrationConfig, id int, client client.Client) error

func (*Client) ListWebhook

func (c *Client) ListWebhook(integrationConfig *cicdv1.IntegrationConfig, client client.Client) ([]git.WebhookEntry, error)

func (*Client) ParseWebhook

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

func (*Client) RegisterWebhook

func (c *Client) RegisterWebhook(integrationConfig *cicdv1.IntegrationConfig, url string, client client.Client) error

func (*Client) SetCommitStatus

func (c *Client) SetCommitStatus(integrationJob *cicdv1.IntegrationJob, integrationConfig *cicdv1.IntegrationConfig, context string, state git.CommitStatusState, description, targetUrl string, client client.Client) error

type CommitStatusBody

type CommitStatusBody struct {
	State       string `json:"state"`
	TargetURL   string `json:"target_url"`
	Description string `json:"description"`
	Context     string `json:"context"`
}
type Head struct {
	Ref string `json:"ref"`
	Sha string `json:"sha"`
}

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"`
}

Webhook is a github-specific webhook body Should contain json tag for each field, to be unmarshalled properly

type PushWebhook

type PushWebhook struct {
	Ref    string `json:"ref"`
	Repo   Repo   `json:"repository"`
	Pusher struct {
		Name string `json:"name"`
	} `json:"pusher"`
	Sha string `json:"after"`
}

Structure for push webhook event

type RegistrationWebhookBody

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

type RegistrationWebhookBodyConfig

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

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 {
	ID string `json:"login"`
}

type WebhookEntry

type WebhookEntry struct {
	Id     int `json:"id"`
	Config struct {
		Url string `json:"url"`
	} `json:"config"`
}

Jump to

Keyboard shortcuts

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