Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions evaluator/flags/testkit-flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,18 @@
["two", 50]
]
}
},
"nested-ref-targeted-flag": {
"state": "ENABLED",
"variants": {
"privileged": "privileged",
"standard": "standard",
"none": "none"
},
"defaultVariant": "none",
"targeting": {
"if": [{"$ref": "is_privileged"}, "privileged", "standard"]
}
}
},
"$evaluators": {
Expand All @@ -482,6 +494,12 @@
"ballmer@macrosoft.com",
{"var": ["email"]}
]
},
"is_privileged": {
"or": [
{"==": ["ballmer@macrosoft.com", {"var": ["email"]}]},
{"==": ["admin", {"var": ["role"]}]}
]
}
}
}
13 changes: 13 additions & 0 deletions evaluator/gherkin/evaluator-refs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,16 @@ Feature: Evaluator evaluator refs
| key | value |
| some-email-targeted-flag | hi |
| some-other-email-targeted-flag | yes |

@evaluator-ref-edge-cases
Scenario Outline: Nested evaluator ref resolution
Given an evaluator
And a String-flag with key "nested-ref-targeted-flag" and a fallback value "fallback"
And a context containing a key "<context_key>", with type "String" and with value "<context_value>"
When the flag was evaluated with details
Then the resolved details value should be "<value>"
Examples:
| context_key | context_value | value |
| email | ballmer@macrosoft.com | privileged |
| role | admin | privileged |
| email | other@example.com | standard |
36 changes: 34 additions & 2 deletions flags/evaluator-refs.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,47 @@
"no"
]
}
},
"nested-ref-targeted-flag": {
"state": "ENABLED",
"variants": {
"privileged": "privileged",
"standard": "standard",
"none": "none"
},
"defaultVariant": "none",
"targeting": {
"if": [
{
"$ref": "is_privileged"
},
"privileged",
"standard"
]
}
}
},
"$evaluators": {
"is_ballmer": {
"==": [
"ballmer@macrosoft.com",
{
"var": [
"email"
"var": ["email"]
}
]
},
"is_privileged": {
"or": [
{
"==": [
"ballmer@macrosoft.com",
{"var": ["email"]}
]
},
{
"==": [
"admin",
{"var": ["role"]}
]
}
]
Expand Down
13 changes: 13 additions & 0 deletions gherkin/targeting.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Feature: Targeting rules
And a stable flagd provider

# evaluator refs
@evaluator-refs
Scenario Outline: Evaluator reuse
Given a String-flag with key "<key>" and a default value "fallback"
And a context containing a key "email", with type "String" and with value "ballmer@macrosoft.com"
Expand All @@ -20,6 +21,18 @@ Feature: Targeting rules
| some-email-targeted-flag | hi |
| some-other-email-targeted-flag | yes |

@evaluator-refs @evaluator-ref-edge-cases
Scenario Outline: Nested evaluator ref resolution
Given a String-flag with key "nested-ref-targeted-flag" and a default value "fallback"
And a context containing a key "<context_key>", with type "String" and with value "<context_value>"
When the flag was evaluated with details
Then the resolved details value should be "<value>"
Examples:
| context_key | context_value | value |
| email | ballmer@macrosoft.com | privileged |
| role | admin | privileged |
| email | other@example.com | standard |

# custom operators
# @fractional-v1: legacy float-based bucketing (abs(hash) / i32::MAX * 100)
# @fractional-v2: high-precision integer bucketing ((hash * totalWeight) >> 32)
Expand Down
Loading