Skip to content

Commit

Permalink
Merge pull request #697 from newrelic/fix/preinstall
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeveland27 authored Feb 19, 2021
2 parents d3d2cf2 + 83ea4f3 commit b7485e5
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 71 deletions.
5 changes: 3 additions & 2 deletions internal/install/recipe_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,9 @@ func (i *RecipeInstaller) executeAndValidate(m *types.DiscoveryManifest, r *type
}

func (i *RecipeInstaller) executeAndValidateWithProgress(m *types.DiscoveryManifest, r *types.Recipe) (string, error) {
i.progressIndicator.Start(fmt.Sprintf("Installing %s", r.Name))
defer func() { i.progressIndicator.Stop() }()

if r.PreInstallMessage() != "" {
fmt.Println(r.PreInstallMessage())
}
Expand All @@ -521,8 +524,6 @@ func (i *RecipeInstaller) executeAndValidateWithProgress(m *types.DiscoveryManif
return "", err
}

i.progressIndicator.Start(fmt.Sprintf("Installing %s", r.Name))
defer func() { i.progressIndicator.Stop() }()
i.status.RecipeInstalling(execution.RecipeStatusEvent{Recipe: *r})

entityGUID, err := i.executeAndValidate(m, r, vars)
Expand Down
59 changes: 21 additions & 38 deletions internal/install/recipes/recipe_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,19 @@ import (

// RecipeFile represents a recipe file as defined in the Open Installation Library.
type RecipeFile struct {
Description string `yaml:"description"`
InputVars []VariableConfig `yaml:"inputVars"`
Install map[string]interface{} `yaml:"install"`
InstallTargets []RecipeInstallTarget `yaml:"installTargets"`
Keywords []string `yaml:"keywords"`
LogMatch []types.LogMatch `yaml:"logMatch"`
Name string `yaml:"name"`
DisplayName string `yaml:"displayName"`
PreInstall RecipePreInstall `yaml:"preInstall"`
PostInstall RecipePostInstall `yaml:"postInstall"`
ProcessMatch []string `yaml:"processMatch"`
Repository string `yaml:"repository"`
ValidationNRQL string `yaml:"validationNrql"`
}

type RecipePreInstall struct {
Info string `yaml:"info"`
Prompt string `yaml:"prompt"`
}

type RecipePostInstall struct {
Info string `yaml:"info"`
Prompt string `yaml:"prompt"`
Description string `yaml:"description"`
InputVars []VariableConfig `yaml:"inputVars"`
Install map[string]interface{} `yaml:"install"`
InstallTargets []RecipeInstallTarget `yaml:"installTargets"`
Keywords []string `yaml:"keywords"`
LogMatch []types.LogMatch `yaml:"logMatch"`
Name string `yaml:"name"`
DisplayName string `yaml:"displayName"`
PreInstall types.OpenInstallationPreInstallConfiguration `yaml:"preInstall"`
PostInstall types.RecipePostInstall `yaml:"postInstall"`
ProcessMatch []string `yaml:"processMatch"`
Repository string `yaml:"repository"`
ValidationNRQL string `yaml:"validationNrql"`
}

type VariableConfig struct {
Expand Down Expand Up @@ -128,22 +118,15 @@ func (f *RecipeFile) ToRecipe() (*types.Recipe, error) {
if err != nil {
return nil, err
}

r := types.Recipe{
File: fileStr,
Name: f.Name,
DisplayName: f.DisplayName,
Description: f.Description,
Repository: f.Repository,
Keywords: f.Keywords,
PreInstall: types.RecipePreInstall{
Info: f.PreInstall.Info,
Prompt: f.PreInstall.Prompt,
},
PostInstall: types.RecipePostInstall{
Info: f.PostInstall.Info,
Prompt: f.PostInstall.Prompt,
},
File: fileStr,
Name: f.Name,
DisplayName: f.DisplayName,
Description: f.Description,
Repository: f.Repository,
Keywords: f.Keywords,
PreInstall: f.PreInstall,
PostInstall: f.PostInstall,
ProcessMatch: f.ProcessMatch,
LogMatch: f.LogMatch,
ValidationNRQL: f.ValidationNRQL,
Expand Down
1 change: 1 addition & 0 deletions internal/install/recipes/service_recipe_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ func createRecipe(result types.OpenInstallationRecipe) types.Recipe {
ProcessMatch: result.ProcessMatch,
Repository: result.Repository,
ValidationNRQL: string(result.ValidationNRQL),
PreInstall: result.PreInstall,
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/install/scenario_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func setupRecipeFetcherGuidedInstall() recipes.RecipeFetcher {
{
Name: "infrastructure-agent-installer",
DisplayName: "Infrastructure Agent",
PreInstall: types.RecipePreInstall{
PreInstall: types.OpenInstallationPreInstallConfiguration{
Info: `
This is the Infrastructure Agent Installer preinstall message.
It is made up of a multi line string.
Expand Down
43 changes: 14 additions & 29 deletions internal/install/types/recipe.go
Original file line number Diff line number Diff line change
@@ -1,43 +1,32 @@
package types

type Recipe struct {
ID string `json:"id"`
Description string `json:"description"`
DisplayName string `json:"displayName"`
File string `json:"file"`
InstallTargets []OpenInstallationRecipeInstallTarget `json:"installTargets"`
Keywords []string `json:"keywords"`
LogMatch []LogMatch `json:"logMatch"`
Name string `json:"name"`
PreInstall RecipePreInstall `json:"preInstall"`
PostInstall RecipePostInstall `json:"postInstall"`
ProcessMatch []string `json:"processMatch"`
Repository string `json:"repository"`
ValidationNRQL string `json:"validationNrql"`
ID string `json:"id"`
Description string `json:"description"`
DisplayName string `json:"displayName"`
File string `json:"file"`
InstallTargets []OpenInstallationRecipeInstallTarget `json:"installTargets"`
Keywords []string `json:"keywords"`
LogMatch []LogMatch `json:"logMatch"`
Name string `json:"name"`
PreInstall OpenInstallationPreInstallConfiguration `json:"preInstall"`
PostInstall RecipePostInstall `json:"postInstall"`
ProcessMatch []string `json:"processMatch"`
Repository string `json:"repository"`
ValidationNRQL string `json:"validationNrql"`
Vars map[string]interface{}
}

// RecipePreInstall represents the information used prior to recipe execution.
type RecipePreInstall struct {
Info string `yaml:"info"`
Prompt string `yaml:"prompt"`
}

// RecipePostInstall represents the information used after recipe execution has completed.
type RecipePostInstall struct {
Info string `yaml:"info"`
Prompt string `yaml:"prompt"`
Info string `yaml:"info"`
}

func (r *Recipe) PostInstallMessage() string {
if r.PostInstall.Info != "" {
return r.PostInstall.Info
}

if r.PostInstall.Prompt != "" {
return r.PostInstall.Prompt
}

return ""
}

Expand All @@ -46,10 +35,6 @@ func (r *Recipe) PreInstallMessage() string {
return r.PreInstall.Info
}

if r.PreInstall.Prompt != "" {
return r.PreInstall.Prompt
}

return ""
}

Expand Down
2 changes: 2 additions & 0 deletions internal/install/types/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/install/ux/plain_progress_indicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (p *PlainProgress) Start(msg string) {
x := color.New(color.Bold)
x.Printf(" %s", msg)

fmt.Printf("... ")
fmt.Printf("...\n")
}

func (p *PlainProgress) Success() {
Expand Down

0 comments on commit b7485e5

Please sign in to comment.