manager

package
v0.0.0-...-ffb5225 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

TODO: rename package to management or something else, or split up into domain specific packages

Index

Constants

View Source
const (
	KindFinalizeAttestation                      = "finalize_attestation"
	FinalizeAttestationScheduledForResyncMinutes = 10 * time.Second
	FinalizeAttestationScheduledWaitSecond       = 30 * time.Second
)
View Source
const (
	KindRemoveFromSource            = "remove_from_source"
	RemoveFromSourceByPeriodMinutes = 2 * time.Minute
)
View Source
const (
	KindUploadAttestation            = "upload_attestation"
	UploadAttestationByPeriodMinutes = 2 * time.Minute
)
View Source
const (
	KindAddWorkload = "add_workload"
)
View Source
const (
	KindDeleteWorkload = "delete_workload"
)
View Source
const (
	KindGetAttestation = "get_attestation"
)

Variables

This section is empty.

Functions

func AddWorker

func AddWorker[T river.JobArgs](ctx context.Context, worker river.Worker[T])

func JobClient

func JobClient(ctx context.Context) job.Client

func NewContext

func NewContext(
	ctx context.Context,
	dbPool *pgxpool.Pool,
	jobClient job.Client,
	verifier attestation.Verifier,
	source sources.Source,
	logger logrus.FieldLogger,
) context.Context

Types

type AddWorkloadJob

type AddWorkloadJob struct {
	Workload *model.Workload
}

func (AddWorkloadJob) InsertOpts

func (a AddWorkloadJob) InsertOpts() river.InsertOpts

func (AddWorkloadJob) Kind

func (AddWorkloadJob) Kind() string

type AddWorkloadWorker

type AddWorkloadWorker struct {
	river.WorkerDefaults[AddWorkloadJob]
	// contains filtered or unexported fields
}

func (*AddWorkloadWorker) Work

type Db

type Db struct {
	Pool *pgxpool.Pool
	sql.Querier
}

type DeleteWorkloadJob

type DeleteWorkloadJob struct {
	Workload *model.Workload
}

func (DeleteWorkloadJob) InsertOpts

func (u DeleteWorkloadJob) InsertOpts() river.InsertOpts

func (DeleteWorkloadJob) Kind

func (DeleteWorkloadJob) Kind() string

type DeleteWorkloadWorker

type DeleteWorkloadWorker struct {
	river.WorkerDefaults[DeleteWorkloadJob]
	// contains filtered or unexported fields
}

func (*DeleteWorkloadWorker) Work

type Dispatcher

type Dispatcher[T any] struct {
	// contains filtered or unexported fields
}

func NewDispatcher

func NewDispatcher[T any](worker Worker[T], queue chan T, maxWorkers int) *Dispatcher[T]

func (*Dispatcher[T]) Add

func (d *Dispatcher[T]) Add(obj T)

Add enqueues an object into the queue. If the number of enqueued jobs has already reached its maximum size, this will block until the other jobs has finished and the queue has space to accept a new object.

func (*Dispatcher[T]) Start

func (d *Dispatcher[T]) Start(ctx context.Context)

func (*Dispatcher[T]) Wait

func (d *Dispatcher[T]) Wait()

Wait blocks until the dispatcher stops.

type FinalizeAttestationJob

type FinalizeAttestationJob struct {
	ImageName    string `river:"unique"`
	ImageTag     string `river:"unique"`
	ProcessToken string
}

func (FinalizeAttestationJob) InsertOpts

func (f FinalizeAttestationJob) InsertOpts() river.InsertOpts

func (FinalizeAttestationJob) Kind

type FinalizeAttestationWorker

type FinalizeAttestationWorker struct {
	river.WorkerDefaults[FinalizeAttestationJob]
	// contains filtered or unexported fields
}

func (*FinalizeAttestationWorker) Work

type GetAttestationJob

type GetAttestationJob struct {
	ImageName    string
	ImageTag     string
	WorkloadId   pgtype.UUID
	WorkloadType model.WorkloadType
}

func (GetAttestationJob) InsertOpts

func (g GetAttestationJob) InsertOpts() river.InsertOpts

func (GetAttestationJob) Kind

func (GetAttestationJob) Kind() string

type GetAttestationWorker

type GetAttestationWorker struct {
	river.WorkerDefaults[GetAttestationJob]
	// contains filtered or unexported fields
}

func (*GetAttestationWorker) NextRetry

func (*GetAttestationWorker) Work

type JobOutput

type JobOutput struct {
	Status JobStatus `json:"status"`
}

type JobStatus

type JobStatus = string
const (
	JobStatusSourceRefDeleteSkipped     JobStatus = "source_ref_delete_skipped"
	JobStatusInitializeWorkloadSkipped  JobStatus = "initialize_workload_skipped"
	JobStatusUnrecoverable              JobStatus = "unrecoverable"
	JobStatusSourceRefExists            JobStatus = "source_ref_exists"
	JobStatusNoAttestation              JobStatus = "no_attestation"
	JobStatusAttestationDownloaded      JobStatus = "attestation_downloaded"
	JobStatusAttestationUploaded        JobStatus = "attestation_uploaded"
	JobStatusUploadAttestationFinalized JobStatus = "upload_attestation_finalized"
	JobStatusUpdated                    JobStatus = "updated"
	JobStatusImageRemovedFromSource     JobStatus = "image_removed_from_source"
	JobStatusImageStillInUse            JobStatus = "image_still_in_use"
	JobStatusSourceRefDeleted           JobStatus = "source_ref_deleted"
)

type Mgr

type Mgr struct {
	Db        *Db
	JobClient job.Client
	Verifier  attestation.Verifier
	Source    sources.Source
	Logger    logrus.FieldLogger
}

func FromContext

func FromContext(ctx context.Context) *Mgr

type RemoveFromSourceJob

type RemoveFromSourceJob struct {
	ImageName string `json:"image_name" river:"unique"`
	ImageTag  string `json:"image_tag" river:"unique"`
}

func (RemoveFromSourceJob) InsertOpts

func (u RemoveFromSourceJob) InsertOpts() river.InsertOpts

func (RemoveFromSourceJob) Kind

func (RemoveFromSourceJob) Kind() string

type RemoveFromSourceWorker

type RemoveFromSourceWorker struct {
	river.WorkerDefaults[RemoveFromSourceJob]
	// contains filtered or unexported fields
}

func (*RemoveFromSourceWorker) Work

type UploadAttestationJob

type UploadAttestationJob struct {
	ImageName   string `river:"unique"`
	ImageTag    string `river:"unique"`
	WorkloadId  pgtype.UUID
	Attestation []byte
}

func (UploadAttestationJob) InsertOpts

func (u UploadAttestationJob) InsertOpts() river.InsertOpts

func (UploadAttestationJob) Kind

type UploadAttestationWorker

type UploadAttestationWorker struct {
	river.WorkerDefaults[UploadAttestationJob]
	// contains filtered or unexported fields
}

func (*UploadAttestationWorker) Work

type Worker

type Worker[T any] func(ctx context.Context, item T) error

type WorkloadEvent

type WorkloadEvent string
const (
	WorkloadEventFailed           WorkloadEvent = "failed"
	WorkloadEventUnrecoverable    WorkloadEvent = "unrecoverable_error"
	WorkloadEventRecoverable      WorkloadEvent = "recoverable_error"
	WorkloadEventSucceeded        WorkloadEvent = "succeeded"
	WorkloadEventSubsystemUnknown               = "unknown"
)

type WorkloadManager

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

func NewWorkloadManager

func NewWorkloadManager(ctx context.Context, pool *pgxpool.Pool, jobCfg *job.Config, verifier attestation.Verifier, source sources.Source, queue *kubernetes.WorkloadEventQueue, log *logrus.Entry) *WorkloadManager

func (*WorkloadManager) AddJob

func (m *WorkloadManager) AddJob(ctx context.Context, job river.JobArgs) error

func (*WorkloadManager) AddWorkload

func (m *WorkloadManager) AddWorkload(ctx context.Context, workload *model.Workload) error

func (*WorkloadManager) DeleteWorkload

func (m *WorkloadManager) DeleteWorkload(ctx context.Context, workload *model.Workload) error

func (*WorkloadManager) Start

func (m *WorkloadManager) Start(ctx context.Context)

func (*WorkloadManager) Stop

func (m *WorkloadManager) Stop(ctx context.Context) error

Jump to

Keyboard shortcuts

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