代码拉取完成,页面将自动刷新
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"github.com/elastic/beats/libbeat/template"
"github.com/elastic/beats/libbeat/version"
)
// main generates index templates for the beats
func main() {
beatVersion := version.GetDefaultVersion()
index := flag.String("index", "", "Base index name. Normally {beat_name} (required)")
output := flag.String("output", "", "Required: Full path to the output file (required)")
version := flag.String("es.version", beatVersion, "Elasticsearch version")
file := flag.String("file", "", "Path to fields.yml file")
flag.Parse()
if len(*file) == 0 {
fmt.Fprintf(os.Stderr, "File path cannot be empty")
os.Exit(1)
}
if *index == "" {
fmt.Fprintf(os.Stderr, "index is empty. It must be set.")
os.Exit(1)
}
if _, err := os.Stat(*file); err != nil {
fmt.Fprintf(os.Stderr, "Error during loading -file %s with error: %s", *file, err)
os.Exit(1)
}
// Make it compatible with the sem versioning
if *version == "2x" {
*version = "2.0.0"
}
tmpl, err := template.New(beatVersion, *version, *index, template.TemplateSettings{})
if err != nil {
fmt.Fprintf(os.Stderr, "Error generating template: %+v", err)
os.Exit(1)
}
templateString, err := tmpl.Load(*file)
if err != nil {
fmt.Fprintf(os.Stderr, "Error generating template: %+v", err)
os.Exit(1)
}
err = ioutil.WriteFile(*output, []byte(templateString.StringToPrint()), 0644)
if err != nil {
fmt.Fprintf(os.Stderr, "Error writing output: %s", err)
os.Exit(1)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。