image

package
v0.0.0-...-bbaddd9 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: AGPL-3.0 Imports: 18 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	RelationshipTypeBase    = "base"
	RelationshipTypeOverlay = "overlay"
)
View Source
const DefaultDeleteExpiredImagesInterval = 60 * time.Second

Variables

View Source
var ZeroUUID = uuid.UUID{}

Functions

func DeleteExpiredImagesTask

func DeleteExpiredImagesTask(lock utils.MutexLock, imageRepo ImageRepo) error

DeleteExpiredImagesTask runs one pass under lock: expired images are auto marked as deleted periodically.

func RunDeleteExpiredImagesTask

func RunDeleteExpiredImagesTask(lock utils.MutexLock, imageRepo ImageRepo, interval time.Duration)

Types

type DBImageRelationshipRepo

type DBImageRelationshipRepo struct {
	db.RepoConn
}

func NewDBImageRelationshipRepo

func NewDBImageRelationshipRepo(conn *sql.DB) *DBImageRelationshipRepo

func (*DBImageRelationshipRepo) AreRelated

func (repo *DBImageRelationshipRepo) AreRelated(imageId1, imageId2 string) (bool, error)

AreRelated returns true if there is any DAG path between the two images (in either direction).

func (*DBImageRelationshipRepo) CreateRelationship

func (repo *DBImageRelationshipRepo) CreateRelationship(imageId, parentImageId, relationshipType string) (*ImageRelationship, error)

func (*DBImageRelationshipRepo) GetAncestorIds

func (repo *DBImageRelationshipRepo) GetAncestorIds(imageId string) ([]string, error)

GetAncestorIds walks the DAG upward from imageId using a recursive CTE.

func (*DBImageRelationshipRepo) GetChildrenByImageId

func (repo *DBImageRelationshipRepo) GetChildrenByImageId(imageId string) ([]ImageRelationship, error)

func (*DBImageRelationshipRepo) GetDescendantIds

func (repo *DBImageRelationshipRepo) GetDescendantIds(imageId string) ([]string, error)

GetDescendantIds walks the DAG downward from imageId using a recursive CTE.

func (*DBImageRelationshipRepo) GetParentsByImageId

func (repo *DBImageRelationshipRepo) GetParentsByImageId(imageId string) ([]ImageRelationship, error)

func (*DBImageRelationshipRepo) GetParentsByImageIds

func (repo *DBImageRelationshipRepo) GetParentsByImageIds(imageIds []string) (map[string][]ImageRelationship, error)

func (*DBImageRelationshipRepo) HasRelationships

func (repo *DBImageRelationshipRepo) HasRelationships(imageId string) (bool, error)

func (*DBImageRelationshipRepo) IsAncestor

func (repo *DBImageRelationshipRepo) IsAncestor(imageId, ancestorId string) (bool, error)

IsAncestor returns true if ancestorId is a transitive parent of imageId.

func (*DBImageRelationshipRepo) WithTransaction

func (repo *DBImageRelationshipRepo) WithTransaction(tx *sql.Tx) db.DBRepo

type DBImageRepo

type DBImageRepo struct {
	db.RepoConn
}

func NewDBImageRepo

func NewDBImageRepo(conn *sql.DB) *DBImageRepo

func (*DBImageRepo) CountImages

func (repo *DBImageRepo) CountImages(filters *ListImagesFilters) (int, error)

func (*DBImageRepo) CreateAndSaveUploadedImage

func (repo *DBImageRepo) CreateAndSaveUploadedImage(image *dm.Image, mimeType string, fileBytes []byte, storageDefinitionId string, saveFn SaveFunc) (*dm.StoredImage, error)

func (*DBImageRepo) CreateImage

func (repo *DBImageRepo) CreateImage(image *dm.Image) (*dm.Image, error)

func (*DBImageRepo) CreateStoredImage

func (repo *DBImageRepo) CreateStoredImage(imageId string, storageDefinitionId string, fileIdentifier string, copiedFromId *string) (*dm.StoredImage, error)

func (*DBImageRepo) DeleteImageById

func (repo *DBImageRepo) DeleteImageById(id string) error

func (*DBImageRepo) DeleteImagesByIds

func (repo *DBImageRepo) DeleteImagesByIds(ids []string) error

func (*DBImageRepo) GetExpiredImageIds

func (repo *DBImageRepo) GetExpiredImageIds() ([]string, error)

GetExpiredImageIds returns the ids of images whose expiry has passed.

func (*DBImageRepo) GetImageById

func (repo *DBImageRepo) GetImageById(id string) (*dm.Image, error)

func (*DBImageRepo) GetImagesByIds

func (repo *DBImageRepo) GetImagesByIds(ids []string) ([]*dm.Image, error)

func (*DBImageRepo) ListImages

func (repo *DBImageRepo) ListImages(
	filtersWithoutCursor *ListImagesFilters,
	filtersWithCursor *ListImagesFilters,
	ordering *ListImagesOrdering,
	reverse bool,
) (dm.ListImageResult, error)

func (*DBImageRepo) SetImagesExpiration

func (repo *DBImageRepo) SetImagesExpiration(ids []string, expiresAt *time.Time) (int, error)

SetImagesExpiration sets or clears (expiresAt == nil) the expiry of the given images and returns how many were updated. Images that have already expired are left unchanged: an expired image is only ever transitioned to deleted.

func (*DBImageRepo) WithTransaction

func (repo *DBImageRepo) WithTransaction(tx *sql.Tx) db.DBRepo

type DeleteExpiredImagesConfig

type DeleteExpiredImagesConfig struct {
	Enabled  bool
	Interval time.Duration
}

DeleteExpiredImagesConfig controls the periodic task that transitions expired images to deleted. It is enabled by default.

func DefaultDeleteExpiredImagesConfig

func DefaultDeleteExpiredImagesConfig() *DeleteExpiredImagesConfig

func ReadDeleteExpiredImagesConfigFromEnv

func ReadDeleteExpiredImagesConfigFromEnv() *DeleteExpiredImagesConfig

ReadDeleteExpiredImagesConfigFromEnv reads DELETE_EXPIRED_IMAGES_ENABLED and DELETE_EXPIRED_IMAGES_INTERVAL_SECONDS. It returns nil when neither is set, so that other config sources or the default apply.

type ImageRelationship

type ImageRelationship struct {
	Id               string
	ImageId          string
	ParentImageId    string
	RelationshipType string
}

type ImageRelationshipRepo

type ImageRelationshipRepo interface {
	CreateRelationship(imageId, parentImageId, relationshipType string) (*ImageRelationship, error)
	GetParentsByImageId(imageId string) ([]ImageRelationship, error)
	GetParentsByImageIds(imageIds []string) (map[string][]ImageRelationship, error)
	GetChildrenByImageId(imageId string) ([]ImageRelationship, error)
	HasRelationships(imageId string) (bool, error)
	// GetDescendantIds returns all transitive children of the given image (not including itself).
	GetDescendantIds(imageId string) ([]string, error)
	// GetAncestorIds returns all transitive parents of the given image (not including itself).
	GetAncestorIds(imageId string) ([]string, error)
	// AreRelated returns true if there is any path between the two images in the DAG.
	AreRelated(imageId1, imageId2 string) (bool, error)
	// IsAncestor returns true if ancestorId is a transitive parent of imageId.
	IsAncestor(imageId, ancestorId string) (bool, error)
}

type ImageRepo

type ImageRepo interface {
	CreateAndSaveUploadedImage(image *dm.Image, mimeType string, fileBytes []byte, storageDefinitionId string, saveFn SaveFunc) (*dm.StoredImage, error)
	CreateStoredImage(imageId string, storageDefinitionId string, fileIdentifier string, copiedFromId *string) (*dm.StoredImage, error)
	ListImages(filtersWithoutCursor *ListImagesFilters, filtersWithCursor *ListImagesFilters, ordering *ListImagesOrdering, reverse bool) (dm.ListImageResult, error)
	CountImages(filters *ListImagesFilters) (int, error)
	GetImageById(id string) (*dm.Image, error)
	GetImagesByIds(ids []string) ([]*dm.Image, error)
	DeleteImageById(id string) error
	DeleteImagesByIds(ids []string) error
	SetImagesExpiration(ids []string, expiresAt *time.Time) (int, error)
	GetExpiredImageIds() ([]string, error)
}

type ListImagesFilters

type ListImagesFilters struct {
	NameContains string
	NameLt       string
	NameGt       string
	CreatedAtLt  *time.Time
	CreatedAtGt  *time.Time
	IdGt         string
	IdLt         string
	CreatedBy    *string
	Limit        int
}

func FromPaginationFilter

func FromPaginationFilter(pf *pagination.Filter) *ListImagesFilters

type ListImagesOrdering

type ListImagesOrdering struct {
	ID        *PaginationDirection `json:"id,omitempty"`
	Name      *PaginationDirection `json:"name,omitempty"`
	CreatedAt *PaginationDirection `json:"createdAt,omitempty"`
	Checksum  string
}

func FromPaginationOrder

func FromPaginationOrder(po *pagination.Order) *ListImagesOrdering

type PaginationDirection

type PaginationDirection string
var (
	PaginationDirectionAsc  PaginationDirection = "asc"
	PaginationDirectionDesc PaginationDirection = "desc"
)

func (PaginationDirection) Reverse

type SaveFunc

type SaveFunc func(file utils.SeekerReader, filename string, mimeType string) error

Jump to

Keyboard shortcuts

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