-
Notifications
You must be signed in to change notification settings - Fork 524
/
generate_imports.py
45 lines (31 loc) · 1.06 KB
/
generate_imports.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
import sys
# Generates the file list.go with all processors
header = """/*
Package include imports all processor packages so that they register with the global
registry. This package can be imported in the main package to automatically register
all of the standard supported apm-server processors.
*/
package include
import (
\t// This list is automatically generated by `make imports`
"""
def generate(go_beat_path):
base_dir = "processor"
path = os.path.abspath("processor")
list_file = header
# Fetch all protocols
for protocol in sorted(os.listdir(base_dir)):
if protocol == "model":
continue
if os.path.isfile(path + "/" + protocol):
continue
list_file += ' _ "' + go_beat_path + '/processor/' + protocol + '"\n'
list_file += ")"
# output string so it can be concatenated
print(list_file)
if __name__ == "__main__":
# First argument is the beat path under GOPATH.
# (e.g. github.com/elastic/beats/packetbeat)
go_beat_path = sys.argv[1]
generate(go_beat_path)