store

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package store provides MySQL-backed metadata storage. Object storage remains the source of truth.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blob

type Blob struct {
	Digest    string `json:"digest"`
	Size      int64  `json:"size"`
	MediaType string `json:"mediaType"`
	RefCount  int    `json:"refCount"`
}

Blob represents a content-addressable blob row in the database.

type DashboardStats

type DashboardStats struct {
	RepositoryCount int   `json:"repositoryCount"`
	TagCount        int   `json:"tagCount"`
	BlobCount       int   `json:"blobCount"`
	TotalSize       int64 `json:"totalSize"`
}

DashboardStats holds aggregate counts for the web UI dashboard.

type PlatformSize added in v0.1.7

type PlatformSize struct {
	Digest     string `json:"digest"`
	Size       int64  `json:"size"`
	LayerCount int    `json:"layerCount"`
}

PlatformSize stores per-platform size and layer count for image indexes.

type PlatformSizes added in v0.1.7

type PlatformSizes []PlatformSize

PlatformSizes round-trips through a MySQL JSON column; empty persists as NULL.

func (*PlatformSizes) Scan added in v0.1.7

func (p *PlatformSizes) Scan(src any) error

Scan unmarshals JSON from a MySQL column into PlatformSizes.

func (PlatformSizes) Value added in v0.1.7

func (p PlatformSizes) Value() (driver.Value, error)

Value marshals PlatformSizes to JSON for MySQL storage.

type Repository

type Repository struct {
	ID           int64     `json:"id"`
	Name         string    `json:"name"`
	TagCount     int       `json:"tagCount"`
	TotalSize    int64     `json:"totalSize"`
	ArtifactType string    `json:"artifactType,omitempty"`
	Kind         string    `json:"kind,omitempty"`
	CreatedAt    time.Time `json:"createdAt"`
	UpdatedAt    time.Time `json:"updatedAt"`
}

Repository represents a repository row with aggregated tag stats.

type Store

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

Store provides MySQL-backed metadata queries and token management.

func New

func New(ctx context.Context, dsn string) (*Store, error)

New opens a MySQL connection, runs migrations, and returns a ready Store.

func (*Store) Close

func (s *Store) Close() error

Close shuts down the database connection pool.

func (*Store) CreateToken

func (s *Store) CreateToken(ctx context.Context, name, createdBy string) (string, error)

CreateToken generates a random token, stores its hash, and returns the plaintext.

func (*Store) DeleteTag

func (s *Store) DeleteTag(ctx context.Context, repoName, tagName string) error

DeleteTag removes a tag from the database by repository name and tag name.

func (*Store) DeleteToken

func (s *Store) DeleteToken(ctx context.Context, id int64) error

DeleteToken removes a token by ID and invalidates the cache.

func (*Store) GetRepository

func (s *Store) GetRepository(ctx context.Context, name string) (*Repository, error)

GetRepository returns a single repository by name, or nil if not found.

func (*Store) GetStats

func (s *Store) GetStats(ctx context.Context) (*DashboardStats, error)

GetStats returns aggregate counts for the dashboard.

func (*Store) GetTag

func (s *Store) GetTag(ctx context.Context, repoName, tagName string) (*Tag, error)

GetTag returns a single tag with full details, or nil if not found.

func (*Store) InvalidateTokenCache added in v0.1.7

func (s *Store) InvalidateTokenCache()

InvalidateTokenCache clears all cached token validation results.

func (*Store) ListRepositories

func (s *Store) ListRepositories(ctx context.Context) ([]Repository, error)

ListRepositories returns all repositories ordered by last update.

func (*Store) ListTags

func (s *Store) ListTags(ctx context.Context, repoName string) ([]Tag, error)

ListTags returns all tags for a repository ordered by push time.

func (*Store) ListTokens

func (s *Store) ListTokens(ctx context.Context) ([]Token, error)

ListTokens returns all tokens ordered by ID.

func (*Store) SyncFromCatalog

func (s *Store) SyncFromCatalog(ctx context.Context, reg *registry.Registry) error

SyncFromCatalog ingests catalog entries into MySQL. Per-tag failures are non-fatal.

func (*Store) ValidateToken

func (s *Store) ValidateToken(ctx context.Context, plaintext string) bool

ValidateToken checks whether a plaintext token is valid, using a cache.

type Tag

type Tag struct {
	ID            int64         `json:"id"`
	RepositoryID  int64         `json:"-"`
	RepoName      string        `json:"repoName,omitempty"`
	Name          string        `json:"name"`
	Digest        string        `json:"digest"`
	ArtifactType  string        `json:"artifactType,omitempty"`
	Kind          string        `json:"kind,omitempty"`
	ManifestJSON  string        `json:"-"`
	TotalSize     int64         `json:"totalSize"`
	LayerCount    int           `json:"layerCount"`
	PlatformSizes PlatformSizes `json:"platformSizes,omitempty"`
	PushedAt      time.Time     `json:"pushedAt"`
	SyncedAt      time.Time     `json:"syncedAt"`
}

Tag represents a manifest tag row in the database.

type Token

type Token struct {
	ID        int64      `json:"id"`
	Name      string     `json:"name"`
	Token     string     `json:"token,omitempty"`
	CreatedBy string     `json:"createdBy"`
	CreatedAt time.Time  `json:"createdAt"`
	LastUsed  *time.Time `json:"lastUsed,omitempty"`
}

Token represents an API access token row in the database.

Jump to

Keyboard shortcuts

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