db

package
v0.0.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is a not found error

Functions

This section is empty.

Types

type Check

type Check struct {
	Name       string
	Repository string
	Score      int
}

Check is a repository's score for an individual scorecard check

type DB

type DB interface {
	DBReader
	DBWriter

	// Close the database
	Close() error

	// Initialize the database
	Initialize(context.Context) error
}

DB is the tally database

type DBReader

type DBReader interface {
	// GetChecks retrieves check scores for a repository. Returns
	// ErrNotFound if no checks are found.
	GetChecks(context.Context, string) ([]Check, error)

	// GetRepositories returns any repositories associated with the package
	// indicated by system and name. Returns ErrNotFound if there are no matching
	// repositories.
	GetRepositories(context.Context, string, string) ([]string, error)

	// GetScore retrieves scorecard scores for a list of repositories
	GetScores(context.Context, ...string) ([]Score, error)
}

DBReader reads from the database

type DBWriter

type DBWriter interface {
	// AddChecks adds scorecard check scores to the database. If there's
	// already a check in the database for the repository in question then
	// the existing check will be updated.
	AddChecks(context.Context, ...Check) error

	// AddPackages adds packages to the database. The same package+system
	// combination can have multiple repositories associated with it.
	AddPackages(context.Context, ...Package) error

	// AddScores adds scorecard scores to the database. If there's already
	// a score in the database for the repository in question, then the
	// existing score will be updated.
	AddScores(context.Context, ...Score) error
}

DBWriter writes to the database

type Package

type Package struct {
	System     string
	Name       string
	Repository string
}

Package is a package associated with a repository

type Score

type Score struct {
	Repository string
	Score      float64
}

Score is the aggregated scorecard score for a repository

type Source

type Source interface {
	// String returns a string that identifies the source
	String() string

	// Update the database with items from the source
	Update(context.Context, DBWriter) error
}

Source populates the database with data

Directories

Path Synopsis
bigquery

Jump to

Keyboard shortcuts

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