-
Notifications
You must be signed in to change notification settings - Fork 13
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
fix: support "if" 1-arg shorthand #131
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,22 @@ type: object | |
- type: array | ||
items: | ||
type: string | ||
ifRule: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this change, "if" can no longer share the its anatomy with other ops ( |
||
type: object | ||
additionalProperties: false | ||
properties: | ||
if: | ||
title: If Operator | ||
description: 'The if statement takes 1-3 arguments: a condition ("if"), what to | ||
do if its true ("then", optional, defaults to returning true), | ||
and what to do if its false ("else", optional, defaults to returning false). | ||
Note that the form accepting more than 3 arguments (else-if) is not supported in flagd; | ||
use nesting instead.' | ||
type: array | ||
minItems: 1 | ||
maxItems: 3 | ||
items: | ||
$ref: "#/$defs/args" | ||
binaryOrTernaryOp: | ||
type: array | ||
minItems: 2 | ||
|
@@ -107,13 +123,6 @@ type: object | |
type: object | ||
additionalProperties: false | ||
properties: | ||
if: | ||
title: If Operator | ||
description: 'The if statement takes 2-3 arguments: a condition (if), what to | ||
do if its true (then), and what to do if its false (else, optional). Note that the | ||
form accepting more than 3 arguments (if/else) is not supported in flagd; | ||
use nesting instead.' | ||
$ref: "#/$defs/binaryOrTernaryOp" | ||
substr: | ||
title: Substring Operation | ||
description: Get a portion of a string. Give a positive start position to return everything beginning at that index. | ||
|
@@ -418,6 +427,7 @@ type: object | |
- $ref: "#/$defs/varRule" | ||
- $ref: "#/$defs/missingRule" | ||
- $ref: "#/$defs/missingSomeRule" | ||
- $ref: "#/$defs/ifRule" | ||
- $ref: "#/$defs/binaryRule" | ||
- $ref: "#/$defs/binaryOrTernaryRule" | ||
- $ref: "#/$defs/associativeRule" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of these didn't validate before this change, and now they do. |
||
"$schema": "../../flags.json", | ||
"flags": { | ||
"if-shorthand-1": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"true": true, | ||
"false": false | ||
}, | ||
"defaultVariant": "true", | ||
"targeting": { | ||
"if": [ | ||
{ | ||
"===": [ | ||
{ | ||
"var": "env" | ||
}, | ||
"production" | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"if-shorthand-2": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"true": true, | ||
"false": false | ||
}, | ||
"defaultVariant": "true", | ||
"targeting": { | ||
"if": [ | ||
{ | ||
"===": [ | ||
{ | ||
"var": "env" | ||
}, | ||
"production" | ||
] | ||
}, "true" | ||
] | ||
} | ||
}, | ||
"if-shorthand-ref": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"true": true, | ||
"false": false | ||
}, | ||
"defaultVariant": "true", | ||
"targeting": { | ||
"if": [ | ||
{ | ||
"$ref": "env-production" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"$evaluators": { | ||
"env-production": { | ||
"===": [ | ||
{ | ||
"var": "env" | ||
}, | ||
"production" | ||
] | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @austindrenski , the JSON is generated from the YAML, and the CI makes sure they are in sync.