Skip to content

Commit

Permalink
Fix module integration
Browse files Browse the repository at this point in the history
NewEvent() doesn't return Modules as nil, which was preventing this integration from working.
The extra flag was added to prevent repeatedly trying to cache the modules if getModules() returned nil.
  • Loading branch information
faulkner committed Oct 6, 2019
1 parent cafc6f8 commit 3d1490f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions integrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
type modulesIntegration struct{}

var _modulesCache map[string]string // nolint: gochecknoglobals
var _modulesCached bool // nolint: gochecknoglobals

func (mi *modulesIntegration) Name() string {
return "Modules"
Expand All @@ -29,18 +30,19 @@ func (mi *modulesIntegration) SetupOnce(client *Client) {
}

func (mi *modulesIntegration) processor(event *Event, hint *EventHint) *Event {
if event.Modules == nil {
if len(event.Modules) == 0 {
event.Modules = extractModules()
}

return event
}

func extractModules() map[string]string {
if _modulesCache != nil {
if _modulesCached {
return _modulesCache
}

_modulesCached = true
extractedModules, err := getModules()
if err != nil {
Logger.Printf("ModuleIntegration wasn't able to extract modules: %v\n", err)
Expand Down

0 comments on commit 3d1490f

Please sign in to comment.