store

package
v0.0.0-...-c1e8334 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2021 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Artist is the tag type artist.
	Artist = "artist"
	// Character is the tag type character.
	Character = "character"
	// Copyright is the tag type copyright.
	Copyright = "copyright"
	// Generic is the tag type generic.
	Generic = "generic"
	// Group is the tag type group.
	Group = "group"
	// Meta is the tag type meta.
	Meta = "meta"
)

Variables

View Source
var (
	// AlreadyExists is returned when store already exists.
	AlreadyExists = errors.New("store path already exists")
)

Functions

This section is empty.

Types

type Image

type Image struct {
	Snowflake string `json:"snowflake"`
	Hash      string `json:"hash"`
	Type      string `json:"type"`
	User      string `json:"user"`
	Source    string `json:"source"`
}

Image represents metadata of an image.

type Info

type Info struct {
	Revision       int         `json:"revision"`
	Compat         bool        `json:"compat"`
	Register       bool        `json:"register"`
	InitialUser    string      `json:"initial_user"`
	PermissionDir  os.FileMode `json:"permission_dir"`
	PermissionFile os.FileMode `json:"permission_file"`
}

Info represents system information of a store.

type Store

type Store struct {
	Path           string
	SingleUser     bool
	Revision       int
	Compat         bool
	Register       bool
	InitialUser    string
	PermissionDir  os.FileMode
	PermissionFile os.FileMode
}

Store represents a file store.

func NewStore

func NewStore(path string, single bool) *Store

NewStore initialises a new store instance.

func (*Store) Image

func (s *Store) Image(hash string) Image

Image returns an image with specific hash.

func (*Store) ImageAdd

func (s *Store) ImageAdd(data []byte, flake string) Image

ImageAdd adds an image to the store.

func (*Store) ImageData

func (s *Store) ImageData(hash string, preview bool) (Image, []byte)

ImageData returns an image and its data with a specific hash.

func (*Store) ImageDestroy

func (s *Store) ImageDestroy(hash string)

ImageDestroy destroys an image.

func (*Store) ImageFilePath

func (s *Store) ImageFilePath(hash string) string

ImageFilePath returns path to an image file with specific hash.

func (*Store) ImageHashSplit

func (s *Store) ImageHashSplit(hash string) string

ImageHashSplit returns split image hash.

func (*Store) ImageMetadataPath

func (s *Store) ImageMetadataPath(hash string) string

ImageMetadataPath returns path to an image's metadata file with specific hash.

func (*Store) ImageMetadataRead

func (s *Store) ImageMetadataRead(path string) Image

ImageMetadataRead reads an image metadata file.

func (*Store) ImagePath

func (s *Store) ImagePath(hash string) string

ImagePath returns path to an image with specific hash.

func (*Store) ImagePreviewFilePath

func (s *Store) ImagePreviewFilePath(hash string) string

ImagePreviewFilePath returns path to an image preview file with specific hash.

func (*Store) ImageSnowflake

func (s *Store) ImageSnowflake(flake string) Image

ImageSnowflake returns image that has specific snowflake.

func (*Store) ImageSnowflakeHash

func (s *Store) ImageSnowflakeHash(flake string) string

ImageSnowflakeHash returns image hash from snowflake.

func (*Store) ImageSnowflakePath

func (s *Store) ImageSnowflakePath(flake string) string

ImageSnowflakePath returns path to an image with specific snowflake.

func (*Store) ImageSnowflakes

func (s *Store) ImageSnowflakes() []string

ImageSnowflakes returns all snowflakes.

func (*Store) ImageSource

func (s *Store) ImageSource(hash, source string)

ImageSource sets image source URL.

func (*Store) ImageTagAdd

func (s *Store) ImageTagAdd(hash, tag string)

ImageTagAdd adds a tag to an image with specific hash.

func (*Store) ImageTagRemove

func (s *Store) ImageTagRemove(hash, tag string)

ImageTagRemove removes a tag from an image with specific hash.

func (*Store) ImageTags

func (s *Store) ImageTags(hash string) []string

ImageTags returns tags of an image with specific hash.

func (*Store) ImageTagsPath

func (s *Store) ImageTagsPath(hash string) string

ImageTagsPath returns path to an image's tags with specific hash.

func (*Store) Images

func (s *Store) Images() []string

Images returns a list of images.

func (*Store) ImagesDir

func (s *Store) ImagesDir() string

ImagesDir returns path to images.

func (*Store) ImagesSnowflakeDir

func (s *Store) ImagesSnowflakeDir() string

ImagesSnowflakeDir returns path to image snowflakes.

func (*Store) SecretAssociate

func (s *Store) SecretAssociate(secret, flake string)

SecretAssociate associates a secret with a user.

func (*Store) SecretDisassociate

func (s *Store) SecretDisassociate(secret string)

SecretDisassociate disassociates a secret.

func (*Store) SecretLookup

func (s *Store) SecretLookup(secret string) User

SecretLookup looks up an user from a secret.

func (*Store) SecretNew

func (s *Store) SecretNew() string

SecretNew generates a new user secret.

func (*Store) SecretPath

func (s *Store) SecretPath(secret string) string

SecretPath returns path to tokens.

func (*Store) SecretsDir

func (s *Store) SecretsDir() string

SecretsDir returns path to tokens.

func (*Store) Tag

func (s *Store) Tag(tag string) []string

Tag returns a list of image hashes in a specific tag.

func (*Store) TagCreate

func (s *Store) TagCreate(tag string) bool

TagCreate creates a tag and returns ok value.

func (*Store) TagDestroy

func (s *Store) TagDestroy(tag string)

TagDestroy removes all references from a tag and removes it.

func (*Store) TagInfo

func (s *Store) TagInfo(tag string) Tag

TagInfo returns information of a tag.

func (*Store) TagMetadataPath

func (s *Store) TagMetadataPath(tag string) string

TagMetadataPath returns path to a specific tag's metadata file.

func (*Store) TagPath

func (s *Store) TagPath(tag string) string

TagPath returns path to a specific tag.

func (*Store) TagType

func (s *Store) TagType(tag, t string)

TagType sets type of a tag.

func (*Store) Tags

func (s *Store) Tags() []string

Tags returns a slice of tag names.

func (*Store) TagsDir

func (s *Store) TagsDir() string

TagsDir returns path to tags.

func (*Store) User

func (s *Store) User(flake string) User

User returns user information with specific snowflake.

func (*Store) UserAdd

func (s *Store) UserAdd(username string, privileged bool) User

UserAdd creates a user.

func (*Store) UserDestroy

func (s *Store) UserDestroy(flake string)

UserDestroy destroys a user with specific snowflake.

func (*Store) UserImages

func (s *Store) UserImages(flake string) []string

UserImages returns slice of a user's images.

func (*Store) UserImagesPath

func (s *Store) UserImagesPath(flake string) string

UserImagesPath returns path to a user's images with specific snowflake.

func (*Store) UserMetadata

func (s *Store) UserMetadata(info User)

UserMetadata sets user metadata.

func (*Store) UserMetadataPath

func (s *Store) UserMetadataPath(flake string) string

UserMetadataPath returns path to a user's metadata file with specific snowflake.

func (*Store) UserPath

func (s *Store) UserPath(flake string) string

UserPath returns path to a user with specific snowflake.

func (*Store) UserPrivileged

func (s *Store) UserPrivileged(flake string, privileged bool)

UserPrivileged sets privileged status of user with specific snowflake.

func (*Store) UserSecretRegen

func (s *Store) UserSecretRegen(flake string) string

UserSecretRegen regenerates secret of user with specific snowflake.

func (*Store) UserUsername

func (s *Store) UserUsername(flake, username string)

UserUsername sets username of user with specific snowflake.

func (*Store) Users

func (s *Store) Users() []string

Users returns a slice of user snowflakes.

func (*Store) UsersDir

func (s *Store) UsersDir() string

UsersDir returns path to users.

type Tag

type Tag struct {
	Type         string    `json:"type"`
	CreationTime time.Time `json:"creation_time"`
}

Tag represents metadata of a tag.

type User

type User struct {
	Secret     string `json:"secret"`
	Privileged bool   `json:"privileged"`
	Snowflake  string `json:"snowflake"`
	Username   string `json:"username"`
}

User represents metadata of a user.

Jump to

Keyboard shortcuts

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