Skip to content

Commit

Permalink
Enable plugin filtering for deprecation list.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Rebhan committed Oct 14, 2021
1 parent 9043900 commit 4316f39
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/telegraf/telegraf.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,12 @@ func main() {
case *fDeprecationList:
c := config.NewConfig()
c.VersionMajor, c.VersionMinor = config.ParseVersion(version)
infos := c.CollectDeprecationInfos()
infos := c.CollectDeprecationInfos(
inputFilters,
outputFilters,
aggregatorFilters,
processorFilters,
)
//nolint:revive // We will notice if Println fails
fmt.Println("Deprecated Input Plugins: ")
c.PrintDeprecationList(infos["inputs"])
Expand Down
18 changes: 17 additions & 1 deletion config/deprecation.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,15 @@ func (c *Config) printUserDeprecation(category, name string, plugin interface{})
return nil
}

func (c *Config) CollectDeprecationInfos() map[string][]PluginDeprecationInfo {
func (c *Config) CollectDeprecationInfos(inFilter, outFilter, aggFilter, procFilter []string) map[string][]PluginDeprecationInfo {
infos := make(map[string][]PluginDeprecationInfo)

infos["inputs"] = make([]PluginDeprecationInfo, 0)
for name, creator := range inputs.Inputs {
if len(inFilter) > 0 && !sliceContains(name, inFilter) {
continue
}

plugin := creator()
info := c.collectDeprecationInfo("inputs", name, plugin, true)

Expand All @@ -180,6 +184,10 @@ func (c *Config) CollectDeprecationInfos() map[string][]PluginDeprecationInfo {

infos["outputs"] = make([]PluginDeprecationInfo, 0)
for name, creator := range outputs.Outputs {
if len(outFilter) > 0 && !sliceContains(name, outFilter) {
continue
}

plugin := creator()
info := c.collectDeprecationInfo("outputs", name, plugin, true)

Expand All @@ -190,6 +198,10 @@ func (c *Config) CollectDeprecationInfos() map[string][]PluginDeprecationInfo {

infos["processors"] = make([]PluginDeprecationInfo, 0)
for name, creator := range processors.Processors {
if len(procFilter) > 0 && !sliceContains(name, procFilter) {
continue
}

plugin := creator()
info := c.collectDeprecationInfo("processors", name, plugin, true)

Expand All @@ -200,6 +212,10 @@ func (c *Config) CollectDeprecationInfos() map[string][]PluginDeprecationInfo {

infos["aggregators"] = make([]PluginDeprecationInfo, 0)
for name, creator := range aggregators.Aggregators {
if len(aggFilter) > 0 && !sliceContains(name, aggFilter) {
continue
}

plugin := creator()
info := c.collectDeprecationInfo("aggregators", name, plugin, true)

Expand Down

0 comments on commit 4316f39

Please sign in to comment.