forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 1
/
modules.go
30 lines (23 loc) · 806 Bytes
/
modules.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package cmd
import (
"strings"
"github.com/pkg/errors"
"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/cfgfile"
"github.com/elastic/beats/libbeat/cmd"
)
func buildModulesManager(beat *beat.Beat) (cmd.ModulesManager, error) {
config := beat.BeatConfig
glob, err := config.String("config.modules.path", -1)
if err != nil {
return nil, errors.Errorf("modules management requires 'metricbeat.config.modules.path' setting")
}
if !strings.HasSuffix(glob, "*.yml") {
return nil, errors.Errorf("wrong settings for config.modules.path, it is expected to end with *.yml. Got: %s", glob)
}
modulesManager, err := cfgfile.NewGlobManager(glob, ".yml", ".disabled")
if err != nil {
return nil, errors.Wrap(err, "initialization error")
}
return modulesManager, nil
}