-
Notifications
You must be signed in to change notification settings - Fork 492
conditional transforms #33
Description
We need to support some additional logic for our import_transforms at stack.
CURRENT:
var TRANSFORM_DOUBLEINT = [
{low: NYLO, high: NYLO+40, newBase: [NYINT,COINT] },
{low: NYHI, high: NYHI+40, newBase: [NYINT,COINT] },
{low: COLO, high: COLO+40, newBase: [NYINT,COINT] },
{low: COHI, high: COHI+40, newBase: [NYINT,COINT] },
]
We need to conditionally only use one of the newBase entries for wildcard records.
Logic is essentially:
var TRANSFORM_DOUBLEINT = [
{low: NYLO, high: NYLO+40, newBase: [NYINT(always),COINT(unless *)] },
{low: NYHI, high: NYHI+40, newBase: [NYINT(always),COINT(unless *)] },
{low: COLO, high: COLO+40, newBase: [NYINT(unless *),COINT(always)] },
{low: COHI, high: COHI+40, newBase: [NYINT(unless *),COINT(always)] },
]
I can see a few different ways to implement this:
1. Hack it in
Just handle all * records as a special case and only emit the first newBase transform.
Quick and easy, but completely inflexible, and a bit "magical"
2. Add a field to each rule, double the rules
var TRANSFORM_DOUBLEINT = [
{low: NYLO, high: NYLO+40, newBase: [NYINT,COINT], ignore:"*" },
{low: NYLO, high: NYLO+40, newBase: [NYINT] },
{low: NYHI, high: NYHI+40, newBase: [NYINT,COINT] , ignore:"*"},
{low: NYHI, high: NYHI+40, newBase: [NYINT] },
{low: COLO, high: COLO+40, newBase: [NYINT,COINT], ignore:"*" },
{low: COLO, high: COLO+40, newBase: [COINT] },
{low: COHI, high: COHI+40, newBase: [NYINT,COINT], ignore:"*" },
{low: COHI, high: COHI+40, newBase: [COINT] },
]
Here each rule can have an ignore field to skip it. Since transforms stop looking at rules once we match one, this should behave as expected.
Cons: our home grown hacky transform format for transforms (~~ soup) is not making this easy. But it can be added in.
Also, is the field a regex? Or just do a contains on it? Regex for wildcard means putting in \* which feels kinda odd. Should it just match on the label, or on the fqdn?