would you consider adding Kotlin scripts for Hooks...
# dev
g
would you consider adding Kotlin scripts for Hooks?
l
Hi @Giuseppe Barbieri, it's not on the roadmap for now. Could you please open a issue?
g
sure, no problem
e
You are welcome to contribute the code @Giuseppe Barbieri
👍 1
g
I'd love, but I don't even know where to start from, I'd need some inputs for that
b
Not something that I tested, but it looks like a valid alternative you can start using now - https://ktor.io/ and use lakefs hooks to trigger your code
👍 3
g
this shall be triggered via a webhook, right?
b
yes, you can use https://docs.lakefs.io/howto/hooks/webhooks.html or Lua if you need more control
g
sorry, but I'm having issues trying to understand where the logic is executed let's look for example at this example, that ensures only parquet files are allowed on a merge on
master
, it will generate a POST to
http://<host:port>/webhooks/format
like
Copy code
{
  "event_type": "pre-merge",
  "event_time": "..",
  "action_name": "ParquetOnlyInProduction",
  "hook_id": "production_format_validator",
  "repository_id": "repo1",
  "branch_id": "branch1",
  "source_ref": "branch1",
  "commit_message": "commit message",
  "committer": "committer",
  "commit_metadata": {
    "key": "value"
  }
}
the server receive that POST and then? How can it check if there are only parquet files?
b
Good example. The hook implementation uses lakefs API to list the changes and block the change as needed.
g
could you elaborate?
b
https://github.com/treeverse/lakeFS-hooks/blob/01a70e297bb291068f23c0b2367711b5973b2eb8/server.py#L27 the link to the example, check the web hook "format" handler. it uses lakefs API to query the data it validates.
I assume you will want to implement the same using kotlin in your case.