artifacts

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package artifacts keeps the Controller's cache of software artifacts (server jars): files in the data directory named by their SHA-256, with a database record of what each one is. Downloads are checked against the upstream checksum before they are kept; uploads are kept as unverified.

Index

Constants

View Source
const MaxPluginSize = 64 << 20

MaxPluginSize bounds a plugin jar; real ones are a few MiB.

View Source
const MaxSize = 512 << 20

MaxSize bounds an artifact; real server jars are under 100 MiB.

Variables

View Source
var (
	// ErrChecksumMismatch is returned when a download does not match the
	// checksum upstream published; the file is discarded.
	ErrChecksumMismatch = errors.New("the download does not match its published checksum")
	// ErrDownload is returned when a publisher's download fails.
	ErrDownload = errors.New("the download failed")
	// ErrTooLarge is returned for an artifact over its size limit.
	ErrTooLarge = errors.New("the artifact is too large")
)
View Source
var ErrNotPlugin = pluginjar.ErrNotPlugin

ErrNotPlugin is returned for an upload that is not a plugin jar.

Functions

This section is empty.

Types

type Cache

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

Cache is the artifact cache.

func New

func New(dir string, st *store.Store, cat *catalog.Catalog, logger *slog.Logger) (*Cache, error)

New opens the cache in dir, creating it.

func (*Cache) Ensure

func (c *Cache) Ensure(ctx context.Context, b catalog.Build) (domain.Artifact, error)

Ensure returns the cached artifact for an upstream build, downloading and verifying it first if needed.

func (*Cache) EnsurePlugin added in v1.14.0

func (c *Cache) EnsurePlugin(ctx context.Context, d PluginDownload) (domain.PluginArtifact, error)

EnsurePlugin returns the cached jar of a catalog plugin version, downloading it from its publisher and verifying it against the catalog's checksum and size first if needed.

func (*Cache) Open

func (c *Cache) Open(ctx context.Context, id uuid.UUID) (io.ReadCloser, domain.Artifact, error)

Open returns an artifact's file.

func (*Cache) OpenPlugin added in v1.14.0

func (c *Cache) OpenPlugin(ctx context.Context, id uuid.UUID) (io.ReadCloser, domain.PluginArtifact, error)

OpenPlugin returns a plugin jar's file.

func (*Cache) Upload

func (c *Cache) Upload(ctx context.Context, a domain.Artifact, r io.Reader) (domain.Artifact, error)

Upload stores an artifact an administrator supplied. It is unverified: nothing upstream vouches for it.

func (*Cache) UploadPlugin added in v1.14.0

func (c *Cache) UploadPlugin(ctx context.Context, fileName string, r io.Reader, by *uuid.UUID) (domain.PluginArtifact, pluginjar.Info, error)

UploadPlugin stores a plugin jar a user supplied, after checking that it declares a plugin. It is unverified: nothing vouches for it.

type PluginDownload added in v1.14.0

type PluginDownload struct {
	PluginID  string
	VersionID string
	Version   string
	URL       string
	FileName  string
	// Size is zero when the publisher does not state it.
	Size      int64
	Checksums []format.Checksum
}

PluginDownload is a catalog plugin version to cache.

Jump to

Keyboard shortcuts

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