Documentation
¶
Index ¶
- Constants
- Variables
- func GetBundlePartitionFileKey(filename, dirname string) mapstore.FileKey
- func SanitizeBundleID(id BundleID) string
- func ValidateBundleSlug(s BundleSlug) error
- func ValidateItemSlug(s ItemSlug) error
- func ValidateItemVersion(v ItemVersion) error
- func ValidateTag(tag string) error
- func ValidateTags(tags []string) error
- type BundleDirInfo
- type BundleID
- type BundlePartitionProvider
- type BundleSlug
- type FileInfo
- type ItemID
- type ItemSlug
- type ItemVersion
Constants ¶
const ItemFileExtension = "json"
Variables ¶
Functions ¶
func SanitizeBundleID ¶
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 ValidateItemVersion ¶
func ValidateItemVersion(v ItemVersion) error
func ValidateTag ¶
ValidateTag checks a single tag for format and length.
func ValidateTags ¶
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 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 ¶
ParseItemFileName parses a item filename into slug and version. Uses the last underscore as delimiter.
type ItemVersion ¶
type ItemVersion string