Skip to content

Commit

Permalink
chore(entities): add back --reporting flag implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderblue committed Apr 11, 2024
1 parent e9abb7f commit 5fc5549
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/entities/command_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package entities

import (
"context"
"strconv"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand All @@ -26,9 +27,9 @@ The search command performs a search for New Relic entities.
Example: "newrelic entity search --name=<name> --type=<type> --domain=<domain> --tags=tagKey1:tagValue2,tagKey2:tagValue2",
PreRun: client.RequireClient,
Run: func(cmd *cobra.Command, args []string) {
if entityName == "" && entityType == "" && entityAlertSeverity == "" && entityDomain == "" && len(entityTags) == 0 {
if entityName == "" && entityType == "" && entityAlertSeverity == "" && entityDomain == "" && len(entityTags) == 0 && entityReporting == "" {
utils.LogIfError(cmd.Help())
log.Fatal("one of --name, --type, --alert-severity, --domain, or --tags is required")
log.Fatal("one of --name, --type, --alert-severity, --domain, --reporting, or --tags is required")
}

tags, err := entities.ConvertTagsToMap(entityTags)
Expand All @@ -43,6 +44,12 @@ The search command performs a search for New Relic entities.
IsCaseSensitive: entitySearchCaseSensitive,
}

if entityReporting != "" {
r, err := strconv.ParseBool(entityReporting)
utils.LogIfFatal(err)
searchParams.IsReporting = &r
}

query := entities.BuildEntitySearchNrqlQuery(searchParams)

results, err := client.NRClient.Entities.GetEntitySearchByQueryWithContext(context.Background(),
Expand Down

0 comments on commit 5fc5549

Please sign in to comment.