webui

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

README

Lighthouse Web UI

This is a Web UI for Lighthouse, to visualize:

  • Webhook events (push, comments, ...) and the related jobs triggered by each event
  • Lighthouse Jobs
  • Lighthouse Merge Status from Keeper
  • Lighthouse Merge History from Keeper

The goal is to make it easy to see what is happening inside Lighthouse.

Screenshots

events

jobs

merge-status

merge-history

How It Works

It is a Lighthouse External Plugin, and as such, it receives all the webhook events. It stores them in a Bleve index - which can be persisted on disk in a PVC (when deployed in Kubernetes).

It also uses the "informer" Kubernetes pattern to keep a local cache of the Lighthouse Jobs, and index them in an in-memory Bleve index.

And it periodically sync the Lighthouse Keeper state, by polling the "merge pool" JSON and "merge history" JSON from the Keeper service.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockerIssue

type BlockerIssue struct {
	Number int
	Title  string
	URL    string
}

type Event

type Event struct {
	GUID       string
	Owner      string
	Repository string
	Branch     string
	Kind       string
	Action     string
	Details    string
	URL        string
	Sender     string
	Time       time.Time
}

func (Event) PullRequestNumber

func (e Event) PullRequestNumber() string

type EventHandler

type EventHandler struct {
	Store  *Store
	Logger *logrus.Logger
}

func (*EventHandler) HandleWebhook

func (h *EventHandler) HandleWebhook(webhook scm.Webhook) error

type Events

type Events struct {
	Events []Event
	Counts struct {
		Kinds        map[string]int
		Repositories map[string]int
		Senders      map[string]int
	}
}

type EventsQuery

type EventsQuery struct {
	GUID       string
	Owner      string
	Repository string
	Branch     string
	Query      string
}

func (EventsQuery) ToBleveQuery

func (q EventsQuery) ToBleveQuery() query.Query

type Job

type Job struct {
	Name        string
	Type        string
	EventGUID   string
	Owner       string
	Repository  string
	Branch      string
	Build       string
	Context     string
	Author      string
	State       string
	Description string
	ReportURL   string
	TraceID     string
	Start       time.Time
	End         time.Time
	Duration    time.Duration
}

func JobFromLighthouseJob

func JobFromLighthouseJob(lhjob *lhv1alpha1.LighthouseJob) Job

func (Job) PullRequestNumber

func (j Job) PullRequestNumber() string

type JobInformer

type JobInformer struct {
	LHClient       *lhclientset.Clientset
	Namespace      string
	ResyncInterval time.Duration
	Store          *Store
	Logger         *logrus.Logger
}

func (*JobInformer) OnAdd

func (i *JobInformer) OnAdd(obj interface{}, _ bool)

func (*JobInformer) OnDelete

func (i *JobInformer) OnDelete(obj interface{})

func (*JobInformer) OnUpdate

func (i *JobInformer) OnUpdate(oldObj, newObj interface{})

func (*JobInformer) Start

func (i *JobInformer) Start(ctx context.Context)

type Jobs

type Jobs struct {
	Jobs   []Job
	Counts struct {
		States       map[string]int
		Types        map[string]int
		Repositories map[string]int
		Authors      map[string]int
	}
}

type JobsQuery

type JobsQuery struct {
	EventGUID  string
	Owner      string
	Repository string
	Branch     string
	Query      string
}

func (JobsQuery) ToBleveQuery

func (q JobsQuery) ToBleveQuery() query.Query

type KeeperSyncer

type KeeperSyncer struct {
	KeeperEndpoint string
	SyncInterval   time.Duration
	Store          *Store
	Logger         *logrus.Logger
	// contains filtered or unexported fields
}

func (*KeeperSyncer) Start

func (s *KeeperSyncer) Start(ctx context.Context)

func (*KeeperSyncer) Sync

func (s *KeeperSyncer) Sync() error

type MergeHistoryQuery

type MergeHistoryQuery struct {
	Owner      string
	Repository string
	Branch     string
}

type MergePool

type MergePool struct {
	Owner      string
	Repository string
	Branch     string

	// PRs with passing tests, pending tests, and missing or failed tests.
	// Note that these results are rolled up. If all tests for a PR are passing
	// except for one pending, it will be in PendingPRs.
	SuccessPRs []PullRequest
	PendingPRs []PullRequest
	MissingPRs []PullRequest

	// Empty if there is no pending batch.
	BatchPending []PullRequest

	// this is the most recent UpdatedAt field from the different PRs
	UpdatedAt time.Time

	Action   string
	Target   []PullRequest
	Blockers []BlockerIssue
	Error    string

	// this is the original keeper object
	KeeperPool interface{}
}

from lighthouse/pkg/keeper.Pool

func MergePoolFromLighthousePool

func MergePoolFromLighthousePool(lhPool *gabs.Container) MergePool

func MergePoolsFromLighthousePools

func MergePoolsFromLighthousePools(lhPools *gabs.Container) []MergePool

type MergeRecord

type MergeRecord struct {
	Owner      string
	Repository string
	Branch     string

	Time    time.Time
	Action  string
	BaseSHA string

	PRs []PullRequest

	// this is the original keeper object
	KeeperRecord interface{}
}

from lighthouse/pkg/keeper/history.Record

func MergeRecordFromLighthouseRecord

func MergeRecordFromLighthouseRecord(lhRecord *gabs.Container) MergeRecord

func MergeRecordsFromLighthouseRecords

func MergeRecordsFromLighthouseRecords(lhRecords *gabs.Container) []MergeRecord

type MergeStatusQuery

type MergeStatusQuery struct {
	Owner      string
	Repository string
	Branch     string
}

type PullRequest

type PullRequest struct {
	Number    int
	Author    string
	Mergeable string
	Title     string
	UpdatedAt time.Time
}

func PullRequestFromLighthousePullRequest

func PullRequestFromLighthousePullRequest(lhPR *gabs.Container) PullRequest

type Store

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

func NewStore

func NewStore(cfg StoreConfig, logger *logrus.Logger) (*Store, error)

func (*Store) AddEvent

func (s *Store) AddEvent(e Event) error

func (*Store) AddJob

func (s *Store) AddJob(j Job) error

func (*Store) Close added in v0.1.0

func (s *Store) Close() error

func (*Store) CollectGarbage added in v0.1.0

func (s *Store) CollectGarbage() error

func (*Store) DeleteJob

func (s *Store) DeleteJob(name string) error

func (*Store) QueryEvents

func (s *Store) QueryEvents(q EventsQuery) (*Events, error)

func (*Store) QueryJobs

func (s *Store) QueryJobs(q JobsQuery) (*Jobs, error)

func (*Store) QueryMergeHistory

func (s *Store) QueryMergeHistory(q MergeHistoryQuery) []MergeRecord

func (*Store) QueryMergeStatus

func (s *Store) QueryMergeStatus(q MergeStatusQuery) []MergePool

func (*Store) SetMergeHistory

func (s *Store) SetMergeHistory(records []MergeRecord)

func (*Store) SetMergeStatus

func (s *Store) SetMergeStatus(pools []MergePool)

type StoreConfig added in v0.1.0

type StoreConfig struct {
	DataPath     string
	MaxEvents    int
	EventsMaxAge time.Duration
}

Directories

Path Synopsis
cmd
internal
web

Jump to

Keyboard shortcuts

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