Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Unparse Expr values to strings
  • Loading branch information
TristonianJones committed Apr 14, 2025
commit dac9e7d260f12f8670095012a0114ef0bcef18e2
8 changes: 7 additions & 1 deletion cel/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ func AstToParsedExpr(a *Ast) (*exprpb.ParsedExpr, error) {
// Note, the conversion may not be an exact replica of the original expression, but will produce
// a string that is semantically equivalent and whose textual representation is stable.
func AstToString(a *Ast) (string, error) {
return parser.Unparse(a.NativeRep().Expr(), a.NativeRep().SourceInfo())
return ExprToString(a.NativeRep().Expr(), a.NativeRep().SourceInfo())
}

// ExprToString converts an AST Expr node back to a string using macro call tracking metadata from
// source info if any macros are encountered within the expression.
func ExprToString(e ast.Expr, info *ast.SourceInfo) (string, error) {
return parser.Unparse(e, info)
}

// RefValueToValue converts between ref.Val and google.api.expr.v1alpha1.Value.
Expand Down