"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plugin/converter/template.go" between
drone-2.15.0.tar.gz and drone-2.16.0.tar.gz

About: Drone is a Continuous Delivery system built on (docker) container technology.

template.go  (drone-2.15.0):template.go  (drone-2.16.0)
skipping to change at line 44 skipping to change at line 44
) )
var ( var (
// templateFileRE regex to verifying kind is template. // templateFileRE regex to verifying kind is template.
templateFileRE = regexp.MustCompilePOSIX("^kind:[[:space:]]+ template[[:space:]]?+$") templateFileRE = regexp.MustCompilePOSIX("^kind:[[:space:]]+ template[[:space:]]?+$")
errTemplateNotFound = errors.New("template converter: template na me given not found") errTemplateNotFound = errors.New("template converter: template na me given not found")
errTemplateSyntaxErrors = errors.New("template converter: there is a problem with the yaml file provided") errTemplateSyntaxErrors = errors.New("template converter: there is a problem with the yaml file provided")
errTemplateExtensionInvalid = errors.New("template extension invalid. mus t be yaml, starlark or jsonnet") errTemplateExtensionInvalid = errors.New("template extension invalid. mus t be yaml, starlark or jsonnet")
) )
func Template(templateStore core.TemplateStore, stepLimit uint64) core.ConvertSe rvice { func Template(templateStore core.TemplateStore, stepLimit uint64, sizeLimit uint 64) core.ConvertService {
return &templatePlugin{ return &templatePlugin{
templateStore: templateStore, templateStore: templateStore,
stepLimit: stepLimit, stepLimit: stepLimit,
sizeLimit: sizeLimit,
} }
} }
type templatePlugin struct { type templatePlugin struct {
templateStore core.TemplateStore templateStore core.TemplateStore
stepLimit uint64 stepLimit uint64
sizeLimit uint64
} }
func (p *templatePlugin) Convert(ctx context.Context, req *core.ConvertArgs) (*c ore.Config, error) { func (p *templatePlugin) Convert(ctx context.Context, req *core.ConvertArgs) (*c ore.Config, error) {
// check type is yaml // check type is yaml
configExt := filepath.Ext(req.Repo.Config) configExt := filepath.Ext(req.Repo.Config)
if configExt != ".yml" && configExt != ".yaml" { if configExt != ".yml" && configExt != ".yaml" {
return nil, nil return nil, nil
} }
skipping to change at line 87 skipping to change at line 89
return nil, errTemplateNotFound return nil, errTemplateNotFound
} }
if err != nil { if err != nil {
return nil, err return nil, err
} }
switch filepath.Ext(templateArgs.Load) { switch filepath.Ext(templateArgs.Load) {
case ".yml", ".yaml": case ".yml", ".yaml":
return parseYaml(req, template, templateArgs) return parseYaml(req, template, templateArgs)
case ".star", ".starlark", ".script": case ".star", ".starlark", ".script":
return parseStarlark(req, template, templateArgs, p.stepLimit) return parseStarlark(req, template, templateArgs, p.stepLimit, p. sizeLimit)
case ".jsonnet": case ".jsonnet":
return parseJsonnet(req, template, templateArgs) return parseJsonnet(req, template, templateArgs)
default: default:
return nil, errTemplateExtensionInvalid return nil, errTemplateExtensionInvalid
} }
} }
func parseYaml(req *core.ConvertArgs, template *core.Template, templateArgs core .TemplateArgs) (*core.Config, error) { func parseYaml(req *core.ConvertArgs, template *core.Template, templateArgs core .TemplateArgs) (*core.Config, error) {
data := map[string]interface{}{ data := map[string]interface{}{
"build": toBuild(req.Build), "build": toBuild(req.Build),
skipping to change at line 125 skipping to change at line 127
func parseJsonnet(req *core.ConvertArgs, template *core.Template, templateArgs c ore.TemplateArgs) (*core.Config, error) { func parseJsonnet(req *core.ConvertArgs, template *core.Template, templateArgs c ore.TemplateArgs) (*core.Config, error) {
file, err := jsonnet.Parse(req, nil, 0, template, templateArgs.Data) file, err := jsonnet.Parse(req, nil, 0, template, templateArgs.Data)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &core.Config{ return &core.Config{
Data: file, Data: file,
}, nil }, nil
} }
func parseStarlark(req *core.ConvertArgs, template *core.Template, templateArgs func parseStarlark(req *core.ConvertArgs, template *core.Template, templateArgs
core.TemplateArgs, stepLimit uint64) (*core.Config, error) { core.TemplateArgs, stepLimit uint64, sizeLimit uint64) (*core.Config, error) {
file, err := starlark.Parse(req, template, templateArgs.Data, stepLimit) file, err := starlark.Parse(req, template, templateArgs.Data, stepLimit,
sizeLimit)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &core.Config{ return &core.Config{
Data: file, Data: file,
}, nil }, nil
} }
 End of changes. 5 change blocks. 
5 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)