bundleitemutils

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ItemFileExtension = "json"

Variables

View Source
var (
	ErrInvalidSlug     = errors.New("invalid slug")
	ErrInvalidVersion  = errors.New("invalid version")
	ErrInvalidFilename = errors.New("invalid filename")

	ErrBundleAttributeMissing = errors.New("missing bundle partition attribute")
)

Functions

func GetBundlePartitionFileKey

func GetBundlePartitionFileKey(filename, dirname string) mapstore.FileKey

func SanitizeBundleID

func SanitizeBundleID(id BundleID) string

SanitizeBundleID removes all characters from id except [a-zA-Z0-9-_]. If the result is empty, returns "x".

func ValidateBundleSlug

func ValidateBundleSlug(s BundleSlug) error

func ValidateItemSlug

func ValidateItemSlug(s ItemSlug) error

func ValidateItemVersion

func ValidateItemVersion(v ItemVersion) error

func ValidateTag

func ValidateTag(tag string) error

ValidateTag checks a single tag for format and length.

func ValidateTags

func ValidateTags(tags []string) error

ValidateTags checks a slice of tags for format, length, and duplicates.

Types

type BundleDirInfo

type BundleDirInfo struct {
	ID      BundleID
	Slug    BundleSlug
	DirName string
}

BundleDirInfo holds information about a bundle directory.

func BuildBundleDir

func BuildBundleDir(id BundleID, slug BundleSlug) (BundleDirInfo, error)

BuildBundleDir returns a BundleDirInfo with a directory name safe for all filesystems. The directory name is "<sanitizedID>_<slug>".

func ParseBundleDir

func ParseBundleDir(dir string) (BundleDirInfo, error)

ParseBundleDir parses a bundle directory name into its ID and slug parts. Splits on the first underscore.

type BundleID

type BundleID string

type BundlePartitionProvider

type BundlePartitionProvider struct{}

BundlePartitionProvider implements mapstore.PartitionProvider for bundle directories.

func (*BundlePartitionProvider) GetPartitionDir

func (b *BundlePartitionProvider) GetPartitionDir(key mapstore.FileKey) (string, error)

GetPartitionDir returns the partition directory for a given file key. The directory is provided via the XAttr field.

func (*BundlePartitionProvider) ListPartitions

func (b *BundlePartitionProvider) ListPartitions(
	baseDir, sortOrder, pageToken string,
	pageSize int,
) (dirs []string, nextPageToken string, err error)

ListPartitions lists all bundle directories under baseDir.

type BundleSlug

type BundleSlug string

type FileInfo

type FileInfo struct {
	Slug     ItemSlug
	Version  ItemVersion
	FileName string
}

FileInfo holds information about a item file.

func BuildItemFileInfo

func BuildItemFileInfo(slug ItemSlug, version ItemVersion) (FileInfo, error)

BuildItemFileInfo returns the canonical filename for a (slug, version) pair. Both slug and version must be validated before calling. The filename is "<url-escaped-slug>_<url-escaped-version>.json".

func ParseItemFileName

func ParseItemFileName(fn string) (FileInfo, error)

ParseItemFileName parses a item filename into slug and version. Uses the last underscore as delimiter.

type ItemID

type ItemID string

type ItemSlug

type ItemSlug string

type ItemVersion

type ItemVersion string

Jump to

Keyboard shortcuts

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