Documentation
¶
Overview ¶
Package artifact stores and serves the SHA-pinned repository tarballs that source-controller produces and agent jobs fetch. Paths embed a 128-bit random id, so a URL is unguessable by other workloads that can reach the serving port; the fetching init container verifies the sha256 digest end-to-end. The store is in-memory-indexed over plain files — artifacts are reproducible (a restart just re-fetches), so no durable index exists.
Index ¶
- Variables
- type Client
- type Info
- type Store
- func (s *Store) Delete(key string)
- func (s *Store) Get(key string) (*Info, bool)
- func (s *Store) Handler() http.Handler
- func (s *Store) InternalHandler(token string, maxBytes int64) http.Handler
- func (s *Store) Put(key string, r io.Reader) (*Info, error)
- func (s *Store) PutBlob(digest string, r io.Reader, maxBytes int64) (bool, error)
- func (s *Store) StatBlob(digest string) (int64, bool)
- func (s *Store) SweepBlobs(before time.Time) int
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDigestMismatch: the uploaded bytes do not hash to the digest they // were uploaded under. ErrDigestMismatch = errors.New("artifact: digest mismatch") // ErrBlobTooLarge: the upload exceeded the configured cap. ErrBlobTooLarge = errors.New("artifact: blob too large") )
Blob errors the upload API maps onto HTTP statuses.
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v0.9.3
type Client struct {
// BaseURL of the internal endpoint, e.g.
// http://patchy-source-controller.patchy.svc.cluster.local:9791.
BaseURL string
// Token is the optional shared bearer token.
Token string
// HTTPClient defaults to http.DefaultClient.
HTTPClient *http.Client
}
Client talks to the store's internal blob endpoint (PUT|HEAD /internal/blobs/{digest}) from another process — evaluation-controller checking a workspace before launch or streaming an upload through to the cache.
type Info ¶
type Info struct {
// URL the artifact is served at.
URL string
// Digest is the hex sha256 of the tarball.
Digest string
// Size in bytes.
Size int64
}
Info describes one stored artifact.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store keeps artifacts on disk keyed by owner name (the Repository object's namespaced name) and serves them over HTTP.
func NewStore ¶
NewStore builds a Store rooted at dir, minting URLs under baseURL (the cluster-internal address agents reach, e.g. http://patchy-source-controller.patchy.svc:9790).
func (*Store) Handler ¶
Handler serves GET /artifacts/<id>.tar.gz: 32-hex ids are repository tarballs, 64-hex ids are content-addressed workspace blobs.
func (*Store) InternalHandler ¶ added in v0.9.3
InternalHandler serves the NetworkPolicy-gated upload endpoint evaluation-controller streams workspace bundles to:
HEAD /internal/blobs/{digest} → 204 cached / 404
PUT /internal/blobs/{digest} → 201 created / 200 already cached /
422 digest mismatch / 413 too large
A non-empty token requires Authorization: Bearer <token> (constant-time compared) as defense-in-depth atop the NetworkPolicy; maxBytes caps uploads (0 = unbounded).
func (*Store) Put ¶
Put stores the tarball read from r under the owner key, replacing any previous artifact for that key, and returns its serving info.
func (*Store) PutBlob ¶ added in v0.9.3
PutBlob stores the tarball read from r under its sha256 digest, idempotently: a digest already present is not re-read. The stream is hashed while writing and discarded on mismatch (ErrDigestMismatch) or when it exceeds maxBytes (ErrBlobTooLarge; 0 means unbounded). Returns whether the blob was newly created.