Documentation
¶
Index ¶
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func MustAsset(name string) []byte
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func ValidateTemplate(in []byte) error
- type CachedRegistry
- type ErrInvalidTemplate
- type GithubRegistry
- func (r *GithubRegistry) Fetch() error
- func (r *GithubRegistry) Find(templateName string) (*RegistryTemplate, error)
- func (r *GithubRegistry) IsCacheObsolete() (bool, error)
- func (r *GithubRegistry) LoadRaw(templateName string) ([]byte, error)
- func (r *GithubRegistry) LocateURI(name string) string
- func (r *GithubRegistry) String() string
- func (r *GithubRegistry) ValidateCache() bool
- type LocalRegistry
- type RegistryTemplate
- type RemoteRegistry
- type TemplateFinder
- type TemplateRoot
Constants ¶
This section is empty.
Variables ¶
var ( ErrLocalCacheNotReady = errors.New("Resource template registry has not been cached yet") ErrUnknownTemplateName = errors.New("Unknown template name") )
var GithubDefaultRef = "master"
Buildtime constant
Functions ¶
func Asset ¶
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 ¶
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 ¶
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 MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
func ValidateTemplate ¶
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 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