client

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GitHubWebhookEvents = map[string][]string{
	"branch_protection_configuration": {"disabled", "enabled"},
	"branch_protection_rule":          {"created", "deleted", "edited"},
	"check_run":                       {"completed", "created", "requested_action", "rerequested"},
	"check_suite":                     {"completed", "requested", "rerequested"},
	"code_scanning_alert":             {"appeared_in_branch", "closed_by_user", "created", "fixed", "reopened", "reopened_by_user"},
	"commit_comment":                  {"created"},
	"create":                          {},
	"custom_property":                 {"created", "deleted", "updated"},
	"custom_property_values":          {"updated"},
	"delete":                          {},
	"dependabot_alert":                {"auto_dismissed", "auto_reopened", "created", "dismissed", "fixed", "reintroduced", "reopened"},
	"deploy_key":                      {"created", "deleted"},
	"deployment":                      {"created"},
	"deployment_protection_rule":      {"requested"},
	"deployment_review":               {"approved", "rejected", "requested"},
	"deployment_status":               {"created"},
	"discussion":                      {"answered", "category_changed", "created", "deleted", "edited", "labeled", "locked", "pinned", "transferred", "unanswered", "unlabeled", "unlocked", "unpinned"},
	"discussion_comment":              {"created", "deleted", "edited"},
	"fork":                            {},
	"github_app_authorization":        {"revoked"},
	"gollum":                          {},
	"installation":                    {"created", "deleted", "new_permissions_accepted", "suspend", "unsuspend"},
	"installation_repositories":       {"added", "removed"},
	"installation_target":             {"renamed"},
	"issue_comment":                   {"created", "deleted", "edited"},
	"issues":                          {"assigned", "closed", "deleted", "demilestoned", "edited", "labeled", "locked", "milestoned", "opened", "pinned", "reopened", "transferred", "unassigned", "unlabeled", "unlocked", "unpinned"},
	"label":                           {"created", "deleted", "edited"},
	"marketplace_purchase":            {"cancelled", "changed", "pending_change", "pending_change_cancelled", "purchased"},
	"member":                          {"added", "edited", "removed"},
	"membership":                      {"added", "removed"},
	"merge_group":                     {"checks_requested", "destroyed"},
	"meta":                            {"deleted"},
	"milestone":                       {"closed", "created", "deleted", "edited", "opened"},
	"org_block":                       {"blocked", "unblocked"},
	"organization":                    {"deleted", "member_added", "member_invited", "member_removed", "renamed"},
	"package":                         {"published", "updated"},
	"page_build":                      {},
	"personal_access_token_request":   {"approved", "cancelled", "created", "denied"},
	"ping":                            {},
	"project":                         {"closed", "created", "deleted", "edited", "reopened"},
	"project_card":                    {"converted", "created", "deleted", "edited", "moved"},
	"project_column":                  {"created", "deleted", "edited", "moved"},
	"projects_v2":                     {"closed", "created", "deleted", "edited", "reopened"},
	"projects_v2_item":                {"archived", "converted", "created", "deleted", "edited", "reordered", "restored"},
	"projects_v2_status_update":       {"created", "deleted", "edited"},
	"public":                          {},
	"pull_request":                    {"assigned", "auto_merge_disabled", "auto_merge_enabled", "closed", "converted_to_draft", "demilestoned", "dequeued", "edited", "enqueued", "labeled", "locked", "milestoned", "opened", "ready_for_review", "reopened", "review_request_removed", "review_requested", "synchronize", "unassigned", "unlabeled", "unlocked"},
	"pull_request_review":             {"dismissed", "edited", "submitted"},
	"pull_request_review_comment":     {"created", "deleted", "edited"},
	"pull_request_review_thread":      {"resolved", "unresolved"},
	"push":                            {},
	"registry_package":                {"published", "updated"},
	"release":                         {"created", "deleted", "edited", "prereleased", "published", "released", "unpublished"},
	"repository":                      {"archived", "created", "deleted", "edited", "privatized", "publicized", "renamed", "transferred", "unarchived"},
	"repository_advisory":             {"published", "reported"},
	"repository_dispatch":             {},
	"repository_import":               {},
	"repository_ruleset":              {"created", "deleted", "edited"},
	"repository_vulnerability_alert":  {"create", "dismiss", "resolve"},
	"secret_scanning_alert":           {"created", "resolved", "reopened", "validated"},
	"secret_scanning_alert_location":  {"created"},
	"security_advisory":               {"performed", "published", "updated", "withdrawn"},
	"security_and_analysis":           {},
	"sponsorship":                     {"cancelled", "created", "edited", "pending_cancellation", "pending_tier_change", "tier_changed"},
	"star":                            {"created", "deleted"},
	"status":                          {},
	"sub_issues":                      {"parent_issue_added", "parent_issue_removed", "sub_issue_added", "sub_issue_removed"},
	"team":                            {"added_to_repository", "created", "deleted", "edited", "removed_from_repository"},
	"team_add":                        {},
	"watch":                           {"started"},
	"workflow_dispatch":               {},
	"workflow_job":                    {"completed", "in_progress", "queued", "waiting"},
	"workflow_run":                    {"completed", "in_progress", "requested"},
}

GitHubWebhookEvents maps each GitHub webhook event type to its known action values. Events with an empty slice have no action field. This reference is provided for users configuring global-ignore-pre / global-ignore-post and global-allowed-pre / global-allowed-post patterns; it is NOT used for runtime validation since GitHub may add new events or actions at any time.

Source: https://docs.github.com/en/webhooks/webhook-events-and-payloads

View Source
var Version = "dev"

Version is set at build time via -ldflags "-X main.version=...". It is copied from the main package at startup.

Functions

func Checkout

func Checkout(repoPath string, event protocol.EventMsg) error

Checkout switches to the correct ref based on the event.

func EnsureRepo

func EnsureRepo(reposDir, repoName, cloneURL string) (string, error)

EnsureRepo clones the repo if it doesn't exist, or fetches if it does.

func Run

func Run(ctx context.Context, cfg Config)

Run connects to the relay and processes events. Reconnects on failure.

func RunHook

func RunHook(ctx context.Context, repoPath, hook, hookLabel string, event protocol.EventMsg) error

RunHook executes a hook command in the repo directory.

func RunHookWithOutput

func RunHookWithOutput(ctx context.Context, repoPath, hook, hookLabel string, event protocol.EventMsg) (string, error)

RunHookWithOutput executes a hook and returns its combined output.

func ShouldNotify added in v0.5.0

func ShouldNotify(notifyOn []string, state string) bool

ShouldNotify checks whether a notification should fire based on the notify_on filter and the current state. An empty filter means always notify.

func StartAutoUpdater added in v0.2.0

func StartAutoUpdater(ctx context.Context)

StartAutoUpdater runs a background loop that checks for new releases every 5 minutes. When a newer version is found it replaces the running binary and exits so systemd (or the parent supervisor) can restart the service.

func StartRepoChecker added in v0.3.0

func StartRepoChecker(ctx context.Context, cfg Config)

StartRepoChecker runs a background loop that periodically walks the repos directory and verifies every cloned repository is healthy. Repos that are missing a .git directory or fail a basic git sanity check are re-cloned on the default branch. Repos already checked out on a branch are left as-is.

Repos are checked one at a time to avoid overwhelming the system.

Types

type ApprovalData added in v0.5.0

type ApprovalData struct {
	Repos   map[string]bool `json:"repos"`
	Senders map[string]bool `json:"senders"`
}

type ApprovalStore added in v0.5.0

type ApprovalStore struct {
	Data ApprovalData
	// contains filtered or unexported fields
}

ApprovalStore manages persistent approval of repositories and senders.

func NewApprovalStore added in v0.5.0

func NewApprovalStore(path string) *ApprovalStore

func (*ApprovalStore) ApproveRepo added in v0.5.0

func (s *ApprovalStore) ApproveRepo(repo string) error

func (*ApprovalStore) ApproveSender added in v0.5.0

func (s *ApprovalStore) ApproveSender(sender string) error

func (*ApprovalStore) IsApproved added in v0.5.0

func (s *ApprovalStore) IsApproved(repo, sender string) bool

func (*ApprovalStore) List added in v0.5.0

func (s *ApprovalStore) List() string

func (*ApprovalStore) RevokeRepo added in v0.5.0

func (s *ApprovalStore) RevokeRepo(repo string) error

func (*ApprovalStore) RevokeSender added in v0.5.0

func (s *ApprovalStore) RevokeSender(sender string) error

type Config

type Config struct {
	Relay       string   `yaml:"relay"`
	Token       string   `yaml:"token"`
	ClientID    string   `yaml:"client_id"`
	ReposDir    string   `yaml:"repos_dir"`
	Subscribe   []string `yaml:"subscribe"`
	AutoUpdate  bool     `yaml:"auto-update"`
	AutoCheck   *bool    `yaml:"auto-check"`
	MaxWorkers  int      `yaml:"max-workers"`
	LogLevel    string   `yaml:"log-level"`
	GlobalHooks struct {
		Pre      string   `yaml:"pre"`
		Post     string   `yaml:"post"`
		Notify   string   `yaml:"notify"`
		NotifyOn []string `yaml:"notify_on"`
	} `yaml:"global-hooks"`
	GlobalIgnorePre   []string        `yaml:"global-ignore-pre"`
	GlobalIgnorePost  []string        `yaml:"global-ignore-post"`
	GlobalAllowedPre  []string        `yaml:"global-allowed-pre"`
	GlobalAllowedPost []string        `yaml:"global-allowed-post"`
	Notifier          notifier.Config `yaml:"notifier"`
	RequireApproval   bool            `yaml:"require_approval"`
	ApprovalsPath     string          `yaml:"approvals_path"`
}

type EventHooks

type EventHooks struct {
	Pre      string   `yaml:"pre"`
	Post     string   `yaml:"post"`
	Notify   string   `yaml:"notify"`
	NotifyOn []string `yaml:"notify_on"` // e.g. ["failure"], ["success", "failure"]
}

EventHooks defines pre/post/notify hooks for a specific event or event.action.

type EventicConfig

type EventicConfig struct {
	Hooks struct {
		Pre      string   `yaml:"pre"`
		Post     string   `yaml:"post"`
		Notify   string   `yaml:"notify"`
		NotifyOn []string `yaml:"notify_on"`
	} `yaml:"hooks"`
	Events map[string]EventHooks `yaml:"events"`
}

EventicConfig is the in-repo .eventic.yaml format.

type HookSet

type HookSet struct {
	Pre           string   // global pre hook — runs for every event
	Post          string   // global post hook — runs for every event
	Notify        string   // global notify template
	NotifyOn      []string // global notify filter (e.g. ["failure"])
	EventPre      string   // event-specific pre hook
	EventPost     string   // event-specific post hook
	EventNotify   string   // event-specific notify template
	EventNotifyOn []string // event-specific notify filter
}

HookSet holds all hooks resolved for a single event.

func DiscoverHooks

func DiscoverHooks(repoPath string, event protocol.EventMsg, globalPre, globalPost, globalNotify string, globalNotifyOn []string) HookSet

DiscoverHooks checks the repo for .eventic.yaml or .deploy/deploy.yml and resolves global + event-specific hooks for the given event.

type RepoLocks added in v0.3.0

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

RepoLocks provides per-repository mutual exclusion so that concurrent events targeting the same repo are serialized (queued), while events for different repos run in parallel.

func NewRepoLocks added in v0.3.0

func NewRepoLocks() *RepoLocks

func (*RepoLocks) Lock added in v0.3.0

func (r *RepoLocks) Lock(repo string)

Lock acquires the mutex for the given repository. If another goroutine holds the lock for the same repo, the caller blocks until it is released.

func (*RepoLocks) Unlock added in v0.3.0

func (r *RepoLocks) Unlock(repo string)

Unlock releases the mutex for the given repository.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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