diff --git a/web/api/v1/parse_expr.go b/web/api/v1/ast_to_json.go similarity index 96% rename from web/api/v1/parse_expr.go rename to web/api/v1/ast_to_json.go index ed14b6829..c5f0d08dc 100644 --- a/web/api/v1/parse_expr.go +++ b/web/api/v1/ast_to_json.go @@ -20,14 +20,8 @@ import ( "github.com/prometheus/prometheus/promql/parser" ) -func getStartOrEnd(startOrEnd parser.ItemType) interface{} { - if startOrEnd == 0 { - return nil - } - - return startOrEnd.String() -} - +// Take a Go PromQL AST and translate it to a JSON object for the tree view in the UI. +// TODO: Could it make sense to do this via the normal JSON marshalling methods? func translateAST(node parser.Expr) interface{} { if node == nil { return nil @@ -151,3 +145,11 @@ func translateMatchers(in []*labels.Matcher) interface{} { } return out } + +func getStartOrEnd(startOrEnd parser.ItemType) interface{} { + if startOrEnd == 0 { + return nil + } + + return startOrEnd.String() +}