gh

package
v0.0.0-...-b22dccf Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

Package gh implements bot command to create Github workflow dispatch events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTokenClient

func NewTokenClient(token string, mp metric.MeterProvider, tp trace.TracerProvider) *github.Client

NewTokenClient returns new instrumented GitHub client with token and rate limiter.

Types

type Check

type Check struct {
	ID         int64
	Name       string // e.g. "build"
	Conclusion string // failure, success, neutral, cancelled, skipped, timed_out, action_required
	Status     string // completed
}

type ComponentUpdate

type ComponentUpdate struct {
	CreatedAt   time.Time `json:"created_at"`
	NewStatus   string    `json:"new_status"`
	OldStatus   string    `json:"old_status"`
	ID          string    `json:"id"`
	ComponentID string    `json:"component_id"`
}

type Event

type Event struct {
	Type     string
	RepoName string
	RepoID   int64
}

func Transform

func Transform(d *jx.Decoder, e *jx.Encoder) (*Event, error)

type Hook

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

Hook is event handler which saves last message ID of dialog to the storage.

func NewHook

NewHook creates new hook.

func (Hook) OnMessage

func (h Hook) OnMessage(ctx context.Context, e dispatch.MessageEvent) error

OnMessage implements dispatch.MessageHandler.

type PullRequestUpdate

type PullRequestUpdate struct {
	// Possible values: pr_update, check_update
	Event string
	// Possible values for Event == "update": opened, merged
	Action string

	Repo   *github.Repository
	PR     *github.PullRequest
	Checks []Check
}

func (PullRequestUpdate) ActionIn

func (u PullRequestUpdate) ActionIn(actions ...string) bool

type StatusComponent

type StatusComponent struct {
	CreatedAt time.Time `json:"created_at"`
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Status    string    `json:"status"`
}

type StatusMeta

type StatusMeta struct {
	Unsubscribe   string `json:"unsubscribe"`
	Documentation string `json:"documentation"`
}

type StatusPage

type StatusPage struct {
	ID                string `json:"id"`
	StatusIndicator   string `json:"status_indicator"`
	StatusDescription string `json:"status_description"`
}

type StatusWebhook

type StatusWebhook struct {
	Meta            StatusMeta      `json:"meta"`
	Page            StatusPage      `json:"page"`
	ComponentUpdate ComponentUpdate `json:"component_update"`
	Component       StatusComponent `json:"component"`
}

type Webhook

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

Webhook is a Github events web hook handler.

func NewWebhook

func NewWebhook(
	db *ent.Client,
	gh *github.Client,
	ghID int64,
	sender *message.Sender,
	meterProvider metric.MeterProvider,
	tracerProvider trace.TracerProvider,
) *Webhook

NewWebhook creates new web hook handler.

func (*Webhook) Client

func (w *Webhook) Client(ctx context.Context) (*github.Client, error)

Client returns GitHub client for installation.

func (*Webhook) Handle

func (w *Webhook) Handle(ctx context.Context, t string, data []byte) (rerr error)

func (*Webhook) HasSecret

func (w *Webhook) HasSecret() bool

func (*Webhook) RegisterRoutes

func (w *Webhook) RegisterRoutes(e *echo.Echo)

RegisterRoutes registers hook using given Echo router.

func (*Webhook) Run

func (w *Webhook) Run(ctx context.Context) error

Run runs some background tasks of Webhook.

func (*Webhook) WithCache

func (w *Webhook) WithCache(c *redis.Client) *Webhook

func (*Webhook) WithNotifyGroup

func (w *Webhook) WithNotifyGroup(domain string) *Webhook

WithNotifyGroup sets channel name to send notifications.

func (*Webhook) WithSecret

func (w *Webhook) WithSecret(v string) *Webhook

func (*Webhook) WithSender

func (w *Webhook) WithSender(sender *message.Sender) *Webhook

WithSender sets message sender to use.

Jump to

Keyboard shortcuts

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