storage

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: GPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotExist = errors.New("does not exist")

ErrNotExist indicates that a record does not exist

Functions

This section is empty.

Types

type Application

type Application struct {
	ID   int
	Name string
}

Application stores the name of the Application

func (*Application) NameLower

func (a *Application) NameLower() string

NameLower returns the app of the name in lowercase

type ArtifactType added in v0.11.1

type ArtifactType string

ArtifactType describes the type of an artifact

const (
	//DockerArtifact is a docker image artifact
	DockerArtifact ArtifactType = "docker"
	//FileArtifact is a file artifact
	FileArtifact ArtifactType = "file"
)

type Build

type Build struct {
	ID               int
	Application      Application
	VCSState         VCSState
	StartTimeStamp   time.Time
	StopTimeStamp    time.Time
	TotalInputDigest string
	Outputs          []*Output
	Inputs           []*Input
}

Build represents a stored build

type BuildWithDuration added in v0.9.0

type BuildWithDuration struct {
	Build
	Duration time.Duration
}

BuildWithDuration adds duration to a Build

type Field added in v0.9.0

type Field int

Field represents data fields that can be used in sort and filter operations

const (
	FieldUndefined Field = iota
	FieldApplicationName
	FieldBuildDuration
	FieldBuildStartTime
	FieldBuildID
)

Defines the available data fields

func (Field) String added in v0.9.0

func (f Field) String() string

type Filter added in v0.9.0

type Filter struct {
	Field    Field
	Operator Op
	Value    interface{}
}

Filter specifies filter operatons for queries

type Input

type Input struct {
	URI    string
	Digest string
}

Input represents a source of an artifact

type Issue

type Issue string

Issue describes an issue in the build database

const (
	// IssueOutputDigestMissing describes that a build didn't produces an
	// output that other builds with the same input digest produced
	IssueOutputDigestMissing Issue = "output with digest missing"
	// IssueUnmatchedDigest describes that a build produced an output with
	// a different digest then other builds with the same inputs
	IssueUnmatchedDigest Issue = "output with different digest"
)

type Op added in v0.9.0

type Op int

Op describes the filter operator

const (
	// OpEQ represents an equal (=) operator
	OpEQ Op = iota
	// OpGT represents a greater than (>) operator
	OpGT
	// OpLT represents a smaller than (<) operator
	OpLT
	// OpIN represents a In operator, works like the SQL IN operator, the
	// corresponding Value field in The filter struct must be a slice
	OpIN
)

func (Op) String added in v0.9.0

func (o Op) String() string

type Order added in v0.9.0

type Order int

Order specifies the sort order

const (
	// SortInvalid represents an invalid sort value
	SortInvalid Order = iota
	// OrderAsc sorts ascending
	OrderAsc
	// OrderDesc sorts descending
	OrderDesc
)

func OrderFromStr added in v0.9.0

func OrderFromStr(s string) (Order, error)

OrderFromStr converts a string to an Order

func (Order) String added in v0.9.0

func (s Order) String() string

type Output

type Output struct {
	Name      string
	Type      ArtifactType
	Digest    string
	SizeBytes int64
	Upload    Upload
}

Output represents a build output

type Sorter added in v0.9.0

type Sorter struct {
	Field Field
	Order Order
}

Sorter specifies how the result of queries should be sorted

func (*Sorter) String added in v0.9.0

func (s *Sorter) String() string

String return the string representation

type Storer

type Storer interface {
	Init() error
	Save(b *Build) error

	GetApps() ([]*Application, error)

	GetSameTotalInputDigestsForAppBuilds(appName string, startTs time.Time) (map[string][]int, error)
	GetLatestBuildByDigest(appName, totalInputDigest string) (*BuildWithDuration, error)

	GetBuildOutputs(buildID int) ([]*Output, error)
	BuildExist(id int) (bool, error)

	// GetBuildWithoutInputsOutputs returns a single build, if no build with the ID
	// exist ErrNotExist is returned
	GetBuildWithoutInputsOutputs(id int) (*BuildWithDuration, error)
	GetBuildsWithoutInputsOutputs(filters []*Filter, sorters []*Sorter) ([]*BuildWithDuration, error)
}

Storer is an interface for persisting informations about builds

type Upload

type Upload struct {
	ID             int
	UploadDuration time.Duration
	URI            string
	Method         UploadMethod
}

Upload contains informations about an output upload

type UploadMethod added in v0.11.1

type UploadMethod string

UploadMethod describes the used upload mechanism

const (
	S3             UploadMethod = "s3"
	DockerRegistry UploadMethod = "docker"
	FileCopy       UploadMethod = "filecopy"
)

Description of UploadMethod Values

type VCSState

type VCSState struct {
	CommitID string
	IsDirty  bool
}

VCSState contains informations about the VCS at the time of the build

type VerifyIssue

type VerifyIssue struct {
	Build          *BuildWithDuration
	Output         *Output
	ReferenceBuild *BuildWithDuration
	Issue          Issue
}

VerifyIssue describes a found issue during verification

func VerifySameInputDigestSameOutputs

func VerifySameInputDigestSameOutputs(clt Storer, appName string, startTs time.Time) ([]*VerifyIssue, error)

VerifySameInputDigestSameOutputs if the application has multiple builds with the same total input digest, it finds the most common outputs by digest from those builds and checks if the other builds have the outputs with the same digest. For builds that don't match an Issue description is returned

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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