diff --git a/internal/install/recipe_installer.go b/internal/install/recipe_installer.go index 8fb604978..8e417b442 100644 --- a/internal/install/recipe_installer.go +++ b/internal/install/recipe_installer.go @@ -4,12 +4,13 @@ import ( "context" "errors" "fmt" - "github.com/fatih/color" "os" "regexp" "strconv" "time" + "github.com/fatih/color" + log "github.com/sirupsen/logrus" "github.com/newrelic/newrelic-cli/internal/cli" diff --git a/internal/install/recipes/process_evaluator.go b/internal/install/recipes/process_evaluator.go index 561d1118a..257ef82fa 100644 --- a/internal/install/recipes/process_evaluator.go +++ b/internal/install/recipes/process_evaluator.go @@ -4,9 +4,10 @@ import ( "context" "fmt" - "github.com/newrelic/newrelic-cli/internal/install/execution" "golang.org/x/exp/slices" + "github.com/newrelic/newrelic-cli/internal/install/execution" + "github.com/shirou/gopsutil/v3/process" log "github.com/sirupsen/logrus" diff --git a/internal/nrql/command_query.go b/internal/nrql/command_query.go index 41602e8bb..397491f87 100644 --- a/internal/nrql/command_query.go +++ b/internal/nrql/command_query.go @@ -1,6 +1,9 @@ package nrql import ( + "errors" + "os" + log "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -29,6 +32,19 @@ issue the query against. PreRun: client.RequireClient, Run: func(cmd *cobra.Command, args []string) { accountID := configAPI.RequireActiveProfileAccountID() + + _, err := os.Stat(query) + if err != nil && !errors.Is(err, os.ErrNotExist) { + log.Fatal(err) + } else if err == nil { + // query points to a file/file descriptor + fileBytes, readErr := os.ReadFile(query) + if readErr != nil { + log.Fatal(readErr) + } + query = string(fileBytes) + } + result, err := client.NRClient.Nrdb.QueryWithContext(utils.SignalCtx, accountID, nrdb.NRQL(query)) if err != nil { log.Fatal(err)