Skip to content

Commit

Permalink
chore: Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
NSSPKrishna committed Jun 6, 2024
1 parent ec9e128 commit a921e4c
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 44 deletions.
1 change: 0 additions & 1 deletion internal/install/bundle_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ func (bi *BundleInstaller) InstallBundleRecipe(bundleRecipe *recipes.BundleRecip
func (bi *BundleInstaller) getInstallableBundleRecipes(bundle *recipes.Bundle) []*recipes.BundleRecipe {
var bundleRecipes []*recipes.BundleRecipe

// FIX: TEST below code
for _, bundleRecipe := range bundle.BundleRecipes {
if !bundleRecipe.LastStatus(execution.RecipeStatusTypes.AVAILABLE) {
// Skip if not available
Expand Down
2 changes: 0 additions & 2 deletions internal/install/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ var Command = &cobra.Command{
return e
}

// FIX: its not floated as error
// This is showing up in all the scenarios if super agent is present
if errors.Is(err, types.ErrSuperAgent) {
return err
}
Expand Down
11 changes: 2 additions & 9 deletions internal/install/recipe_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,6 @@ func (i *RecipeInstall) install(ctx context.Context) error {
return err
}

// FIX: This is for super agent process when found on the host
// Check if this is functional
//!i.InstallerContext.IsRecipeTargeted(types.SuperAgentRecipeName)
if _, ok := availableRecipes.GetRecipeDetection(types.SuperAgentRecipeName); i.hostHasSuperAgentProcess() && !ok {
availableRecipes = append(availableRecipes, &recipes.RecipeDetectionResult{
Recipe: &types.OpenInstallationRecipe{Name: types.SuperAgentRecipeName},
Expand Down Expand Up @@ -437,7 +434,6 @@ func (i *RecipeInstall) installAdditionalBundle(bundler RecipeBundler, bundleIns
log.Debugf("bundling additional bundle")
log.Debugf("recipes in list %d", len(i.RecipeNames))
additionalBundle = bundler.CreateAdditionalTargetedBundle(i.RecipeNames)
// FIX: Write tests here
if bun.HasSuperInstalled {
for _, coreRecipe := range bun.GetCoreRecipeNames() {
if depBundle, found := additionalBundle.ContainsName(coreRecipe); found {
Expand Down Expand Up @@ -490,16 +486,13 @@ func (i *RecipeInstall) installCoreBundle(bundler RecipeBundler, bundleInstaller
} else {
log.Debugf("Super agent process not found. Proceeding with installation.")
}
// FIX: Should allow to create the bundle even if there is SuperAgentRecipeName
// creating a bundle check if its core type and say skip / nil
// check the created core bundle for nil and say skip
// if i.shouldInstallCore() && !bun.HasSuperInstalled {

log.Debugf("Status of core skip: %v", i.shouldInstallCore())

if i.shouldInstallCore() {
log.Debugf("Preparing core bundle")
coreBundle := bundler.CreateCoreBundle()

// FIX: Write tests here
if bundler.(*recipes.Bundler).HasSuperInstalled {
for _, coreRecipe := range bun.GetCoreRecipeNames() {
if i, ok := coreBundle.ContainsName(coreRecipe); ok {
Expand Down
3 changes: 0 additions & 3 deletions internal/install/recipe_installer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ func TestInstallGuidedShouldSkipCoreInstallWhileSuperAgentIsInstalled(t *testing
Build()

err := recipeInstall.install(context.TODO())
//FIX:

//assert.NoError(t, err)
assert.Equal(t, "no recipes were installed", err.Error())
assert.Equal(t, 2, statusReporter.RecipeDetectedCallCount, "Detection Count")
assert.Equal(t, 1, statusReporter.RecipeAvailableCallCount, "Available Count")
Expand Down Expand Up @@ -589,7 +587,6 @@ func TestInstallSuperInstallAdditionalShouldInstallOnSuperAgentInstalled(t *test
}

func TestInstallOHIAdditionalShouldInstallOnSuperAgentInstalled(t *testing.T) {

r2 := &recipes.RecipeDetectionResult{
Recipe: recipes.NewRecipeBuilder().Name("recipe1").Build(),
Status: execution.RecipeStatusTypes.AVAILABLE,
Expand Down
29 changes: 0 additions & 29 deletions internal/install/recipes/bundler.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func (b *Bundler) CreateAdditionalGuidedBundle() *Bundle {
var recipes []string

for _, d := range b.AvailableRecipes {
//FIX: SUPER continue
if !coreRecipeMap[d.Recipe.Name] {
if !strings.EqualFold(d.Recipe.Name, types.SuperAgentRecipeName) {
recipes = append(recipes, d.Recipe.Name)
Expand Down Expand Up @@ -86,13 +85,6 @@ func (b *Bundler) createBundle(recipes []string, bType BundleType) *Bundle {
bundleRecipe = b.getBundleRecipeWithDependencies(d.Recipe)

if bundleRecipe != nil {
//FIX:
// Reset super agent if made available
// Reset can be done to INSTALLED, NULL
// cases
// - OHI dependency => should be silenced if dependency is present and no it the list of recipes
// - Infra
// - Super agent => super is given as input
isSuperInput := utils.StringInSlice(types.SuperAgentRecipeName, recipes)
if dep, found := findRecipeDependency(bundleRecipe, types.SuperAgentRecipeName); !isSuperInput && found {
log.Debugf("updating the dependency status for %s", dep)
Expand All @@ -117,27 +109,6 @@ func (b *Bundler) createBundle(recipes []string, bType BundleType) *Bundle {
return bundle
}

// FIX: Remove this
// func checkSuper() {
// for _, dependency := range bundleRecipe.Dependencies {
// foundInRecipes := false
// for _, recipe := range recipes {
// if dependency.Recipe.Name == recipe {
// foundInRecipes = true
// break
// }
// }
// if !foundInRecipes {
// log.Debugf("Found dependency %s", dependency.Recipe.Name)
// // FIX: TEST this
// if dep, ok := findRecipeDependency(dependency, types.SuperAgentRecipeName); ok {
// log.Debugf("updating the dependency status for %s", dep)
// dep.AddDetectionStatus(execution.RecipeStatusTypes.INSTALLED, 0)
// }
// }
// }
// }

// findRecipeDependency recursively searches for a recipe dependency
func findRecipeDependency(recipe *BundleRecipe, name string) (*BundleRecipe, bool) {
if strings.EqualFold(recipe.Recipe.Name, name) {
Expand Down

0 comments on commit a921e4c

Please sign in to comment.