Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
CDimonaco committed Sep 23, 2022
1 parent cf37647 commit 91e8eb9
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions cmd/facts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/spf13/viper"

"github.com/trento-project/agent/internal"
"github.com/trento-project/agent/internal/factsengine"
"github.com/trento-project/agent/internal/factsengine/entities"
"github.com/trento-project/agent/internal/factsengine/gatherers"
"github.com/trento-project/agent/internal/utils"
Expand Down Expand Up @@ -102,13 +101,11 @@ func gather(*cobra.Command, []string) {

gathererManager.AddGatherers(gatherersFromPlugins)

engine := factsengine.NewFactsEngine("", "", *gathererManager)

defer gatherers.CleanupPlugins()

g, err := gathererManager.GetGatherer(gatherer)
if err != nil {
cleanupAndFatal(engine, err)
cleanupAndFatal(err)
}

factRequest := []entities.FactRequest{
Expand All @@ -120,19 +117,19 @@ func gather(*cobra.Command, []string) {

value, err := g.Gather(factRequest)
if err != nil {
cleanupAndFatal(engine, err)
cleanupAndFatal(err)
}

result, err := utils.PrettifyInterfaceToJSON(value[0])
if err != nil {
cleanupAndFatal(engine, err)
cleanupAndFatal(err)
}

log.Printf("Gathered fact for \"%s\" with argument \"%s\":", gatherer, argument)
log.Printf("%s", result)
}

func cleanupAndFatal(engine *factsengine.FactsEngine, err error) {
func cleanupAndFatal(err error) {
gatherers.CleanupPlugins()
log.Fatal(err)
}
Expand Down

0 comments on commit 91e8eb9

Please sign in to comment.