contributors

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package contributors reports the git contributors for a repository and the associated entity under test to the Contributors ingest API.

Index

Constants

EntityTypeProject identifies a captured ID as a Snyk project ID.

EntityTypeRevision identifies a captured ID as a Snyk revision ID.

Variables

View Source
var (
	ErrNotAGitRepository = errors.New("not a git repository")
	ErrNoContributors    = errors.New("no contributors in the contributor window")
	ErrCollect           = errors.New("collect contributors")
	ErrSubmit            = errors.New("submit contributors")
)

Outcomes of Emitter.Emit.

Functions

func Report added in v0.21.0

func Report(ctx context.Context, engine workflow.Engine, sink *Sink)

Report emits contributors and records the result.

Types

type Emitter

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

Emitter synchronously collects and reports contributors for a given repository.

func NewEmitter added in v0.21.0

func NewEmitter(httpClient *http.Client, config configuration.Configuration, logger *zerolog.Logger) (*Emitter, error)

NewEmitter returns an Emitter that reports contributors of a repository, sending requests over httpClient to the API configured in config.

func (*Emitter) Emit

func (e *Emitter) Emit(ctx context.Context, repoPath string, orgID uuid.UUID, item Item) (int, error)

Emit reports the repository's current contributors against item, returning how many it collected.

Every outcome other than a successful emission is returned as an error. A canceled context surfaces wrapped in ErrCollect or ErrSubmit.

type EntityType added in v0.19.0

type EntityType = contributors_ingest.EntityType

EntityType identifies the kind of Snyk entity a captured ID refers to.

type Item

type Item struct {
	EntityType contributors_ingest.EntityType
	EntityID   string
}

Item identifies the entity that contributors are attributed to.

type MissReason added in v0.21.0

type MissReason int

MissReason explains why a request the contributor_capture middleware matched did not yield an entity.

const (
	// MissNone means no miss recorded.
	MissNone MissReason = iota

	// MissErrorStatus is a matched request whose response was an HTTP error.
	MissErrorStatus

	// MissBodyTooLarge is a response body too large to parse.
	MissBodyTooLarge

	// MissBodyUnreadable is a request or response body that could not be read.
	MissBodyUnreadable

	// MissNoEntity is a body parsed successfully that held no entity to record.
	MissNoEntity

	// MissPanic is a panic recovered during capture.
	MissPanic
)

type Sink added in v0.21.0

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

func (*Sink) RecordEntity added in v0.21.0

func (s *Sink) RecordEntity(entityType EntityType, entityID string)

RecordEntity records the first entity reported to the sink for later emission.

func (*Sink) RecordMiss added in v0.21.0

func (s *Sink) RecordMiss(reason MissReason)

RecordMiss keeps the first reason for a miss reported for analytics.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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