Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starlark #341

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Starlark #341

wants to merge 14 commits into from

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.

None yet

2 participants