Skip to content

Conversation

@orsinium
Copy link
Contributor

@orsinium orsinium commented Oct 7, 2020

Add Starlark template filter syntax support. See the included documentation for more information

Motivation

  1. More powerful: everything that we can do with "template" filters can be done with "starlark" and much more. Actually, Starlark is turing-complete.
  2. More readable.
  3. Familiar: Python is one of the most popular languages.

Requirements

Blocked by #340 (contains that PR in the diff)

TODO

The input field for filters in beehive-admin should be changed to textarea. For now, I'm using YAML configuration file from #339 to write starlark filters.

log.Println("\tExecuting filter:", filter)
func execFilter(source string, opts map[string]interface{}) bool {
name := "template"
if strings.Contains(source, "def main(") {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too happy with this "string magic". Maybe we could introduce proper filter types? I was also pondering having simple bash-scripts as filters, which either return 0 or 1 as a result.

Copy link
Contributor Author

@orsinium orsinium Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not sure if it is a good solution but it requires a selector on the UI side and I'm not ready to dive into Ember. If you're ready to do such adjustments, please, do.

If to talk about a better backend-only solution, I can propose shebangs. In that case, this line will be if strings.HasPrefix(source, "#!/usr/bin/env starlark") , for example.

Bash scripts is a cool and fun idea. I'm sure some will be happy to build grep/sed/awk/perl pipelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants