Merge pull request #3095 from drone/defect/template-not-found-handling
handle error properly if template doesn't exist in the db
This commit is contained in:
commit
5c2aedc694
1 changed files with 5 additions and 4 deletions
|
@ -18,6 +18,7 @@ package converter
|
|||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
@ -63,12 +64,12 @@ func (p *templatePlugin) Convert(ctx context.Context, req *core.ConvertArgs) (*c
|
|||
}
|
||||
// get template from db
|
||||
template, err := p.templateStore.FindName(ctx, templateArgs.Load, req.Repo.Namespace)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
if template == nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, ErrTemplateNotFound
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Check if file is of type Starlark
|
||||
if strings.HasSuffix(templateArgs.Load, ".script") ||
|
||||
strings.HasSuffix(templateArgs.Load, ".star") ||
|
||||
|
|
Loading…
Reference in a new issue