Skip to content

Commit 112d20f

Browse files
feat: modify copies from several installation steps and remove logs-integration-agent-control logic (#1811)
1 parent 4ed200d commit 112d20f

12 files changed

Lines changed: 122 additions & 182 deletions

internal/changeTracking/command_create_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package changeTracking
33
import (
44
"testing"
55

6-
"github.com/newrelic/newrelic-cli/internal/testcobra"
76
"github.com/stretchr/testify/assert"
7+
8+
"github.com/newrelic/newrelic-cli/internal/testcobra"
89
)
910

1011
func TestChangeTrackingCommand(t *testing.T) {

internal/install/execution/link_generator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ type LinkGenerator interface {
66
GenerateLoggingLink(entityGUID string) string
77
GenerateFleetLink(entityGUID string) string
88
GenerateGuidedInstallDocLink() string
9+
GenerateFleetConfigurationDocLink() string
910
GenerateRedirectURL(status InstallStatus) string
1011
}

internal/install/execution/mock_link_generator.go

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@ package execution
33
import "strings"
44

55
type MockPlatformLinkGenerator struct {
6-
GenerateExplorerLinkCallCount int
7-
GenerateEntityLinkCallCount int
8-
GenerateLoggingLinkCallCount int
9-
GenerateFleetLinkCallCount int
10-
GenerateRedirectURLCallCount int
11-
GenerateGuidedInstallDocLinkCallCount int
12-
GenerateExplorerLinkVal string
13-
GenerateEntityLinkVal string
14-
GenerateLoggingLinkVal string
15-
GenerateFleetLinkVal string
16-
GenerateRedirectURLVal string
17-
GenerateGuidedInstallDocLinkVal string
6+
GenerateExplorerLinkCallCount int
7+
GenerateEntityLinkCallCount int
8+
GenerateLoggingLinkCallCount int
9+
GenerateFleetLinkCallCount int
10+
GenerateRedirectURLCallCount int
11+
GenerateGuidedInstallDocLinkCallCount int
12+
GenerateFleetConfigurationDocLinkCallCount int
13+
GenerateExplorerLinkVal string
14+
GenerateEntityLinkVal string
15+
GenerateLoggingLinkVal string
16+
GenerateFleetLinkVal string
17+
GenerateRedirectURLVal string
18+
GenerateGuidedInstallDocLinkVal string
19+
GenerateFleetConfigurationDocLinkVal string
1820
}
1921

2022
func NewMockPlatformLinkGenerator() *MockPlatformLinkGenerator {
@@ -49,6 +51,14 @@ func (g *MockPlatformLinkGenerator) GenerateGuidedInstallDocLink() string {
4951
return "https://docs.newrelic.com/docs/infrastructure/infrastructure-agent/new-relic-guided-install-overview/"
5052
}
5153

54+
func (g *MockPlatformLinkGenerator) GenerateFleetConfigurationDocLink() string {
55+
g.GenerateFleetConfigurationDocLinkCallCount++
56+
if g.GenerateFleetConfigurationDocLinkVal != "" {
57+
return g.GenerateFleetConfigurationDocLinkVal
58+
}
59+
return "https://docs.newrelic.com/docs/new-relic-control/fleet-control/setup/"
60+
}
61+
5262
func (g *MockPlatformLinkGenerator) GenerateRedirectURL(status InstallStatus) string {
5363
g.GenerateRedirectURLCallCount++
5464
if status.hasAnyRecipeStatus(RecipeStatusTypes.INSTALLED) {

internal/install/execution/platform_link_generator.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func (g *PlatformLinkGenerator) GenerateGuidedInstallDocLink() string {
5555
return "https://docs.newrelic.com/docs/infrastructure/infrastructure-agent/new-relic-guided-install-overview/"
5656
}
5757

58+
func (g *PlatformLinkGenerator) GenerateFleetConfigurationDocLink() string {
59+
return "https://docs.newrelic.com/docs/new-relic-control/fleet-control/setup/"
60+
}
61+
5862
// GenerateRedirectURL creates a URL for the user to navigate to after running
5963
// through an installation. The URL is displayed in the CLI out as well and is
6064
// also provided in the nerdstorage document. This provides the user two options

internal/install/execution/recipe_log_forwarder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func NewRecipeLogForwarder() *RecipeLogForwarder {
4444
}
4545

4646
func (lf *RecipeLogForwarder) PromptUserToSendLogs(reader io.Reader) bool {
47-
fmt.Printf("\n%s Something went wrong during the installation — let’s look at the docs and try again. Would you like to send us the logs to help us understand what happened? [Y/n] ", color.YellowString("\u0021"))
47+
fmt.Printf("\n%s We couldn’t complete the installation. Check out our troubleshooting docs and try again. Want to help us make our troubleshooting help better? If so, send us the install logs so we can understand. [Y/n] ", color.YellowString("\u0021"))
4848
scanner := bufio.NewScanner(reader)
4949
for scanner.Scan() {
5050
input := strings.TrimSuffix(scanner.Text(), "\n")

internal/install/execution/terminal_reporter.go

Lines changed: 55 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -81,65 +81,63 @@ func (r TerminalStatusReporter) InstallStarted(status *InstallStatus) error {
8181
}
8282

8383
func (r TerminalStatusReporter) InstallComplete(status *InstallStatus) error {
84-
hasStatuses := len(status.Statuses) > 0
85-
if hasStatuses {
86-
hasInstalledRecipes := status.hasAnyRecipeStatus(RecipeStatusTypes.INSTALLED)
84+
if len(status.Statuses) == 0 {
85+
return nil
86+
}
8787

88-
if hasInstalledRecipes {
89-
fmt.Print("\n New Relic installation complete \n\n")
90-
}
88+
hasInstalled := status.hasAnyRecipeStatus(RecipeStatusTypes.INSTALLED)
89+
hasFailures := status.hasAnyRecipeStatus(RecipeStatusTypes.FAILED) || status.hasAnyRecipeStatus(RecipeStatusTypes.UNSUPPORTED)
90+
isAgentControl := r.isAgentControlInstalled(status)
91+
isAgentControlAttempt := r.isOnlyAgentControlAttempt(status)
9192

92-
fmt.Println(" --------------------")
93-
fmt.Println(" Installation Summary")
94-
fmt.Println("")
95-
r.printInstallationSummary(os.Stdout, status)
96-
97-
// Check if only agent-control recipes were installed (successfully)
98-
isOnlyAgentControl := r.isOnlyAgentControlInstallation(status)
99-
// Check if all recipes attempted (regardless of status) are agent-control
100-
isOnlyAgentControlAttempt := r.isOnlyAgentControlAttempt(status)
101-
102-
msg := "View your data at the link below:\n"
103-
followInstructionsMsg := "Follow the instructions at the URL below to complete the installation process."
104-
if hasInstalledRecipes && (status.hasAnyRecipeStatus(RecipeStatusTypes.FAILED) || status.hasAnyRecipeStatus(RecipeStatusTypes.UNSUPPORTED)) {
105-
msg = fmt.Sprintf("Installation was successful overall, however, one or more installations could not be completed.\n %s \n\n", followInstructionsMsg)
106-
} else if !hasInstalledRecipes {
107-
msg = fmt.Sprintf("Installation incomplete. %s \n\n", followInstructionsMsg)
108-
}
93+
if hasInstalled {
94+
fmt.Print("\n New Relic installation complete \n\n")
95+
}
96+
97+
fmt.Println(" --------------------")
98+
fmt.Println(" What's next?")
99+
r.printInstallationSummary(os.Stdout, status)
109100

110-
// Generate redirect link only when needed (not for agent-control only installations)
111-
linkToData := ""
112-
if status.PlatformLinkGenerator != nil && !isOnlyAgentControl && !isOnlyAgentControlAttempt {
113-
linkToData = status.PlatformLinkGenerator.GenerateRedirectURL(*status)
101+
var msg, link string
102+
dataLink := ""
103+
if status.PlatformLinkGenerator != nil && !isAgentControl && !isAgentControlAttempt {
104+
dataLink = status.PlatformLinkGenerator.GenerateRedirectURL(*status)
105+
}
106+
107+
switch {
108+
case isAgentControl:
109+
msg = "Learn about configuring your agent and fleet:"
110+
if status.PlatformLinkGenerator != nil {
111+
link = status.PlatformLinkGenerator.GenerateFleetConfigurationDocLink()
114112
}
115113

116-
// For incomplete installations: show message with appropriate link
117-
if !hasInstalledRecipes {
118-
if isOnlyAgentControlAttempt && status.PlatformLinkGenerator != nil {
119-
// Agent-control incomplete installation: use documentation link
120-
agentControlDocLink := status.PlatformLinkGenerator.GenerateGuidedInstallDocLink()
121-
fmt.Printf("\n %s", msg)
122-
fmt.Printf(" %s %s", color.GreenString(ux.IconArrowRight), agentControlDocLink)
123-
} else if linkToData != "" {
124-
// Non-agent-control incomplete installation: use regular link
125-
fmt.Printf("\n %s", msg)
126-
fmt.Printf(" %s %s", color.GreenString(ux.IconArrowRight), linkToData)
127-
}
128-
} else if linkToData != "" && !isOnlyAgentControl {
129-
// Successful installation (not agent-control only): show "View your data" link
130-
fmt.Printf("\n %s", msg)
131-
fmt.Printf(" %s %s", color.GreenString(ux.IconArrowRight), linkToData)
114+
case !hasInstalled:
115+
msg = "The installation is incomplete. Follow the instructions at the URL below to complete the installation process."
116+
if isAgentControlAttempt && status.PlatformLinkGenerator != nil {
117+
link = status.PlatformLinkGenerator.GenerateGuidedInstallDocLink()
118+
} else {
119+
link = dataLink
132120
}
133121

134-
r.printLoggingLink(status)
122+
case hasFailures:
123+
msg = "Installation was successful overall, however, one or more installations could not be completed.\n Follow the instructions at the URL below to complete the installation process."
124+
link = dataLink
135125

136-
r.printFleetLink(status)
126+
default:
127+
msg = "View your data at the link below:"
128+
link = dataLink
129+
}
137130

138-
fmt.Println()
139-
fmt.Println("\n --------------------")
140-
fmt.Println()
131+
if link != "" {
132+
fmt.Printf("\n %s\n", msg)
133+
fmt.Printf(" %s %s\n", color.GreenString(ux.IconArrowRight), link)
141134
}
142135

136+
r.printLoggingLink(status)
137+
r.printFleetLink(status)
138+
139+
fmt.Printf("\n --------------------\n\n")
140+
143141
return nil
144142
}
145143

@@ -167,11 +165,11 @@ func (r TerminalStatusReporter) UpdateRequired(status *InstallStatus) error {
167165

168166
func (r TerminalStatusReporter) printFleetLink(status *InstallStatus) {
169167
linkToFleet := ""
170-
fleetMsg := "View your fleet at the link below:\n"
168+
fleetMsg := "Check out your agent in our Fleet Control UI:\n"
171169
statuses := r.getRecipesStatusesForInstallationSummary(status)
172170

173171
for _, s := range statuses {
174-
isAgentControlRecipe := s.Name == types.AgentControlRecipeName || s.Name == types.LoggingAgentControlRecipeName
172+
isAgentControlRecipe := s.Name == types.AgentControlRecipeName
175173

176174
if s.Status == RecipeStatusTypes.INSTALLED && isAgentControlRecipe {
177175
// Use NR_CLI_FLEET_ID environment variable if available, otherwise fall back to entity GUID
@@ -197,22 +195,20 @@ func (r TerminalStatusReporter) printFleetLink(status *InstallStatus) {
197195
}
198196
}
199197

200-
func (r TerminalStatusReporter) isOnlyAgentControlInstallation(status *InstallStatus) bool {
198+
func (r TerminalStatusReporter) isAgentControlInstalled(status *InstallStatus) bool {
201199
statuses := r.getRecipesStatusesForInstallationSummary(status)
202-
hasInstalledRecipes := false
203-
hasNonAgentControlRecipes := false
200+
isAgentControlRecipeInstalled := false
204201

205202
for _, s := range statuses {
206203
if s.Status == RecipeStatusTypes.INSTALLED {
207-
hasInstalledRecipes = true
208-
isAgentControlRecipe := s.Name == types.AgentControlRecipeName || s.Name == types.LoggingAgentControlRecipeName
209-
if !isAgentControlRecipe {
210-
hasNonAgentControlRecipes = true
204+
isAgentControlRecipe := s.Name == types.AgentControlRecipeName
205+
if isAgentControlRecipe {
206+
isAgentControlRecipeInstalled = true
211207
break
212208
}
213209
}
214210
}
215-
return hasInstalledRecipes && !hasNonAgentControlRecipes
211+
return isAgentControlRecipeInstalled
216212
}
217213

218214
func (r TerminalStatusReporter) isOnlyAgentControlAttempt(status *InstallStatus) bool {
@@ -222,7 +218,7 @@ func (r TerminalStatusReporter) isOnlyAgentControlAttempt(status *InstallStatus)
222218
}
223219

224220
for _, s := range statuses {
225-
isAgentControlRecipe := s.Name == types.AgentControlRecipeName || s.Name == types.LoggingAgentControlRecipeName
221+
isAgentControlRecipe := s.Name == types.AgentControlRecipeName
226222
if !isAgentControlRecipe {
227223
return false
228224
}

0 commit comments

Comments
 (0)