Skip to content

Use shared artifacts at cache boundaries - #267

Draft
andrew wants to merge 2 commits into
mainfrom
artifacts-adoption
Draft

Use shared artifacts at cache boundaries#267
andrew wants to merge 2 commits into
mainfrom
artifacts-adoption

Conversation

@andrew

@andrew andrew commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Uses artifacts.Artifact for cached and newly stored package files. Cache rows are converted and validated at the database boundary while the stored hexadecimal SHA-256 remains unchanged. Response ETags and cache verification continue using the encoded digest, and mirror accounting reads shared size metadata.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes cached and newly stored package file metadata by representing artifacts with a shared artifacts.Artifact type at cache boundaries, while keeping the stored SHA-256 hex digest format unchanged for ETags and verification.

Changes:

  • Refactors CacheResult to carry an artifacts.Artifact (digest/size/filename/media type) instead of separate fields, updating serving and mirroring logic accordingly.
  • Validates and converts cached artifact database rows into artifacts.Artifact at the database boundary (GetCachedArtifact).
  • Updates tests and adds coverage for malformed cached metadata and malformed storage digests; adds new module dependencies.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/mirror/mirror.go Uses shared artifact size metadata for mirror accounting.
internal/handler/handler.go Moves cache/fetch paths to artifacts.Artifact for size/ETag/media type and DB updates.
internal/handler/handler_test.go Updates tests to assert artifact metadata and adds malformed-metadata cases.
internal/handler/download_test.go Updates seeded cached artifact hashes to use encoded digest.
internal/handler/container_test.go Updates ETag assertions to use encoded digest.
internal/database/types.go Changes cached-artifact shape to embed artifacts.Artifact.
internal/database/queries.go Converts/validates cached artifact rows into artifacts.Artifact.
internal/database/database_test.go Updates cached-artifact tests and adds row conversion/validation unit tests.
go.mod Adds github.com/git-pkgs/artifacts and github.com/opencontainers/go-digest.
go.sum Adds checksums for the new dependencies.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +229 to +234
if !row.ContentHash.Valid || row.ContentHash.String == "" {
return nil, fmt.Errorf("cached artifact content hash is missing")
}
if !row.Size.Valid {
return nil, fmt.Errorf("cached artifact size is missing")
}
Comment thread internal/mirror/mirror.go
Comment on lines +223 to 224
tracker.bytes.Add(result.Artifact.Size)
m.logger.Info("mirrored",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants