Skip to content

Commit

Permalink
fix: Skip detection reporting for infra if super
Browse files Browse the repository at this point in the history
  • Loading branch information
noahmmcgivern committed Jul 12, 2024
1 parent c11bef6 commit 6332ead
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion internal/install/recipe_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -372,6 +373,10 @@ func (i *RecipeInstall) reportRecipeStatuses(availableRecipes recipes.RecipeDete
i.status.ReportStatus(d.Status, e)
}
for _, d := range availableRecipes {
if i.shouldSkipReporting(d.Recipe.Name) {
continue
}

e := execution.RecipeStatusEvent{Recipe: *d.Recipe, ValidationDurationMs: d.DurationMs}
i.status.ReportStatus(execution.RecipeStatusTypes.DETECTED, e)
}
Expand All @@ -380,10 +385,29 @@ func (i *RecipeInstall) reportRecipeStatuses(availableRecipes recipes.RecipeDete
func (i *RecipeInstall) reportRecipeRecommendations(availableRecipes recipes.RecipeDetectionResults) {
recipeRecommendations := i.getRecipeRecommendations(availableRecipes)
for _, e := range recipeRecommendations {
if i.shouldSkipReporting(e.Recipe.Name) {
continue
}

i.status.ReportStatus(execution.RecipeStatusTypes.RECOMMENDED, e)
}
}

// Skip reporting for the infra agent if super agent has been targeted.
// The logs-integration also reports a status for the infra agent
// and should be skipped as well.
func (i *RecipeInstall) shouldSkipReporting(name string) bool {
if name == "infrastructure-agent-installer" || name == "logs-integration" {
for _, v := range i.RecipeNames {
if v == "super-agent" || v == "logs-integration-super-agent" {
return true
}
}
}

return false
}

// Report recommendations for recipes that are available but have not been attempted to be installed
func (i *RecipeInstall) getRecipeRecommendations(availableRecipes recipes.RecipeDetectionResults) []execution.RecipeStatusEvent {
isTargetedInstall := i.RecipeNamesProvided() && len(i.RecipeNames) > 0
Expand Down

0 comments on commit 6332ead

Please sign in to comment.