1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
removed.go 980 Bytes
一键复制 编辑 原始数据 按行查看 历史
package cfgwarn
import (
"fmt"
"strings"
"github.com/joeshaw/multierror"
"github.com/elastic/beats/libbeat/common"
)
func CheckRemoved5xSettings(cfg *common.Config, settings ...string) error {
var errs multierror.Errors
for _, setting := range settings {
if err := CheckRemoved5xSetting(cfg, setting); err != nil {
errs = append(errs, err)
}
}
return errs.Err()
}
// CheckRemoved5xSetting prints a warning if the obsolete setting is used.
func CheckRemoved5xSetting(cfg *common.Config, setting string) error {
segments := strings.Split(setting, ".")
L := len(segments)
name := segments[L-1]
path := segments[:L-1]
current := cfg
for _, p := range path {
current, _ := current.Child(p, -1)
if current == nil {
break
}
}
// full path to setting not available -> setting not found
if current == nil {
return nil
}
if !current.HasField(name) {
return nil
}
return fmt.Errorf("setting '%v' has been removed", current.PathOf(name))
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v6.2.4

搜索帮助