leif

package module
v0.0.0-...-89f4574 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

README

leif

leif is a service designed to take a set of GitHub repositories to find and track their configuration files for service level objective (SLO) rules, periodically syncing to update the SLO rules, which are exposed over an API.

leif

SLO rules configuration

leif expects the configuration of the SLO rules to be defined in a JSON file named issue_slo_rules.json

leif looks for the config file for the repository in the following places:

  1. In the repository itself: .github/issue_slo_rules.json
  2. If there is no config file in the respository, leif looks for the config file at the owner level: <ownername>/.github/issue_slo_rules.json

Note: an empty config file opts-out of SLO tracking

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrGoGitHub = errors.New("an error came from go github")

ErrGoGitHub is a sentinel error against which to check github.ErrorResponse errors

View Source
var ErrNoContent = errors.New("no content found")

ErrNoContent is a sentinel error representing the github.RepositoryContent is nil

View Source
var ErrNotAFile = errors.New("not a file")

ErrNotAFile is a sentinel error representing that the github.RepositoryContent is not a file

View Source
var ErrRepoAlreadyTracked = errors.New("Already tracked")

ErrRepoAlreadyTracked is a sentinel error which indicates the repository is already tracked by the owner

Functions

func FormatLog

func FormatLog(f logrus.Formatter)

FormatLog sets the log's formatter to the one provided

func NewDiskRepo

func NewDiskRepo(fileName string) repos.RepoList

NewDiskRepo returns a RepoList based on a local file

func VerboseLog

func VerboseLog()

VerboseLog sets the log level to DebugLevel

Types

type AppliesTo

type AppliesTo struct {
	GitHubLabels         []string `json:"gitHubLabels"`
	ExcludedGitHubLabels []string `json:"excludedGitHubLabels"`
	Issues               bool     `json:"issues"`
	PRs                  bool     `json:"prs"`
}

AppliesTo stores structured data on which issues and/or pull requests a SLO applies to

type AppliesToJSON

type AppliesToJSON struct {
	GitHubLabelsRaw         stringOrArray `json:"gitHubLabels"`
	ExcludedGitHubLabelsRaw stringOrArray `json:"excludedGitHubLabels"`
	Issues                  bool          `json:"issues"`
	PRs                     bool          `json:"prs"`
}

AppliesToJSON is the intermediary struct between the JSON representation and the structured leif representation that stores structured data on which issues and/or pull requests a SLO applies to

type ComplianceSettings

type ComplianceSettings struct {
	ResponseTime     time.Duration `json:"responseTime"`
	ResolutionTime   time.Duration `json:"resolutionTime"`
	RequiresAssignee bool          `json:"requiresAssignee"`
	Responders       []string      `json:"responders"`
}

ComplianceSettings stores data on the requirements for an issue or pull request to be considered compliant with the SLO

type ComplianceSettingsJSON

type ComplianceSettingsJSON struct {
	ResponseTime     duration       `json:"responseTime"`
	ResolutionTime   duration       `json:"resolutionTime"`
	RequiresAssignee bool           `json:"requiresAssignee"`
	RespondersJSON   RespondersJSON `json:"responders"`
}

ComplianceSettingsJSON is the intermediary struct between the JSON representation and the structured leif representation that stores data on the requirements for an issue or pull request to be considered compliant with the SLO

type Corpus

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

Corpus holds all of a project's metadata.

func (*Corpus) ForEachOwner

func (c *Corpus) ForEachOwner(fn func(o Owner) error) error

ForEachOwner iterates over the set of owners and performs the given function on each and returns the first non-nil error it receives.

func (*Corpus) ForEachOwnerF

func (c *Corpus) ForEachOwnerF(fn func(o Owner) error, filter func(o Owner) bool) error

ForEachOwnerF iterates over the set of owners that match the given filter and performs the given function on them, and returns the first non-nil error.

func (*Corpus) ForEachOwnerFSort

func (c *Corpus) ForEachOwnerFSort(fn func(o Owner) error, filter func(o Owner) bool, sortfn func(owners []*Owner) func(i, j int) bool) error

ForEachOwnerFSort iterates over the set of owners that match the given filter and performs the given function on them in the order given by the given sort func. Returns the first non-nil error it receives.

func (*Corpus) ForEachRepo

func (c *Corpus) ForEachRepo(fn func(r Repository) error) error

ForEachRepo iterates over the set of repositories and performs the given function on each and returns the first non-nil error it receives.

func (*Corpus) ForEachRepoF

func (c *Corpus) ForEachRepoF(fn func(r Repository) error, filter func(r Repository) bool) error

ForEachRepoF iterates over the set of repositories that match the given filter and performs the given function on them, and returns the first non-nil error it receives.

func (*Corpus) ForEachRepoFSort

func (c *Corpus) ForEachRepoFSort(fn func(r Repository) error, filter func(r Repository) bool, sortfn func([]*Repository) func(i, j int) bool) error

ForEachRepoFSort iterates over the set of repositories that match the given filter and performs the given function on them in the order given by the given sort func. Returns the first non-nil error it receives.

func (*Corpus) Initialize

func (c *Corpus) Initialize(ctx context.Context, ghClient *githubservices.Client) error

Initialize should be the first call to the corpus to do the initial synchronization of the corpus's repos

func (*Corpus) SyncLoop

func (c *Corpus) SyncLoop(ctx context.Context, minutes int, ghClient *githubservices.Client) error

SyncLoop instructs the Corpus to update all the tracked repos every given amount of minutes

func (*Corpus) TrackRepo

func (c *Corpus) TrackRepo(ctx context.Context, ownerName string, repoName string, ghClient *githubservices.Client) error

TrackRepo adds the repository to the corpus to be tracked

type Owner

type Owner struct {
	Repos    []*Repository
	SLORules []*SLORule
	// contains filtered or unexported fields
}

Owner represents a GitHub owner and their tracked repositories Owners can specify default SLO rules that will apply to all tracked repos unless the repository overrides them with its own SLO rules config

func (*Owner) Name

func (o *Owner) Name() string

Name returns the name of the owner

func (*Owner) Update

func (o *Owner) Update(ctx context.Context, ghClient *githubservices.Client) error

Update reaches out to GitHub to update the SLO rules for the owner, then updates the SLO rules for each tracked repository under the owner

func (*Owner) UpdateLoop

func (o *Owner) UpdateLoop(ctx context.Context, minutes int, ghClient *githubservices.Client) error

UpdateLoop updates the owner and their tracked repositories every given amount of minutes

type Repository

type Repository struct {
	SLORules []*SLORule
	// contains filtered or unexported fields
}

Repository represents a GitHub repository and stores its SLO rules

func (*Repository) OwnerName

func (r *Repository) OwnerName() string

OwnerName returns the name of the repository's owner

func (*Repository) RepoName

func (r *Repository) RepoName() string

RepoName returns the repository's name

func (*Repository) Update

func (r *Repository) Update(ctx context.Context, owner Owner, ghClient *githubservices.Client) error

Update reaches out to GitHub to update the SLO rules for the repository

type RespondersJSON

type RespondersJSON struct {
	Owners       stringOrArray `json:"owners"`
	Contributors string        `json:"contributors"`
	Users        []string      `json:"users"`
}

RespondersJSON is the intermediary struct between the JSON representation and the structured leif representation that stores structured data on the responders to the issue or pull request the SLO applies to

func (RespondersJSON) MarshalJSON

func (r RespondersJSON) MarshalJSON() ([]byte, error)

MarshalJSON for responders marshals only the users field into a single array of strings Call prepareForMarshalling before marshalling to get all responders in the marshalled data

type SLORule

type SLORule struct {
	AppliesTo          AppliesTo          `json:"appliesTo"`
	ComplianceSettings ComplianceSettings `json:"complianceSettings"`
}

SLORule represents a service level objective (SLO) rule

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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