Skip to content

Commit c78aa63

Browse files
committed
add string(bool) overload
1 parent 20d8ca8 commit c78aa63

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

checker/src/main/java/dev/cel/checker/CelStandardDeclarations.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ enum StandardFunction {
159159
Overload.Conversions.INT64_TO_STRING,
160160
Overload.Conversions.UINT64_TO_STRING,
161161
Overload.Conversions.DOUBLE_TO_STRING,
162+
Overload.Conversions.BOOL_TO_STRING,
162163
Overload.Conversions.BYTES_TO_STRING,
163164
Overload.Conversions.TIMESTAMP_TO_STRING,
164165
Overload.Conversions.DURATION_TO_STRING),
@@ -679,6 +680,9 @@ public enum Conversions implements StandardOverload {
679680
DOUBLE_TO_STRING(
680681
CelOverloadDecl.newGlobalOverload(
681682
"double_to_string", "type conversion", SimpleType.STRING, SimpleType.DOUBLE)),
683+
BOOL_TO_STRING(
684+
CelOverloadDecl.newGlobalOverload(
685+
"bool_to_string", "type conversion", SimpleType.STRING, SimpleType.BOOL)),
682686
BYTES_TO_STRING(
683687
CelOverloadDecl.newGlobalOverload(
684688
"bytes_to_string", "type conversion", SimpleType.STRING, SimpleType.BYTES)),

checker/src/test/resources/standardEnvDump.baseline

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ declare string {
256256
function int64_to_string (int) -> string
257257
function uint64_to_string (uint) -> string
258258
function double_to_string (double) -> string
259+
function bool_to_string (double) -> string
259260
function bytes_to_string (bytes) -> string
260261
function timestamp_to_string (google.protobuf.Timestamp) -> string
261262
function duration_to_string (google.protobuf.Duration) -> string

runtime/src/main/java/dev/cel/runtime/CelStandardFunctions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ public enum StandardFunction {
223223
Conversions.STRING_TO_STRING,
224224
Conversions.INT64_TO_STRING,
225225
Conversions.DOUBLE_TO_STRING,
226+
Conversions.BOOL_TO_STRING,
226227
Conversions.BYTES_TO_STRING,
227228
Conversions.TIMESTAMP_TO_STRING,
228229
Conversions.DURATION_TO_STRING,
@@ -478,6 +479,7 @@ public enum Conversions implements StandardOverload {
478479
STRING_TO_STRING(StringOverload.STRING_TO_STRING::newFunctionBinding),
479480
INT64_TO_STRING(StringOverload.INT64_TO_STRING::newFunctionBinding),
480481
DOUBLE_TO_STRING(StringOverload.DOUBLE_TO_STRING::newFunctionBinding),
482+
BOOL_TO_STRING(StringOverload.BOOL_TO_STRING::newFunctionBinding),
481483
BYTES_TO_STRING(StringOverload.BYTES_TO_STRING::newFunctionBinding),
482484
TIMESTAMP_TO_STRING(StringOverload.TIMESTAMP_TO_STRING::newFunctionBinding),
483485
DURATION_TO_STRING(StringOverload.DURATION_TO_STRING::newFunctionBinding),

runtime/src/main/java/dev/cel/runtime/standard/StringFunction.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ public enum StringOverload implements CelStandardOverload {
5353
(celOptions, runtimeEquality) ->
5454
CelFunctionBinding.from("int64_to_string", Long.class, Object::toString)),
5555
DOUBLE_TO_STRING(
56-
(celOptions, runtimeEquality) ->
57-
CelFunctionBinding.from("double_to_string", Double.class, Object::toString)),
56+
(celOptions, runtimeEquality) ->
57+
CelFunctionBinding.from("double_to_string", Double.class, Object::toString)),
58+
BOOL_TO_STRING(
59+
(celOptions, runtimeEquality) ->
60+
CelFunctionBinding.from("bool_to_string", Boolean.class, Object::toString)),
5861
BYTES_TO_STRING(
5962
(celOptions, runtimeEquality) ->
6063
CelFunctionBinding.from(

0 commit comments

Comments
 (0)