-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New subcommand: generate #6912
New subcommand: generate #6912
Conversation
libbeat/generator/fields/fields.go
Outdated
return bytes.Join([][]byte{newline, content}, empty) | ||
} | ||
|
||
func Generate(beatsPath, beatName string, files []*YmlFile) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported function Generate should have comment or be unexported
libbeat/generator/fields/fields.go
Outdated
libbeatFields = "libbeat/processors/*/_meta/fields.yml" | ||
) | ||
|
||
type YmlFile struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported type YmlFile should have comment or be unexported
@@ -418,6 +419,38 @@ func (b *Beat) Setup(bt beat.Creator, template, dashboards, machineLearning, pip | |||
}()) | |||
} | |||
|
|||
// Setup registers ES index template and kibana dashboards |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment on exported method Beat.GenerateGlobalFields should be of the form "GenerateGlobalFields ..."
) | ||
|
||
var ( | ||
BeatsPath = flag.String("beats_path", "..", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported var BeatsPath should have comment or be unexported
|
||
err = writeFieldsYml(beatsPath, moduleName, filesetName, d) | ||
if err != nil { | ||
return fmt.Errorf("cannot write field.yml of fileset: %v\n", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error strings should not be capitalized or end with punctuation or a newline
var d []byte | ||
d, err = p.toFieldsYml(noDoc) | ||
if err != nil { | ||
return fmt.Errorf("cannot generate fields.yml for fileset: %v\n", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error strings should not be capitalized or end with punctuation or a newline
func Generate(moduleName, filesetName, beatsPath string, noDoc bool) error { | ||
p, err := readPipeline(beatsPath, moduleName, filesetName) | ||
if err != nil { | ||
return fmt.Errorf("cannot read pipeline.yml of fileset: %v\n", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error strings should not be capitalized or end with punctuation or a newline
return nil | ||
} | ||
|
||
func Generate(moduleName, filesetName, beatsPath string, noDoc bool) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported function Generate should have comment or be unexported
|
||
modulePath := path.Join(modulesPath, "module", moduleName) | ||
if !generator.DirExists(modulePath) { | ||
return fmt.Errorf("cannot generate fileset: module not exists, please create module first by create-module command\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error strings should not be capitalized or end with punctuation or a newline
16b848e
to
74dd3ea
Compare
619b9e8
to
789170a
Compare
I rebased the PR. But it still has a few minor problems, before it becomes ready to review. |
Closing in favour of #9314 |
A new subcommand is added named
generate
to all Beats. This command has a few more subcommands in case of Filebeat.Motivation
This is the next baby step to removing Python from
make update
and making it possible for all users without development envs to generate files, if they edited something locally (including generating FB module).Subcommands in case of all Beats (e.g. Metricbeat):
Subcommands of
generate
:global-fields
: The existingfields.yml
collector is ported to Golang and is unified for all Beats. The behaviour is not changed. The collectedfields.yml
files are concatenated into one globalfields.yml
and placed under_meta
.kibana-index-pattern
: The existing Golang script is exposed as a subcommand.Subcommands of Filebeat:
Special subcommands of Filebeat:
fields
: Existing script is exposed.fileset
: Existing script is exposed.module
: Existing script is exposed.Misc additions
filebeat/generator
fromfilebeat/scripts/generator
keystore
TODO
Depends on: #6911