parent
17dd27fe21
commit
2f4cfcd25d
|
@ -2,6 +2,19 @@ package registry
|
|||
|
||||
import "fmt"
|
||||
|
||||
type ErrTemplateExists struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
func (e ErrTemplateExists) Error() string {
|
||||
return fmt.Sprintf("template %s already exists", e.Name)
|
||||
}
|
||||
|
||||
func IsErrTemplateExists(err error) bool {
|
||||
_, ok := err.(ErrTemplateExists)
|
||||
return ok
|
||||
}
|
||||
|
||||
type ErrTemplateNotFound struct {
|
||||
Name string
|
||||
}
|
||||
|
|
|
@ -50,6 +50,10 @@ func (r *Registry) GetTemplate(name string) (*Template, error) {
|
|||
|
||||
// DownloadTemplate downloads and adds a new Template to the Registry
|
||||
func (r *Registry) DownloadTemplate(name, repo, branch string) (*Template, error) {
|
||||
if _, err := r.GetTemplate(name); err == nil {
|
||||
return nil, ErrTemplateExists{Name: name}
|
||||
}
|
||||
|
||||
t := &Template{
|
||||
reg: r,
|
||||
Name: name,
|
||||
|
@ -68,6 +72,10 @@ func (r *Registry) DownloadTemplate(name, repo, branch string) (*Template, error
|
|||
|
||||
// SaveTemplate saves a local Template to the Registry
|
||||
func (r *Registry) SaveTemplate(name, path string) (*Template, error) {
|
||||
if _, err := r.GetTemplate(name); err == nil {
|
||||
return nil, ErrTemplateExists{Name: name}
|
||||
}
|
||||
|
||||
t := &Template{
|
||||
reg: r,
|
||||
Name: name,
|
||||
|
|
Loading…
Reference in New Issue