collector

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package collector is used to collect signals for a given repository from a variety of sources.

Index

Constants

View Source
const DefaultGCPDatasetName = "criticality_score_data"

DefaultGCPDatasetName is the default name to use for GCP BigQuery Datasets.

Variables

View Source
var ErrRepoNotFound = fmt.Errorf("%w: not found", ErrUncollectableRepo)

ErrRepoNotFound wraps ErrUncollectableRepo and is used when a repo cannot be found for collection.

View Source
var ErrUncollectableRepo = errors.New("repo failed")

ErrUncollectableRepo is the base error returned when there is a problem with the repo url passed in to be collected.

For example, the URL may point to an invalid repository host, or the URL may point to a repo that is inaccessible or missing.

View Source
var ErrUnsupportedURL = fmt.Errorf("%w: unsupported url", ErrUncollectableRepo)

ErrUnsupportedURL wraps ErrUncollectableRepo and is used when a repo url does not match any of the supported hosts.

Functions

This section is empty.

Types

type Collector

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

func New

func New(ctx context.Context, logger *zap.Logger, opts ...Option) (*Collector, error)

func (*Collector) Collect

func (c *Collector) Collect(ctx context.Context, u *url.URL, jobID string) ([]signal.Set, error)

Collect gathers and returns all the signals for the given project repo url.

An optional jobID can be specified which can be used by underlying sources to manage caching. For simple usage this can be the empty string.

func (*Collector) EmptySets

func (c *Collector) EmptySets() []signal.Set

EmptySet returns all the empty instances of signal Sets that are used for determining the namespace and signals supported by the Source.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is an interface used to change the config.

func DisableAllSources

func DisableAllSources() Option

DisableAllSources will disable all SourceTypes for collection.

No data sources will be used for collection unless explicitly enabled with EnableSource.

func DisableSource

func DisableSource(s SourceType) Option

DisableSource will enable the supplied SourceType for collection.

func EnableAllSources

func EnableAllSources() Option

EnableAllSources enables all SourceTypes for collection.

All data sources will be used for collection unless explicitly disabled with DisableSource.

func EnableSource

func EnableSource(s SourceType) Option

EnableSource will enable the supplied SourceType for collection.

func GCPDatasetName

func GCPDatasetName(n string) Option

GCPDatasetName overrides DefaultGCPDatasetName with the supplied dataset name.

func GCPDatasetTTL

func GCPDatasetTTL(ttl time.Duration) Option

GCPDatasetTTL sets the time-to-live for tables created with GCP BigQuery datasets.

func GCPProject

func GCPProject(n string) Option

GCPProject is used to set the ID of the GCP project used for sources that depend on GCP.

If not supplied, the currently configured project will be used.

type SourceType

type SourceType int

SourceType is used to identify the various sources signals can be collected from.

const (
	SourceTypeGithubRepo SourceType = iota
	SourceTypeGithubIssues
	SourceTypeGitHubMentions
	SourceTypeDepsDev
)

func (SourceType) String

func (t SourceType) String() string

String implements the fmt.Stringer interface.

Directories

Path Synopsis
Package githubmentions provides a Collector that returns a Set for the number of mentions a given repository has in commit messages as returned by GitHub's search interface.
Package githubmentions provides a Collector that returns a Set for the number of mentions a given repository has in commit messages as returned by GitHub's search interface.

Jump to

Keyboard shortcuts

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