"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plugin/converter/starlark/starlark.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.

starlark.go  (drone-2.15.0):starlark.go  (drone-2.16.0)
skipping to change at line 32 skipping to change at line 32
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"go.starlark.net/starlark" "go.starlark.net/starlark"
) )
const ( const (
separator = "---" separator = "---"
newline = "\n" newline = "\n"
) )
// limits generated configuration file size. // default limit for generated configuration file size.
const limit = 1000000 const defaultSizeLimit = 1000000
var ( var (
// ErrMainMissing indicates the starlark script is missing // ErrMainMissing indicates the starlark script is missing
// the main method. // the main method.
ErrMainMissing = errors.New("starlark: missing main function") ErrMainMissing = errors.New("starlark: missing main function")
// ErrMainInvalid indicates the starlark script defines a // ErrMainInvalid indicates the starlark script defines a
// global variable named main, however, it is not callable. // global variable named main, however, it is not callable.
ErrMainInvalid = errors.New("starlark: main must be a function") ErrMainInvalid = errors.New("starlark: main must be a function")
skipping to change at line 57 skipping to change at line 57
// ErrMaximumSize indicates the starlark script generated a // ErrMaximumSize indicates the starlark script generated a
// file that exceeds the maximum allowed file size. // file that exceeds the maximum allowed file size.
ErrMaximumSize = errors.New("starlark: maximum file size exceeded") ErrMaximumSize = errors.New("starlark: maximum file size exceeded")
// ErrCannotLoad indicates the starlark script is attempting to // ErrCannotLoad indicates the starlark script is attempting to
// load an external file which is currently restricted. // load an external file which is currently restricted.
ErrCannotLoad = errors.New("starlark: cannot load external scripts") ErrCannotLoad = errors.New("starlark: cannot load external scripts")
) )
func Parse(req *core.ConvertArgs, template *core.Template, templateData map[stri ng]interface{}, stepLimit uint64) (string, error) { func Parse(req *core.ConvertArgs, template *core.Template, templateData map[stri ng]interface{}, stepLimit uint64, sizeLimit uint64) (string, error) {
thread := &starlark.Thread{ thread := &starlark.Thread{
Name: "drone", Name: "drone",
Load: noLoad, Load: noLoad,
Print: func(_ *starlark.Thread, msg string) { Print: func(_ *starlark.Thread, msg string) {
logrus.WithFields(logrus.Fields{ logrus.WithFields(logrus.Fields{
"namespace": req.Repo.Namespace, "namespace": req.Repo.Namespace,
"name": req.Repo.Name, "name": req.Repo.Name,
}).Traceln(msg) }).Traceln(msg)
}, },
} }
skipping to change at line 135 skipping to change at line 135
buf.WriteString(newline) buf.WriteString(newline)
} }
case *starlark.Dict: case *starlark.Dict:
if err := write(buf, v); err != nil { if err := write(buf, v); err != nil {
return "", err return "", err
} }
default: default:
return "", ErrMainReturn return "", ErrMainReturn
} }
if sizeLimit == 0 {
sizeLimit = defaultSizeLimit
}
// this is a temporary workaround until we // this is a temporary workaround until we
// implement a LimitWriter. // implement a LimitWriter.
if b := buf.Bytes(); len(b) > limit { if b := buf.Bytes(); uint64(len(b)) > sizeLimit {
return "", ErrMaximumSize return "", ErrMaximumSize
} }
return buf.String(), nil return buf.String(), nil
} }
func noLoad(_ *starlark.Thread, _ string) (starlark.StringDict, error) { func noLoad(_ *starlark.Thread, _ string) (starlark.StringDict, error) {
return nil, ErrCannotLoad return nil, ErrCannotLoad
} }
 End of changes. 4 change blocks. 
4 lines changed or deleted 8 lines changed or added

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