From a1f67309861d990390cac4af77e4f2133a4e96b0 Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Mon, 25 Mar 2024 16:42:58 -0400 Subject: [PATCH] misc: remove unused rivereval tool --- internal/cmd/rivereval/example.river | 1 - internal/cmd/rivereval/main.go | 52 ---------------------------- 2 files changed, 53 deletions(-) delete mode 100644 internal/cmd/rivereval/example.river delete mode 100644 internal/cmd/rivereval/main.go diff --git a/internal/cmd/rivereval/example.river b/internal/cmd/rivereval/example.river deleted file mode 100644 index 06f273c707..0000000000 --- a/internal/cmd/rivereval/example.river +++ /dev/null @@ -1 +0,0 @@ -env("HOME") diff --git a/internal/cmd/rivereval/main.go b/internal/cmd/rivereval/main.go deleted file mode 100644 index 1a7fe8cc9c..0000000000 --- a/internal/cmd/rivereval/main.go +++ /dev/null @@ -1,52 +0,0 @@ -// Command rivereval reads a River file from disk, evaluates it as an -// expression, and prints the result as a River value. -package main - -import ( - "fmt" - "os" - - "github.com/grafana/alloy/syntax/parser" - "github.com/grafana/alloy/syntax/token/builder" - "github.com/grafana/alloy/syntax/vm" -) - -func main() { - if err := run(); err != nil { - fmt.Fprintln(os.Stderr, err) - } -} - -func run() error { - args := os.Args[1:] - - if len(args) != 1 { - return fmt.Errorf("usage: rivereval [file]") - } - - contents, err := os.ReadFile(args[0]) - if err != nil { - return err - } - - // We currently can't support parsing entire files since eval.Evaluate - // assumes you'll pass a block with a struct schema to it. This might be a - // restriction we can loosen in the future. - node, err := parser.ParseExpression(string(contents)) - if err != nil { - return err - } - eval := vm.New(node) - - var v interface{} - if err := eval.Evaluate(nil, &v); err != nil { - return err - } - - expr := builder.NewExpr() - expr.SetValue(v) - - _, _ = expr.WriteTo(os.Stdout) - fmt.Println() // Write an extra newline at the end - return nil -}