Skip to content

Commit

Permalink
fixing duplicate facts bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Clifford committed Oct 13, 2021
1 parent fd50fa6 commit b7aab19
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
10 changes: 4 additions & 6 deletions cmd/gather.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,12 @@ var gatherCmd = &cobra.Command{
log.Println(err.Error())
continue
}
if verbose := viper.Get("verbose"); verbose == true {
for _, f := range gatheredFacts {
if f.Value != "" {
log.Printf("Registering %s", f.Name)
facts = append(facts, gatheredFacts...)
}
for _, f := range gatheredFacts {
if verbose := viper.Get("verbose"); verbose == true {
log.Printf("Registering %s", f.Name)
}
}
facts = append(facts, gatheredFacts...)
}
}
}
Expand Down
16 changes: 9 additions & 7 deletions gatherers/DrushPMLGatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ func (p *drushPmlGatherer) AppliesToEnvironment() bool {
}

for key, element := range result {
p.GatheredFacts = append(p.GatheredFacts, GatheredFact{
Name: key,
Value: fmt.Sprintf("%v", element.Version),
Source: "drush_pml",
Description: "Drupal " + element.Type + " status: " + element.Status,
Category: Drupal,
})
if element.Version != nil {
p.GatheredFacts = append(p.GatheredFacts, GatheredFact{
Name: key,
Value: fmt.Sprintf("%v", element.Version),
Source: "drush_pml",
Description: "Status: " + element.Status,
Category: Drupal,
})
}
}

return true
Expand Down
4 changes: 2 additions & 2 deletions gatherers/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type GatheredFact struct {
Source string `json:"source"`
Environment int `json:"environment"`
Description string `json:"description"`
Category FactCategory `json:"-"` //`json:"category,omitempty"`
Category FactCategory `json:"-"` // `json:"category,omitempty"`
}

const (
Expand All @@ -17,7 +17,7 @@ const (

type Gatherer interface {
GetGathererCmdType() string
AppliesToEnvironment() bool //Whether this gatherer can run in the local environment
AppliesToEnvironment() bool // Whether this gatherer can run in the local environment
GatherFacts() ([]GatheredFact, error)
}

Expand Down
2 changes: 2 additions & 0 deletions gatherers/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ func Writefacts(projectName string, environmentName string, facts []GatheredFact

client, err := getGraphqlClient()
if err != nil {
log.Println(err)
return err
}

var addFactMutation struct {
AddFacts []struct {
Id int
Expand Down

0 comments on commit b7aab19

Please sign in to comment.