Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I select parameters in a KRL webhook?

Tags:

webhooks

krl

I want to run some KRL rules when a website is updated. The deploy script will get the following URL after pushing the updates:

http://webhooks.kynetxapps.net/t/_appid_/updated?site=production&version=123456abcdef

The ruleset to handle this webhook starts out like this:

rule site_updated {
    select when webhook updated
    pre {
        site = event:param("site");
        version = event:param("version");
    }
    // do something with site and version
}

From http://docs.kynetx.com/docs/Event_API I could make more specific rules with:

select when webhook updated site "test"
    or webhook updated site "production"

Is there a way to get both parameters without a PRE block? What is the best way to use SELECT with a webhook?

like image 736
Randall Bohn Avatar asked Mar 04 '26 14:03

Randall Bohn


1 Answers

Rule filters (like site "test") are regular expressions, and you can set variables using the setting () clause.

http://webhooks.kynetxapps.net/t/_appid_/update?site=production&version=123456abcdef

select when webhook update site "(.*)" setting(site)

causes site to be set to production without using a pre block. As this is a regular expression, you can match anything, like either of two options:

select when webhook update site "(test|production)" setting(site)

will only match with site == test or site == production, and no other times, AND store the value in the site variable in the context of the rule.

like image 160
TelegramSam Avatar answered Mar 07 '26 04:03

TelegramSam