db

package
v4.2.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoVerionsSatisfiedPassedConstraints string = "no versions satisfy passed constraints"
	NoVersionsAvailable                 string = "no versions available"
	PinnedVersionUnavailable            string = "pinned version %s is not available"
)
View Source
const (
	WorkerStateRunning  = WorkerState("running")
	WorkerStateStalled  = WorkerState("stalled")
	WorkerStateLanding  = WorkerState("landing")
	WorkerStateLanded   = WorkerState("landed")
	WorkerStateRetiring = WorkerState("retiring")
)

Variables

View Source
var (
	ErrVolumeCannotBeDestroyedWithChildrenPresent = errors.New("volume cannot be destroyed as children are present")
	ErrVolumeStateTransitionFailed                = errors.New("could not transition volume state")
	ErrVolumeMissing                              = errors.New("volume no longer in db")
	ErrInvalidResourceCache                       = errors.New("invalid resource cache")
)
View Source
var (
	ErrWorkerNotPresent         = errors.New("worker-not-present-in-db")
	ErrCannotPruneRunningWorker = errors.New("worker-not-stalled-for-pruning")
)
View Source
var ErrBuildDisappeared = errors.New("build-disappeared-from-db")
View Source
var ErrBuildEventStreamClosed = errors.New("build event stream closed")
View Source
var ErrConfigComparisonFailed = errors.New("comparison with existing config failed during save")
View Source
var ErrContainerDisappeared = errors.New("container disappeared from db")
View Source
var ErrEncryptedWithUnknownKey = errors.New("row encrypted with neither old nor new key")
View Source
var ErrEndOfBuildEventStream = errors.New("end of build event stream")
View Source
var ErrResourceCacheAlreadyExists = errors.New("resource-cache-already-exists")
View Source
var ErrResourceCacheDisappeared = errors.New("resource-cache-disappeared")
View Source
var ErrResourceConfigAlreadyExists = errors.New("resource config already exists")
View Source
var ErrResourceConfigDisappeared = errors.New("resource config disappeared")
View Source
var ErrResourceConfigParentDisappeared = errors.New("resource config parent disappeared")
View Source
var ErrWorkerBaseResourceTypeDisappeared = errors.New("worker base resource type disappeared")
View Source
var ErrWorkerResourceTypeNotFound = errors.New("worker resource type no longer exists (stale?)")
View Source
var GlobalConnectionTracker = NewConnectionTracker()

Functions

func Close

func Close(c io.Closer)

Close ignores errors, and should used with defer. makes errcheck happy that those errs are captured

func Rollback

func Rollback(tx Tx)

Rollback ignores errors, and should be used with defer. makes errcheck happy that those errs are captured

func SetupConnectionRetryingDriver

func SetupConnectionRetryingDriver(delegateDriverName, sqlDataSource, newDriverName string)

Types

type BaseResourceType

type BaseResourceType struct {
	Name string // The name of the type, e.g. 'git'.
}

BaseResourceType represents a resource type provided by workers.

It is created via worker registration. All creates are upserts.

It is removed by gc.BaseResourceTypeCollector, once there are no references to it from worker_base_resource_types.

func (BaseResourceType) Find

func (brt BaseResourceType) Find(runner sq.Runner) (*UsedBaseResourceType, bool, error)

func (BaseResourceType) FindOrCreate

func (brt BaseResourceType) FindOrCreate(tx Tx) (*UsedBaseResourceType, error)

FindOrCreate looks for an existing BaseResourceType and creates it if it doesn't exist. It returns a UsedBaseResourceType.

type Build

type Build interface {
	ID() int
	Name() string
	JobID() int
	JobName() string
	PipelineID() int
	PipelineName() string
	TeamID() int
	TeamName() string
	Engine() string
	EngineMetadata() string
	PublicPlan() *json.RawMessage
	Status() BuildStatus
	StartTime() time.Time
	EndTime() time.Time
	ReapTime() time.Time
	Tracker() string
	IsManuallyTriggered() bool
	IsScheduled() bool
	IsRunning() bool

	Reload() (bool, error)

	AcquireTrackingLock(logger lager.Logger, interval time.Duration) (lock.Lock, bool, error)
	TrackedBy(peerURL string) error

	Interceptible() (bool, error)
	Preparation() (BuildPreparation, bool, error)

	Start(string, string, atc.Plan) (bool, error)
	FinishWithError(cause error) error
	Finish(BuildStatus) error

	SetInterceptible(bool) error

	Events(uint) (EventSource, error)
	SaveEvent(event atc.Event) error

	SaveInput(input BuildInput) error
	SaveOutput(vr VersionedResource) error
	UseInputs(inputs []BuildInput) error

	Resources() ([]BuildInput, []BuildOutput, error)
	GetVersionedResources() (SavedVersionedResources, error)
	SaveImageResourceVersion(UsedResourceCache) error

	Pipeline() (Pipeline, bool, error)

	Delete() (bool, error)
	MarkAsAborted() error
	AbortNotifier() (Notifier, error)
	Schedule() (bool, error)

	IsDrained() bool
	SetDrained(bool) error
}

type BuildFactory

type BuildFactory interface {
	Build(int) (Build, bool, error)
	VisibleBuilds([]string, Page) ([]Build, Pagination, error)
	PublicBuilds(Page) ([]Build, Pagination, error)
	GetAllStartedBuilds() ([]Build, error)
	GetDrainableBuilds() ([]Build, error)
	// TODO: move to BuildLifecycle, new interface (see WorkerLifecycle)
	MarkNonInterceptibleBuilds() error
}

func NewBuildFactory

func NewBuildFactory(conn Conn, lockFactory lock.LockFactory, oneOffGracePeriod time.Duration) BuildFactory

type BuildInput

type BuildInput struct {
	Name string

	VersionedResource

	FirstOccurrence bool
}

type BuildOutput

type BuildOutput struct {
	VersionedResource
}

type BuildPreparation

type BuildPreparation struct {
	BuildID             int
	PausedPipeline      BuildPreparationStatus
	PausedJob           BuildPreparationStatus
	MaxRunningBuilds    BuildPreparationStatus
	Inputs              map[string]BuildPreparationStatus
	InputsSatisfied     BuildPreparationStatus
	MissingInputReasons MissingInputReasons
}

type BuildPreparationStatus

type BuildPreparationStatus string
const (
	BuildPreparationStatusUnknown     BuildPreparationStatus = "unknown"
	BuildPreparationStatusBlocking    BuildPreparationStatus = "blocking"
	BuildPreparationStatusNotBlocking BuildPreparationStatus = "not_blocking"
)

type BuildStatus

type BuildStatus string
const (
	BuildStatusPending   BuildStatus = "pending"
	BuildStatusStarted   BuildStatus = "started"
	BuildStatusAborted   BuildStatus = "aborted"
	BuildStatusSucceeded BuildStatus = "succeeded"
	BuildStatusFailed    BuildStatus = "failed"
	BuildStatusErrored   BuildStatus = "errored"
)

type Cause

type Cause struct {
	VersionedResourceID int `json:"versioned_resource_id"`
	BuildID             int `json:"build_id"`
}

type ConfigVersion

type ConfigVersion int

ConfigVersion is a sequence identifier used for compare-and-swap

type Conn

type Conn interface {
	Bus() NotificationsBus
	EncryptionStrategy() encryption.Strategy

	Ping() error
	Driver() driver.Driver

	Begin() (Tx, error)
	Exec(query string, args ...interface{}) (sql.Result, error)
	Prepare(query string) (*sql.Stmt, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) squirrel.RowScanner

	SetMaxIdleConns(n int)
	SetMaxOpenConns(n int)
	Stats() sql.DBStats

	Close() error
	Name() string
}

func Log

func Log(logger lager.Logger, conn Conn) Conn

func Open

func Open(logger lager.Logger, sqlDriver string, sqlDataSource string, newKey *encryption.Key, oldKey *encryption.Key, connectionName string, lockFactory lock.LockFactory) (Conn, error)

type ConnectionSession

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

func (*ConnectionSession) Release

func (session *ConnectionSession) Release()

type ConnectionTracker

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

func NewConnectionTracker

func NewConnectionTracker() *ConnectionTracker

func (*ConnectionTracker) Current

func (tracker *ConnectionTracker) Current() []string

func (*ConnectionTracker) Track

func (tracker *ConnectionTracker) Track() *ConnectionSession

type Container

type Container interface {
	ID() int
	State() string
	Handle() string
	WorkerName() string
	Metadata() ContainerMetadata
}

type ContainerMetadata

type ContainerMetadata struct {
	Type ContainerType

	StepName string
	Attempt  string

	WorkingDirectory string
	User             string

	PipelineID int
	JobID      int
	BuildID    int

	PipelineName string
	JobName      string
	BuildName    string
}

func (ContainerMetadata) SQLMap

func (metadata ContainerMetadata) SQLMap() map[string]interface{}

func (*ContainerMetadata) ScanTargets

func (metadata *ContainerMetadata) ScanTargets() []interface{}

type ContainerOwner

type ContainerOwner interface {
	Find(conn Conn) (sq.Eq, bool, error)
	Create(tx Tx, workerName string) (map[string]interface{}, error)
}

ContainerOwner designates the data the container should reference that identifies its lifecycle. When the owner goes away, the container should be garbage collected.

func NewBuildStepContainerOwner

func NewBuildStepContainerOwner(
	buildID int,
	planID atc.PlanID,
) ContainerOwner

NewBuildStepContainerOwner references a step within a build. When the build becomes non-interceptible or disappears, the container can be removed.

func NewImageCheckContainerOwner

func NewImageCheckContainerOwner(
	container CreatingContainer,
) ContainerOwner

NewImageCheckContainerOwner references a container whose image resource this container is checking. When the referenced container transitions to another state, or disappears, the container can be removed.

func NewImageGetContainerOwner

func NewImageGetContainerOwner(
	container CreatingContainer,
) ContainerOwner

NewImageGetContainerOwner references a container whose image resource this container is fetching. When the referenced container transitions to another state, or disappears, the container can be removed.

func NewResourceConfigCheckSessionContainerOwner

func NewResourceConfigCheckSessionContainerOwner(
	resourceConfigCheckSession ResourceConfigCheckSession,
	teamID int,
) ContainerOwner

NewResourceConfigCheckSessionContainerOwner references a resource config and worker base resource type, with an expiry. When the resource config or worker base resource type disappear, or the expiry is reached, the container can be removed.

type ContainerOwnerExpiries

type ContainerOwnerExpiries struct {
	GraceTime time.Duration
	Min       time.Duration
	Max       time.Duration
}

type ContainerRepository

type ContainerRepository interface {
	FindOrphanedContainers() ([]CreatingContainer, []CreatedContainer, []DestroyingContainer, error)
	DestroyFailedContainers() (int, error)
	FindDestroyingContainers(workerName string) ([]string, error)
	RemoveDestroyingContainers(workerName string, currentHandles []string) (int, error)
}

func NewContainerRepository

func NewContainerRepository(conn Conn) ContainerRepository

type ContainerState

type ContainerState string

type ContainerType

type ContainerType string
const (
	ContainerTypeCheck ContainerType = "check"
	ContainerTypeGet   ContainerType = "get"
	ContainerTypePut   ContainerType = "put"
	ContainerTypeTask  ContainerType = "task"
)

func ContainerTypeFromString

func ContainerTypeFromString(containerType string) (ContainerType, error)

type CreatedContainer

type CreatedContainer interface {
	Container

	Discontinue() (DestroyingContainer, error)
	Destroying() (DestroyingContainer, error)
	IsHijacked() bool
	MarkAsHijacked() error
}

type CreatedVolume

type CreatedVolume interface {
	Handle() string
	Path() string
	Type() VolumeType
	TeamID() int
	CreateChildForContainer(CreatingContainer, string) (CreatingVolume, error)
	Destroying() (DestroyingVolume, error)
	WorkerName() string
	InitializeResourceCache(UsedResourceCache) error
	InitializeTaskCache(int, string, string) error
	ContainerHandle() string
	ParentHandle() string
	ResourceType() (*VolumeResourceType, error)
	BaseResourceType() (*UsedWorkerBaseResourceType, error)
	TaskIdentifier() (string, string, string, error)
}

type CreatingContainer

type CreatingContainer interface {
	Container

	Created() (CreatedContainer, error)
	Failed() (FailedContainer, error)
}

type CreatingVolume

type CreatingVolume interface {
	Handle() string
	ID() int
	Created() (CreatedVolume, error)
	Failed() (FailedVolume, error)
}

type Dashboard

type Dashboard []DashboardJob

type DashboardJob

type DashboardJob struct {
	Job Job

	FinishedBuild   Build
	NextBuild       Build
	TransitionBuild Build
}

type DestroyingContainer

type DestroyingContainer interface {
	Container

	Destroy() (bool, error)
	IsDiscontinued() bool
}

type DestroyingVolume

type DestroyingVolume interface {
	Handle() string
	Destroy() (bool, error)
	WorkerName() string
}

type ErrCustomResourceTypeVersionNotFound

type ErrCustomResourceTypeVersionNotFound struct {
	Name string
}

func (ErrCustomResourceTypeVersionNotFound) Error

type ErrResourceNotFound

type ErrResourceNotFound struct {
	Name string
}

func (ErrResourceNotFound) Error

func (e ErrResourceNotFound) Error() string

type ErrVolumeMarkCreatedFailed

type ErrVolumeMarkCreatedFailed struct {
	Handle string
}

func (ErrVolumeMarkCreatedFailed) Error

type ErrVolumeMarkStateFailed

type ErrVolumeMarkStateFailed struct {
	State VolumeState
}

func (ErrVolumeMarkStateFailed) Error

func (e ErrVolumeMarkStateFailed) Error() string

type EventSource

type EventSource interface {
	Next() (event.Envelope, error)
	Close() error
}

type FailedContainer

type FailedContainer interface {
	Container

	Destroy() (bool, error)
}

type FailedVolume

type FailedVolume interface {
	Handle() string
	Destroy() (bool, error)
	WorkerName() string
}

type FirstLoggedBuildIDDecreasedError

type FirstLoggedBuildIDDecreasedError struct {
	Job   string
	OldID int
	NewID int
}

func (FirstLoggedBuildIDDecreasedError) Error

type Job

type Job interface {
	ID() int
	Name() string
	Paused() bool
	FirstLoggedBuildID() int
	PipelineID() int
	PipelineName() string
	TeamID() int
	TeamName() string
	Config() atc.JobConfig
	Tags() []string

	Reload() (bool, error)

	Pause() error
	Unpause() error

	CreateBuild() (Build, error)
	Builds(page Page) ([]Build, Pagination, error)
	Build(name string) (Build, bool, error)
	FinishedAndNextBuild() (Build, Build, error)
	UpdateFirstLoggedBuildID(newFirstLoggedBuildID int) error
	EnsurePendingBuildExists() error
	GetPendingBuilds() ([]Build, error)

	GetIndependentBuildInputs() ([]BuildInput, error)
	GetNextBuildInputs() ([]BuildInput, bool, error)
	SaveNextInputMapping(inputMapping algorithm.InputMapping) error
	SaveIndependentInputMapping(inputMapping algorithm.InputMapping) error
	DeleteNextInputMapping() error

	SetMaxInFlightReached(bool) error
	GetRunningBuildsBySerialGroup(serialGroups []string) ([]Build, error)
	GetNextPendingBuildBySerialGroup(serialGroups []string) (Build, bool, error)

	ClearTaskCache(string, string) (int64, error)
}

type JobFactory

type JobFactory interface {
	VisibleJobs([]string) (Dashboard, error)
}

func NewJobFactory

func NewJobFactory(conn Conn, lockFactory lock.LockFactory) JobFactory

type Jobs

type Jobs []Job

func (Jobs) Configs

func (jobs Jobs) Configs() atc.JobConfigs

type MissingInputReasons

type MissingInputReasons map[string]string

func (MissingInputReasons) RegisterNoVersions

func (mir MissingInputReasons) RegisterNoVersions(inputName string)

func (MissingInputReasons) RegisterPassedConstraint

func (mir MissingInputReasons) RegisterPassedConstraint(inputName string)

func (MissingInputReasons) RegisterPinnedVersionUnavailable

func (mir MissingInputReasons) RegisterPinnedVersionUnavailable(inputName string, version string)

type NotificationsBus

type NotificationsBus interface {
	Listen(channel string) (chan bool, error)
	Notify(channel string) error
	Unlisten(channel string, notify chan bool) error
	Close() error
}

func NewNotificationsBus

func NewNotificationsBus(listener *pq.Listener, conn *sql.DB) NotificationsBus

type Notifier

type Notifier interface {
	Notify() <-chan struct{}
	Close() error
}

type Page

type Page struct {
	Since int // exclusive
	Until int // exclusive

	From int // inclusive
	To   int // inclusive

	Limit int
}

type Pagination

type Pagination struct {
	Previous *Page
	Next     *Page
}

type Pipe

type Pipe struct {
	ID       string
	URL      string
	TeamName string
}

type Pipeline

type Pipeline interface {
	ID() int
	Name() string
	TeamID() int
	TeamName() string
	Groups() atc.GroupConfigs
	ConfigVersion() ConfigVersion
	Public() bool
	Paused() bool
	ScopedName(string) string

	CheckPaused() (bool, error)
	Reload() (bool, error)

	Causality(versionedResourceID int) ([]Cause, error)

	SetResourceCheckError(Resource, error) error
	SaveResourceVersions(atc.ResourceConfig, []atc.Version) error
	GetResourceVersions(resourceName string, page Page) ([]SavedVersionedResource, Pagination, bool, error)

	GetAllPendingBuilds() (map[string][]Build, error)

	GetLatestVersionedResource(resourceName string) (SavedVersionedResource, bool, error)
	GetVersionedResourceByVersion(atcVersion atc.Version, resourceName string) (SavedVersionedResource, bool, error)

	VersionedResource(versionedResourceID int) (SavedVersionedResource, bool, error)
	DisableVersionedResource(versionedResourceID int) error
	EnableVersionedResource(versionedResourceID int) error
	GetBuildsWithVersionAsInput(versionedResourceID int) ([]Build, error)
	GetBuildsWithVersionAsOutput(versionedResourceID int) ([]Build, error)
	Builds(page Page) ([]Build, Pagination, error)

	DeleteBuildEventsByBuildIDs(buildIDs []int) error

	AcquireSchedulingLock(lager.Logger, time.Duration) (lock.Lock, bool, error)

	AcquireResourceCheckingLockWithIntervalCheck(
		logger lager.Logger,
		resourceName string,
		resourceConfig ResourceConfig,
		interval time.Duration,
		immediate bool,
	) (lock.Lock, bool, error)

	AcquireResourceTypeCheckingLockWithIntervalCheck(
		logger lager.Logger,
		resourceTypeName string,
		resourceConfig ResourceConfig,
		interval time.Duration,
		immediate bool,
	) (lock.Lock, bool, error)

	LoadVersionsDB() (*algorithm.VersionsDB, error)

	Resource(name string) (Resource, bool, error)
	Resources() (Resources, error)

	ResourceTypes() (ResourceTypes, error)
	ResourceType(name string) (ResourceType, bool, error)

	Job(name string) (Job, bool, error)
	Jobs() (Jobs, error)
	Dashboard() (Dashboard, error)

	Expose() error
	Hide() error

	Pause() error
	Unpause() error

	Destroy() error
	Rename(string) error

	CreateOneOffBuild() (Build, error)
}

type PipelineFactory

type PipelineFactory interface {
	VisiblePipelines([]string) ([]Pipeline, error)
	AllPipelines() ([]Pipeline, error)
}

func NewPipelineFactory

func NewPipelineFactory(conn Conn, lockFactory lock.LockFactory) PipelineFactory

type PipelinePausedState

type PipelinePausedState string
const (
	PipelinePaused   PipelinePausedState = "paused"
	PipelineUnpaused PipelinePausedState = "unpaused"
	PipelineNoChange PipelinePausedState = "nochange"
)

func (PipelinePausedState) Bool

func (state PipelinePausedState) Bool() *bool

type Resource

type Resource interface {
	ID() int
	Name() string
	PipelineName() string
	TeamName() string
	Type() string
	Source() atc.Source
	CheckEvery() string
	CheckTimeout() string
	LastChecked() time.Time
	Tags() atc.Tags
	CheckError() error
	Paused() bool
	WebhookToken() string
	PinnedVersion() atc.Version
	FailingToCheck() bool

	SetResourceConfig(int) error

	Pause() error
	Unpause() error

	Reload() (bool, error)
}

type ResourceCacheDescriptor

type ResourceCacheDescriptor struct {
	ResourceConfigDescriptor ResourceConfigDescriptor // The resource configuration.
	Version                  atc.Version              // The version of the resource.
	Params                   atc.Params               // The params used when fetching the version.
}

ResourceCache represents an instance of a ResourceConfig's version.

A ResourceCache is created by a `get`, an `image_resource`, or a resource type in a pipeline.

ResourceCaches are garbage-collected by gc.ResourceCacheCollector.

type ResourceCacheFactory

type ResourceCacheFactory interface {
	FindOrCreateResourceCache(
		logger lager.Logger,
		resourceCacheUser ResourceCacheUser,
		resourceTypeName string,
		version atc.Version,
		source atc.Source,
		params atc.Params,
		resourceTypes creds.VersionedResourceTypes,
	) (UsedResourceCache, error)

	// changing resource cache to interface to allow updates on object is not feasible.
	// Since we need to pass it recursively in ResourceConfig.
	// Also, metadata will be available to us before we create resource cache so this
	// method can be removed at that point. See  https://github.com/concourse/concourse/issues/534
	UpdateResourceCacheMetadata(UsedResourceCache, []atc.MetadataField) error
	ResourceCacheMetadata(UsedResourceCache) (ResourceMetadataFields, error)
}

func NewResourceCacheFactory

func NewResourceCacheFactory(conn Conn, lockFactory lock.LockFactory) ResourceCacheFactory

type ResourceCacheLifecycle

type ResourceCacheLifecycle interface {
	CleanUsesForFinishedBuilds(lager.Logger) error
	CleanBuildImageResourceCaches(lager.Logger) error
	CleanUpInvalidCaches(lager.Logger) error
}

func NewResourceCacheLifecycle

func NewResourceCacheLifecycle(conn Conn) ResourceCacheLifecycle

type ResourceCacheUser

type ResourceCacheUser interface {
	SQLMap() map[string]interface{}
}

ResourceCacheUser designates the column to set in the resource_cache_users table.

func ForBuild

func ForBuild(id int) ResourceCacheUser

func ForContainer

func ForContainer(id int) ResourceCacheUser

type ResourceConfig

type ResourceConfig interface {
	ID() int
	CreatedByResourceCache() UsedResourceCache
	CreatedByBaseResourceType() *UsedBaseResourceType
	OriginBaseResourceType() *UsedBaseResourceType
	AcquireResourceConfigCheckingLockWithIntervalCheck(
		logger lager.Logger,
		interval time.Duration,
		immediate bool,
	) (lock.Lock, bool, error)
}

type ResourceConfigCheckSession

type ResourceConfigCheckSession interface {
	ID() int
	ResourceConfig() ResourceConfig
}

type ResourceConfigCheckSessionFactory

type ResourceConfigCheckSessionFactory interface {
	FindOrCreateResourceConfigCheckSession(
		logger lager.Logger,
		resourceType string,
		source atc.Source,
		resourceTypes creds.VersionedResourceTypes,
		expiries ContainerOwnerExpiries,
	) (ResourceConfigCheckSession, error)
}

func NewResourceConfigCheckSessionFactory

func NewResourceConfigCheckSessionFactory(conn Conn, lockFactory lock.LockFactory) ResourceConfigCheckSessionFactory

type ResourceConfigCheckSessionLifecycle

type ResourceConfigCheckSessionLifecycle interface {
	CleanInactiveResourceConfigCheckSessions() error
	CleanExpiredResourceConfigCheckSessions() error
}

func NewResourceConfigCheckSessionLifecycle

func NewResourceConfigCheckSessionLifecycle(conn Conn) ResourceConfigCheckSessionLifecycle

type ResourceConfigDescriptor

type ResourceConfigDescriptor struct {
	// A resource type provided by a resource.
	CreatedByResourceCache *ResourceCacheDescriptor

	// A resource type provided by a worker.
	CreatedByBaseResourceType *BaseResourceType

	// The resource's source configuration.
	Source atc.Source
}

ResourceConfig represents a resource type and config source.

Resources in a pipeline, resource types in a pipeline, and `image_resource` fields in a task all result in a reference to a ResourceConfig.

ResourceConfigs are garbage-collected by gc.ResourceConfigCollector.

type ResourceConfigFactory

type ResourceConfigFactory interface {
	FindResourceConfig(
		logger lager.Logger,
		resourceType string,
		source atc.Source,
		resourceTypes creds.VersionedResourceTypes,
	) (ResourceConfig, bool, error)

	FindOrCreateResourceConfig(
		logger lager.Logger,
		resourceType string,
		source atc.Source,
		resourceTypes creds.VersionedResourceTypes,
	) (ResourceConfig, error)

	CleanUnreferencedConfigs() error
}

func NewResourceConfigFactory

func NewResourceConfigFactory(conn Conn, lockFactory lock.LockFactory) ResourceConfigFactory

type ResourceFactory

type ResourceFactory interface {
	VisibleResources([]string) ([]Resource, error)
}

func NewResourceFactory

func NewResourceFactory(conn Conn, lockFactory lock.LockFactory) ResourceFactory

type ResourceMetadataField

type ResourceMetadataField struct {
	Name  string
	Value string
}

type ResourceMetadataFields

type ResourceMetadataFields []ResourceMetadataField

func NewResourceMetadataFields

func NewResourceMetadataFields(atcm []atc.MetadataField) ResourceMetadataFields

func (ResourceMetadataFields) ToATCMetadata

func (rmf ResourceMetadataFields) ToATCMetadata() []atc.MetadataField

type ResourceNotFoundError

type ResourceNotFoundError struct {
	Name string
}

func (ResourceNotFoundError) Error

func (e ResourceNotFoundError) Error() string

type ResourceType

type ResourceType interface {
	ID() int
	Name() string
	Type() string
	Privileged() bool
	Source() atc.Source
	Params() atc.Params
	Tags() atc.Tags
	CheckEvery() string

	SetResourceConfig(int) error

	Version() atc.Version
	SaveVersion(atc.Version) error

	Reload() (bool, error)
}

type ResourceTypeNotFoundError

type ResourceTypeNotFoundError struct {
	Name string
}

func (ResourceTypeNotFoundError) Error

type ResourceTypes

type ResourceTypes []ResourceType

func (ResourceTypes) Configs

func (resourceTypes ResourceTypes) Configs() atc.ResourceTypes

func (ResourceTypes) Deserialize

func (resourceTypes ResourceTypes) Deserialize() atc.VersionedResourceTypes

type ResourceVersion

type ResourceVersion map[string]string

type Resources

type Resources []Resource

func (Resources) Configs

func (resources Resources) Configs() atc.ResourceConfigs

func (Resources) Lookup

func (resources Resources) Lookup(name string) (Resource, bool)

func (Resources) PinnedVersions

func (resources Resources) PinnedVersions() map[string]atc.Version

type SavedVersionedResource

type SavedVersionedResource struct {
	ID      int
	Enabled bool
	VersionedResource
	CheckOrder int
}

type SavedVersionedResources

type SavedVersionedResources []SavedVersionedResource

type Team

type Team interface {
	ID() int
	Name() string
	Admin() bool

	Auth() map[string][]string

	Delete() error
	Rename(string) error

	SavePipeline(
		pipelineName string,
		config atc.Config,
		from ConfigVersion,
		pausedState PipelinePausedState,
	) (Pipeline, bool, error)

	Pipeline(pipelineName string) (Pipeline, bool, error)
	Pipelines() ([]Pipeline, error)
	PublicPipelines() ([]Pipeline, error)
	VisiblePipelines() ([]Pipeline, error)
	OrderPipelines([]string) error

	CreateOneOffBuild() (Build, error)
	PrivateAndPublicBuilds(Page) ([]Build, Pagination, error)
	Builds(page Page) ([]Build, Pagination, error)

	SaveWorker(atcWorker atc.Worker, ttl time.Duration) (Worker, error)
	Workers() ([]Worker, error)

	FindContainerByHandle(string) (Container, bool, error)
	FindContainersByMetadata(ContainerMetadata) ([]Container, error)
	FindCheckContainers(lager.Logger, string, string, creds.VariablesFactory) ([]Container, error)

	FindCreatedContainerByHandle(string) (CreatedContainer, bool, error)

	FindWorkerForContainer(handle string) (Worker, bool, error)

	FindWorkerForContainerByOwner(ContainerOwner) (Worker, bool, error)
	FindContainerOnWorker(workerName string, owner ContainerOwner) (CreatingContainer, CreatedContainer, error)
	CreateContainer(workerName string, owner ContainerOwner, meta ContainerMetadata) (CreatingContainer, error)

	UpdateProviderAuth(auth map[string][]string) error
}

type TeamFactory

type TeamFactory interface {
	CreateTeam(atc.Team) (Team, error)
	FindTeam(string) (Team, bool, error)
	GetTeams() ([]Team, error)
	GetByID(teamID int) Team
	CreateDefaultTeamIfNotExists() (Team, error)
}

func NewTeamFactory

func NewTeamFactory(conn Conn, lockFactory lock.LockFactory) TeamFactory

type Tx

type Tx interface {
	Commit() error
	Exec(query string, args ...interface{}) (sql.Result, error)
	Prepare(query string) (*sql.Stmt, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) squirrel.RowScanner
	Rollback() error
	Stmt(stmt *sql.Stmt) *sql.Stmt
}

type UsedBaseResourceType

type UsedBaseResourceType struct {
	ID   int // The ID of the BaseResourceType.
	Name string
}

UsedBaseResourceType is created whenever a ResourceConfig is used, either for a build, a resource in the pipeline, or a resource type in the pipeline.

So long as the UsedBaseResourceType's ID is referenced by a ResourceConfig that is in use, this guarantees that the BaseResourceType will not be removed. That is to say that its "Use" is vicarious.

type UsedResourceCache

type UsedResourceCache interface {
	ID() int
	ResourceConfig() ResourceConfig
	Version() atc.Version

	Destroy(Tx) (bool, error)
	BaseResourceType() *UsedBaseResourceType
}

type UsedWorkerBaseResourceType

type UsedWorkerBaseResourceType struct {
	ID      int
	Name    string
	Version string

	WorkerName string
}

type UsedWorkerResourceCache

type UsedWorkerResourceCache struct {
	ID int
}

type UsedWorkerResourceCerts

type UsedWorkerResourceCerts struct {
	ID int
}

type UsedWorkerResourceType

type UsedWorkerResourceType struct {
	ID int

	Worker Worker

	UsedBaseResourceType *UsedBaseResourceType
}

type UsedWorkerTaskCache

type UsedWorkerTaskCache struct {
	ID         int
	WorkerName string
}

type VersionedResource

type VersionedResource struct {
	Resource string
	Type     string
	Version  ResourceVersion
	Metadata ResourceMetadataFields
}

type VolumeRepository

type VolumeRepository interface {
	GetTeamVolumes(teamID int) ([]CreatedVolume, error)

	CreateContainerVolume(int, string, CreatingContainer, string) (CreatingVolume, error)
	FindContainerVolume(int, string, CreatingContainer, string) (CreatingVolume, CreatedVolume, error)

	FindBaseResourceTypeVolume(int, *UsedWorkerBaseResourceType) (CreatingVolume, CreatedVolume, error)
	CreateBaseResourceTypeVolume(int, *UsedWorkerBaseResourceType) (CreatingVolume, error)

	FindResourceCacheVolume(string, UsedResourceCache) (CreatedVolume, bool, error)

	FindTaskCacheVolume(teamID int, uwtc *UsedWorkerTaskCache) (CreatingVolume, CreatedVolume, error)
	CreateTaskCacheVolume(teamID int, uwtc *UsedWorkerTaskCache) (CreatingVolume, error)

	FindResourceCertsVolume(workerName string, uwrc *UsedWorkerResourceCerts) (CreatingVolume, CreatedVolume, error)
	CreateResourceCertsVolume(workerName string, uwrc *UsedWorkerResourceCerts) (CreatingVolume, error)

	FindVolumesForContainer(CreatedContainer) ([]CreatedVolume, error)
	GetOrphanedVolumes() ([]CreatedVolume, error)

	DestroyFailedVolumes() (int, error)

	GetDestroyingVolumes(workerName string) ([]string, error)

	FindCreatedVolume(handle string) (CreatedVolume, bool, error)

	RemoveDestroyingVolumes(workerName string, handles []string) (int, error)
}

func NewVolumeRepository

func NewVolumeRepository(conn Conn) VolumeRepository

type VolumeResourceType

type VolumeResourceType struct {
	WorkerBaseResourceType *UsedWorkerBaseResourceType
	ResourceType           *VolumeResourceType
	Version                atc.Version
}

type VolumeState

type VolumeState string
const (
	VolumeStateCreating   VolumeState = "creating"
	VolumeStateCreated    VolumeState = "created"
	VolumeStateDestroying VolumeState = "destroying"
	VolumeStateFailed     VolumeState = "failed"
)

type VolumeType

type VolumeType string
const (
	VolumeTypeContainer     VolumeType = "container"
	VolumeTypeResource      VolumeType = "resource"
	VolumeTypeResourceType  VolumeType = "resource-type"
	VolumeTypeResourceCerts VolumeType = "resource-certs"
	VolumeTypeTaskCache     VolumeType = "task-cache"
	VolumeTypeUknown        VolumeType = "unknown" // for migration to life
)

type Worker

type Worker interface {
	Name() string
	Version() *string
	State() WorkerState
	GardenAddr() *string
	BaggageclaimURL() *string
	CertsPath() *string
	ResourceCerts() (*UsedWorkerResourceCerts, bool, error)
	HTTPProxyURL() string
	HTTPSProxyURL() string
	NoProxy() string
	ActiveContainers() int
	ResourceTypes() []atc.WorkerResourceType
	Platform() string
	Tags() []string
	TeamID() int
	TeamName() string
	StartTime() int64
	ExpiresAt() time.Time
	Ephemeral() bool

	Reload() (bool, error)

	Land() error
	Retire() error
	Prune() error
	Delete() error
}

type WorkerBaseResourceType

type WorkerBaseResourceType struct {
	Name       string
	WorkerName string
}

func (WorkerBaseResourceType) Find

func (workerBaseResourceType WorkerBaseResourceType) Find(runner sq.Runner) (*UsedWorkerBaseResourceType, bool, error)

type WorkerBaseResourceTypeFactory

type WorkerBaseResourceTypeFactory interface {
	Find(name string, worker Worker) (*UsedWorkerBaseResourceType, bool, error)
}

func NewWorkerBaseResourceTypeFactory

func NewWorkerBaseResourceTypeFactory(conn Conn) WorkerBaseResourceTypeFactory

type WorkerFactory

type WorkerFactory interface {
	GetWorker(name string) (Worker, bool, error)
	SaveWorker(atcWorker atc.Worker, ttl time.Duration) (Worker, error)
	HeartbeatWorker(worker atc.Worker, ttl time.Duration) (Worker, error)
	Workers() ([]Worker, error)
	VisibleWorkers([]string) ([]Worker, error)
}

func NewWorkerFactory

func NewWorkerFactory(conn Conn) WorkerFactory

type WorkerLifecycle

type WorkerLifecycle interface {
	DeleteUnresponsiveEphemeralWorkers() ([]string, error)
	StallUnresponsiveWorkers() ([]string, error)
	LandFinishedLandingWorkers() ([]string, error)
	DeleteFinishedRetiringWorkers() ([]string, error)
}

func NewWorkerLifecycle

func NewWorkerLifecycle(conn Conn) WorkerLifecycle

type WorkerResourceCache

type WorkerResourceCache struct {
	WorkerName    string
	ResourceCache UsedResourceCache
}

func (WorkerResourceCache) Find

func (workerResourceCache WorkerResourceCache) Find(runner sq.Runner) (*UsedWorkerResourceCache, bool, error)

func (WorkerResourceCache) FindOrCreate

func (workerResourceCache WorkerResourceCache) FindOrCreate(tx Tx) (*UsedWorkerResourceCache, error)

type WorkerResourceCerts

type WorkerResourceCerts struct {
	WorkerName string
	CertsPath  string
}

func (WorkerResourceCerts) Find

func (workerResourceCerts WorkerResourceCerts) Find(runner sq.BaseRunner) (*UsedWorkerResourceCerts, bool, error)

func (WorkerResourceCerts) FindOrCreate

func (workerResourceCerts WorkerResourceCerts) FindOrCreate(tx Tx) (*UsedWorkerResourceCerts, error)

type WorkerResourceType

type WorkerResourceType struct {
	Worker  Worker
	Image   string // The path to the image, e.g. '/opt/concourse/resources/git'.
	Version string // The version of the image, e.g. a SHA of the rootfs.

	BaseResourceType *BaseResourceType
}

func (WorkerResourceType) FindOrCreate

func (wrt WorkerResourceType) FindOrCreate(tx Tx) (*UsedWorkerResourceType, error)

type WorkerState

type WorkerState string

type WorkerTaskCache

type WorkerTaskCache struct {
	JobID      int
	StepName   string
	WorkerName string
	Path       string
}

func (WorkerTaskCache) FindOrCreate

func (wtc WorkerTaskCache) FindOrCreate(
	tx Tx,
) (*UsedWorkerTaskCache, error)

type WorkerTaskCacheFactory

type WorkerTaskCacheFactory interface {
	Find(jobID int, stepName string, path string, workerName string) (*UsedWorkerTaskCache, bool, error)
	FindOrCreate(jobID int, stepName string, path string, workerName string) (*UsedWorkerTaskCache, error)
}

func NewWorkerTaskCacheFactory

func NewWorkerTaskCacheFactory(conn Conn) WorkerTaskCacheFactory

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.
encryptionfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
lockfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
cli
migrationfakes
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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