You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ne...@apache.org on 2018/10/17 19:44:49 UTC

[trafficcontrol] 03/08: Add TO Go cli flag to list plugins

This is an automated email from the ASF dual-hosted git repository.

neuman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 2348d118dcca9639f85600d1ac8a6d4e6b0ab7f5
Author: Robert Butts <ro...@apache.org>
AuthorDate: Wed Jul 18 08:41:24 2018 -0600

    Add TO Go cli flag to list plugins
---
 traffic_ops/traffic_ops_golang/plugin/plugin.go      | 9 +++++++++
 traffic_ops/traffic_ops_golang/traffic_ops_golang.go | 6 ++++++
 2 files changed, 15 insertions(+)

diff --git a/traffic_ops/traffic_ops_golang/plugin/plugin.go b/traffic_ops/traffic_ops_golang/plugin/plugin.go
index 14a6c6d..2c2ab79 100644
--- a/traffic_ops/traffic_ops_golang/plugin/plugin.go
+++ b/traffic_ops/traffic_ops_golang/plugin/plugin.go
@@ -29,6 +29,15 @@ import (
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/config"
 )
 
+// List returns the list of plugins compiled into the calling executable.
+func List() []string {
+	l := []string{}
+	for _, p := range initPlugins {
+		l = append(l, p.name)
+	}
+	return l
+}
+
 func Get(appCfg config.Config) Plugins {
 	log.Infof("plugin.Get given: %+v\n", appCfg.Plugins)
 	pluginSlice := getEnabled(appCfg.Plugins)
diff --git a/traffic_ops/traffic_ops_golang/traffic_ops_golang.go b/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
index c93e954..1941293 100644
--- a/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
+++ b/traffic_ops/traffic_ops_golang/traffic_ops_golang.go
@@ -29,6 +29,7 @@ import (
 	"os/signal"
 	"path/filepath"
 	"runtime/pprof"
+	"strings"
 	"time"
 
 	"github.com/apache/trafficcontrol/lib/go-log"
@@ -51,6 +52,7 @@ func init() {
 
 func main() {
 	showVersion := flag.Bool("version", false, "Show version and exit")
+	showPlugins := flag.Bool("plugins", false, "Show the list of plugins and exit")
 	configFileName := flag.String("cfg", "", "The config file path")
 	dbConfigFileName := flag.String("dbcfg", "", "The db config file path")
 	riakConfigFileName := flag.String("riakcfg", "", "The riak config file path")
@@ -60,6 +62,10 @@ func main() {
 		fmt.Println(about.About.RPMVersion)
 		os.Exit(0)
 	}
+	if *showPlugins {
+		fmt.Println(strings.Join(plugin.List(), "\n"))
+		os.Exit(0)
+	}
 	if len(os.Args) < 2 {
 		flag.Usage()
 		os.Exit(1)