Skip to content

Commit

Permalink
Run all loaded plugins by default
Browse files Browse the repository at this point in the history
The aggregator has a plugin filtering mechanism that
seems to actually complicate things for most users. Beyond
adding their plugin to the config map, they also have to
adjust the plugin selection.

This seems to have originated due to a desire for
flexibility (before knowing we needed it or not) and also
ease of testing.

This change just introduces special handling for the nil
selection (not empty, completely nil). In that case, all
plugins are run which are loaded.

ref #405

Signed-off-by: John Schnake <[email protected]>
  • Loading branch information
johnSchnake committed Apr 24, 2019
1 parent 35c8704 commit 7af1d5a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/plugin/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ func LoadAllPlugins(namespace, sonobuoyImage, imagePullPolicy string, searchPath
pluginDefinitions = append(pluginDefinitions, pluginDefinition)
}

pluginDefinitions = filterPluginDef(pluginDefinitions, selections)
// The zero value for the slice, nil, indicates that all plugins should be run.
// If the user wants to run 0 plugins, they should explicitly pass an empty array.
if selections != nil {
pluginDefinitions = filterPluginDef(pluginDefinitions, selections)
}

plugins := []plugin.Interface{}
for _, def := range pluginDefinitions {
Expand Down
10 changes: 10 additions & 0 deletions pkg/plugin/loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ func TestLoadAllPlugins(t *testing.T) {
plugin.Selection{Name: "test-daemon-set-plugin"},
},
expectedPluginNames: []string{"test-job-plugin", "test-daemon-set-plugin"},
}, {
testname: "nil selections defaults to run all",
searchPath: []string{path.Join("testdata", "onlyvalid")},
selections: nil,
expectedPluginNames: []string{"test-job-plugin", "test-daemon-set-plugin"},
}, {
testname: "empty (non-nil) selection runs none",
searchPath: []string{path.Join("testdata", "plugin.d")},
selections: []plugin.Selection{},
expectedPluginNames: []string{},
},
}

Expand Down
12 changes: 12 additions & 0 deletions pkg/plugin/loader/testdata/onlyvalid/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sonobuoy-config:
driver: DaemonSet
plugin-name: test-daemon-set-plugin
result-type: test-daemon-set-plugin
spec:
image: gcr.io/heptio-images/heptio-e2e:master
imagePullPolicy: Always
name: heptio-e2e
volumeMounts:
- mountPath: /tmp/results
name: results
readOnly: false
12 changes: 12 additions & 0 deletions pkg/plugin/loader/testdata/onlyvalid/job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sonobuoy-config:
driver: Job
plugin-name: test-job-plugin
result-type: test-job-plugin
spec:
image: gcr.io/heptio-images/heptio-e2e:master
imagePullPolicy: Always
name: heptio-e2e
volumeMounts:
- mountPath: /tmp/results
name: results
readOnly: false

0 comments on commit 7af1d5a

Please sign in to comment.