Fetch the repository succeeded.
kubernetes
processor -> add_kubernetes_metadata
(#4473)
package add_kubernetes_metadata
import (
"errors"
"fmt"
p "github.com/elastic/beats/libbeat/plugin"
)
var (
indexerKey = "libbeat.processor.kubernetes.indexer"
matcherKey = "libbeat.processor.kubernetes.matcher"
)
type indexerPlugin struct {
name string
constructor IndexerConstructor
}
func IndexerPlugin(name string, c IndexerConstructor) map[string][]interface{} {
return p.MakePlugin(indexerKey, indexerPlugin{name, c})
}
type matcherPlugin struct {
name string
constructor MatcherConstructor
}
func MatcherPlugin(name string, m MatcherConstructor) map[string][]interface{} {
return p.MakePlugin(matcherKey, matcherPlugin{name, m})
}
func init() {
p.MustRegisterLoader(indexerKey, func(ifc interface{}) error {
i, ok := ifc.(indexerPlugin)
if !ok {
return errors.New("plugin does not match output plugin type")
}
name := i.name
if Indexing.indexers[name] != nil {
return fmt.Errorf("indexer type %v already registered", name)
}
Indexing.AddIndexer(name, i.constructor)
return nil
})
p.MustRegisterLoader(matcherKey, func(ifc interface{}) error {
m, ok := ifc.(matcherPlugin)
if !ok {
return errors.New("plugin does not match output plugin type")
}
name := m.name
if Indexing.indexers[name] != nil {
return fmt.Errorf("matcher type %v already registered", name)
}
Indexing.AddMatcher(name, m.constructor)
return nil
})
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。