commonres

package
v0.0.0-...-96163db Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CastResourceToStorageResource

func CastResourceToStorageResource(r Resource, v uint64) storage.Resource

CastResourceToStorageResource creates a new storage.Resource for the given resource associated to the given version.

func CloneResourceRepo

func CloneResourceRepo(ctx context.Context, res, clone Resource) (vcs.VCS, *gz.ErrMsg)

CloneResourceRepo clones the VCS repository of a given resource. Returns the VCS respository of the clone.

func CreateResourceRepo

func CreateResourceRepo(ctx context.Context, res Resource, filesPath string) (vcs.VCS, *gz.ErrMsg)

CreateResourceRepo creates the VCS repository for a given resource Returns the created VCS repository.

func DownloadZipFile

func DownloadZipFile(ctx context.Context, resource Resource, kind string, version int) (string, error)

DownloadZipFile allows to serve a file directly, it returns the path to the zip file from the EFS drive. This method was added for backward compatibility with fuel clients that don't support redirects nor links to cloud providers.

func FileTree

func FileTree(ctx context.Context, res Resource, version string) (*fuel.FileTree, *gz.ErrMsg)

FileTree gets a the file tree of a versioned resource.

func GetFile

func GetFile(ctx context.Context, res Resource, path, version string) (*[]byte, int, *gz.ErrMsg)

GetFile returns the contents (bytes) of a resource file. Given version is considered. Returns the file's bytes and the resolved version of the resource.

func GetLatestVersion

func GetLatestVersion(ctx context.Context, res Resource) (int, error)

GetLatestVersion gets the latest version number of a file based resource.

func GetRevisionFromVersion

func GetRevisionFromVersion(ctx context.Context, res Resource,
	version string) (string, int, *gz.ErrMsg)

GetRevisionFromVersion finds the revision hash from a given resource version. Version 1 is the initial version of the resource when the repo was created or cloned. Returns the found revision, the resolved version or an error.

func GetThumbnails

func GetThumbnails(res Resource) (tbns []string, err error)

GetThumbnails returns a slice of urls pointing to the thumbnails.

func GetZip

func GetZip(ctx context.Context, res Resource, subfolder string, version string) (*string, int, *gz.ErrMsg)

GetZip returns a path to the existing resource zip for the given version. It creates the zip if it does not exist. subfolder arg is the resource type folder for the user (eg. models, worlds)

func MoveResource

func MoveResource(resource Resource, destOwner string) *gz.ErrMsg

MoveResource will move a resource's on-disk location from sourceOwner to destOwner.

func QueryForResourceVisibility

func QueryForResourceVisibility(tx, q *gorm.DB, owner *string, user *users.User) *gorm.DB

QueryForResourceVisibility checks the relationship between requestor (user) and the resource owner to formulate a database query to determine whether a resource is visible to the user

func Remove

func Remove(tx *gorm.DB, res Resource, user string) *gz.ErrMsg

Remove removes a resource. The user argument is the requesting user. It is used to check if the user can perform the operation.

func ZipResourceTip

func ZipResourceTip(ctx context.Context, repo vcs.VCS, res Resource, subfolder string) (int64, string, *gz.ErrMsg)

ZipResourceTip creates a new zip file for the given resource. Returns the zip Filesize and the path to the given zip file or an error. subfolder arg is the resource type folder for the user (eg. models, worlds)

Types

type GetZipResource

type GetZipResource func(ctx context.Context, resource Resource, kind string, version int) (string, error)

GetZipResource defines a function that allows getting a zip file from a local or remote location.

func GetZipLink(storage storage.Storage) GetZipResource

GetZipLink allows to get the link to a zip file.

type Metadata

type Metadata []Metadatum

Metadata is an array of Metadatum

swagger:model

type Metadatum

type Metadatum struct {
	// Key is the string containing the metadata key value.
	Key *string `json:"key,omitempty"`

	// Value is the string containing the metadata value associated with the key.
	Value *string `json:"value,omitempty"`
}

Metadatum contains a key-value pair for a resources.

swagger:model dbModel

func (Metadatum) IsEmpty

func (mm Metadatum) IsEmpty() bool

IsEmpty returns true if the Metadatum has no key and value.

type Resource

type Resource interface {
	GetName() *string
	GetOwner() *string
	SetOwner(owner string)
	GetLocation() *string
	SetLocation(location string)
	GetUUID() *string
}

Resource represents a resource with files (eg. model, world)

Jump to

Keyboard shortcuts

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