From 63d6a72727d69870b29e50a7f05e77cbfc301dce Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sun, 6 Oct 2019 17:35:26 +0000 Subject: [PATCH] feature: allow user to disable plugins via command-line flag --- prog/main.go | 2 +- prog/probe.go | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/prog/main.go b/prog/main.go index bd4e488c0..e44755228 100644 --- a/prog/main.go +++ b/prog/main.go @@ -299,7 +299,7 @@ func setupFlags(flags *flags) { flag.DurationVar(&flags.probe.publishInterval, "probe.publish.interval", 3*time.Second, "publish (output) interval") flag.DurationVar(&flags.probe.spyInterval, "probe.spy.interval", time.Second, "spy (scan) interval") flag.IntVar(&flags.probe.ticksPerFullReport, "probe.full-report-every", 3, "publish full report every N times, deltas in between. Make sure N < (app.window / probe.publish.interval)") - flag.StringVar(&flags.probe.pluginsRoot, "probe.plugins.root", "/var/run/scope/plugins", "Root directory to search for plugins") + flag.StringVar(&flags.probe.pluginsRoot, "probe.plugins.root", "/var/run/scope/plugins", "Root directory to search for plugins (disable plugins if blank)") flag.BoolVar(&flags.probe.noControls, "probe.no-controls", false, "Disable controls (e.g. start/stop containers, terminals, logs ...)") flag.BoolVar(&flags.probe.noCommandLineArguments, "probe.omit.cmd-args", false, "Disable collection of command-line arguments") flag.BoolVar(&flags.probe.noEnvironmentVariables, "probe.omit.env-vars", true, "Disable collection of environment variables") diff --git a/prog/probe.go b/prog/probe.go index 9814d76c9..e69ff4984 100644 --- a/prog/probe.go +++ b/prog/probe.go @@ -351,21 +351,23 @@ func probeMain(flags probeFlags, targets []appclient.Target) { } } - pluginRegistry, err := plugins.NewRegistry( - flags.pluginsRoot, - pluginAPIVersion, - map[string]string{ - "probe_id": probeID, - "api_version": pluginAPIVersion, - }, - handlerRegistry, - p, - ) - if err != nil { - log.Errorf("plugins: problem loading: %v", err) - } else { - defer pluginRegistry.Close() - p.AddReporter(pluginRegistry) + if flags.pluginsRoot != "" { + pluginRegistry, err := plugins.NewRegistry( + flags.pluginsRoot, + pluginAPIVersion, + map[string]string{ + "probe_id": probeID, + "api_version": pluginAPIVersion, + }, + handlerRegistry, + p, + ) + if err != nil { + log.Errorf("plugins: problem loading: %v", err) + } else { + defer pluginRegistry.Close() + p.AddReporter(pluginRegistry) + } } maybeExportProfileData(flags)