Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rtorrero committed Nov 16, 2022
1 parent 4d97f04 commit 7865867
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,29 @@ package gatherers
import (
log "github.com/sirupsen/logrus"
"github.com/trento-project/agent/internal/factsengine/entities"
"github.com/trento-project/agent/internal/utils"
)

const (
PackageVersionGathererName = "package_version"
)

type PackageVersionGatherer struct {
executor CommandExecutor
executor utils.CommandExecutor
}

func NewDefaultPackageVersionGatherer() *PackageVersionGatherer {
return NewPackageVersionGatherer(Executor{})
return NewPackageVersionGatherer(utils.Executor{})
}

func NewPackageVersionGatherer(executor CommandExecutor) *PackageVersionGatherer {
func NewPackageVersionGatherer(executor utils.CommandExecutor) *PackageVersionGatherer {
return &PackageVersionGatherer{
executor: executor,
}
}

func (g *PackageVersionGatherer) Gather(factsRequests []entities.FactRequest) ([]entities.FactsGatheredItem, error) {
facts := []entities.FactsGatheredItem{}
func (g *PackageVersionGatherer) Gather(factsRequests []entities.FactRequest) ([]entities.Fact, error) {
facts := []entities.Fact{}
log.Infof("Starting Package versions facts gathering process")

for _, factReq := range factsRequests {
Expand All @@ -34,7 +35,8 @@ func (g *PackageVersionGatherer) Gather(factsRequests []entities.FactRequest) ([
// TODO: Decide together with Wanda how to deal with errors. `err` field in the fact result?
log.Errorf("Error getting version of package: %s", factReq.Argument)
}
fact := entities.NewFactGatheredWithRequest(factReq, string(version))

fact := entities.NewFactGatheredWithRequest(factReq, entities.ParseStringToFactValue(string(version)))
facts = append(facts, fact)
}

Expand Down

0 comments on commit 7865867

Please sign in to comment.