registry

package
v0.0.0-...-88bc37c Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLocalCacheNotReady  = errors.New("Resource template registry has not been cached yet")
	ErrUnknownTemplateName = errors.New("Unknown template name")
)
View Source
var GithubDefaultRef = "master"

Buildtime constant

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func ValidateTemplate

func ValidateTemplate(in []byte) error

Types

type CachedRegistry

type CachedRegistry interface {
	TemplateFinder
	ValidateCache() bool
	IsCacheObsolete() (bool, error)
	Fetch() error
}

type ErrInvalidTemplate

type ErrInvalidTemplate struct {
	Errors []gojsonschema.ResultError
}

func (*ErrInvalidTemplate) Dump

func (e *ErrInvalidTemplate) Dump(out io.Writer)

func (*ErrInvalidTemplate) Error

func (e *ErrInvalidTemplate) Error() string

type GithubRegistry

type GithubRegistry struct {
	Branch                  string
	RepoSlug                string
	TreePath                string
	ForceCheckToRemoteAfter time.Duration
	FetchRetry              int
	// contains filtered or unexported fields
}

func NewGithubRegistry

func NewGithubRegistry(confDir string) *GithubRegistry

func (*GithubRegistry) Fetch

func (r *GithubRegistry) Fetch() error

Fetch download and extract the remote image registry to local folder.

func (*GithubRegistry) Find

func (r *GithubRegistry) Find(templateName string) (*RegistryTemplate, error)

Find queries resource template details from local registry cache.

func (*GithubRegistry) IsCacheObsolete

func (r *GithubRegistry) IsCacheObsolete() (bool, error)

IsCacheObsolete consults to the remote machine image registry and checks if the local cache is obsolete.

func (*GithubRegistry) LoadRaw

func (r *GithubRegistry) LoadRaw(templateName string) ([]byte, error)

func (*GithubRegistry) LocateURI

func (r *GithubRegistry) LocateURI(name string) string

func (*GithubRegistry) String

func (r *GithubRegistry) String() string

func (*GithubRegistry) ValidateCache

func (r *GithubRegistry) ValidateCache() bool

ValidateCache validates the local cache folder items.

type LocalRegistry

type LocalRegistry struct {
}

Handle resource template file locates on the local system.

func NewLocalRegistry

func NewLocalRegistry() *LocalRegistry

func (*LocalRegistry) Find

func (r *LocalRegistry) Find(templateName string) (*RegistryTemplate, error)

func (*LocalRegistry) LoadRaw

func (r *LocalRegistry) LoadRaw(templateName string) ([]byte, error)

func (*LocalRegistry) LocateURI

func (r *LocalRegistry) LocateURI(name string) string

type RegistryTemplate

type RegistryTemplate struct {
	Name     string
	Template *TemplateRoot
	// contains filtered or unexported fields
}

func (*RegistryTemplate) LocationURI

func (r *RegistryTemplate) LocationURI() string

Returns absolute URI for the original location of the resource template.

func (*RegistryTemplate) ToModel

func (r *RegistryTemplate) ToModel() *model.Template

type RemoteRegistry

type RemoteRegistry struct {
	FetchRetry int
}

Handle resource template represented by URI and locates on the remote system.

func NewRemoteRegistry

func NewRemoteRegistry() *RemoteRegistry

func (*RemoteRegistry) Find

func (r *RemoteRegistry) Find(templateName string) (*RegistryTemplate, error)

func (*RemoteRegistry) LoadRaw

func (r *RemoteRegistry) LoadRaw(templateName string) ([]byte, error)

func (*RemoteRegistry) LocateURI

func (r *RemoteRegistry) LocateURI(name string) string

type TemplateFinder

type TemplateFinder interface {
	Find(templateName string) (*RegistryTemplate, error)
	LocateURI(templateName string) string
	LoadRaw(templateName string) ([]byte, error)
}

type TemplateRoot

type TemplateRoot struct {
	Title       string `json:"title`
	Description string `json:"description,omitempty"`

	// "template" block is delayed to parse.
	// https://golang.org/pkg/encoding/json/#RawMessage
	RawTemplate json.RawMessage        `json:"template"`
	Template    model.ResourceTemplate `json:"-"`
	// contains filtered or unexported fields
}

func (*TemplateRoot) ResourceHandler

func (t *TemplateRoot) ResourceHandler() handlers.ResourceHandler

Jump to

Keyboard shortcuts

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