release

package
v0.0.0-...-6885dbb Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2018 License: BSD-3-Clause Imports: 6 Imported by: 5

Documentation

Index

Constants

View Source
const PathDepthLimit = 2

PathDepthLimit specifies how many nested directories are searched for resources.

Variables

This section is empty.

Functions

This section is empty.

Types

type Release

type Release interface {
	// HasResource returns true for a unique resource name if the release contains this resource.
	HasResource(name string) bool
	// GetResource returns the resource identified by given name if existing, or an error otherwise.
	GetResource(name string) (Resource, error)
	// NewResource creates a new resource under given path and returns the instance, or an error on failure.
	NewResource(name string, path string) (Resource, error)
}

Release wraps a set of unique resources that together make up one release.

func FromAbsolutePaths

func FromAbsolutePaths(paths []string) (release Release, err error)

FromAbsolutePaths returns a Release that provides resources exclusively from the provided paths.

func NewMemoryRelease

func NewMemoryRelease() Release

NewMemoryRelease returns a Release instance that keeps all resources and their data in memory.

func ReleaseFromDir

func ReleaseFromDir(path string) (release Release, err error)

ReleaseFromDir returns a release instance if the given path specifies an existing directory.

type ReleaseContainer

type ReleaseContainer interface {
	// Names returns the list of currently known releases.
	Names() []string
	// Get returns the release with given name, or an error if not possible.
	Get(name string) (Release, error)
	// New creates a new release with given name and returns it, or an error if not possible.
	New(name string) (Release, error)
}

ReleaseContainer can contain any number of releases and provides access to them.

func NewContainerFromDir

func NewContainerFromDir(path string) (container ReleaseContainer, err error)

NewContainerFromDir returns a release container for given file path. An error is returned if the specified directory doesn't exist or any other problem occurred.

func NewMemoryReleaseContainer

func NewMemoryReleaseContainer() ReleaseContainer

NewMemoryReleaseContainer returns a ReleaseContainer for releases only in memory.

func NewStaticReleaseContainer

func NewStaticReleaseContainer(releases map[string]Release) ReleaseContainer

NewStaticReleaseContainer returns a new instance of a ReleaseContainer.

type Resource

type Resource interface {
	// Name returns the unique identifier - the file name of the resource.
	Name() string
	// Path returns the (relative) path for the resource, based on the release's root.
	Path() string
	// AsSource returns an interface for reading the resource.
	AsSource() (serial.SeekingReadCloser, error)
	// AsSink returns an interface for writing the resource.
	AsSink() (serial.SeekingWriteCloser, error)
}

Resource describes one resource file.

func NewMemoryResource

func NewMemoryResource(name string, path string, data []byte) Resource

type StaticReleaseContainer

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

StaticReleaseContainer is not capable of creating new releases. It provides only the initially registered releases.

func (*StaticReleaseContainer) Get

func (container *StaticReleaseContainer) Get(name string) (rel Release, err error)

Get implements the ReleaseContainer interface

func (*StaticReleaseContainer) Names

func (container *StaticReleaseContainer) Names() []string

Names implements the ReleaseContainer interface

func (*StaticReleaseContainer) New

func (container *StaticReleaseContainer) New(name string) (Release, error)

New implements the ReleaseContainer interface

Jump to

Keyboard shortcuts

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