11package docker
22
33import (
4- "os "
4+ "fmt "
55 "path/filepath"
66
77 "github.com/utmstack/UTMStack/installer/config"
88 "github.com/utmstack/UTMStack/installer/utils"
9- "gopkg.in/yaml.v3"
109)
1110
1211type PluginsConfig struct {
1312 Plugins map [string ]PluginConfig `yaml:"plugins"`
1413}
1514
1615type PluginConfig struct {
17- RulesFolder string `yaml:"rulesFolder"`
18- GeoIPFolder string `yaml:"geoipFolder"`
19- Elasticsearch string `yaml:"elasticsearch"`
20- PostgreSQL PostgreConfig `yaml:"postgresql"`
21- ServerName string `yaml:"serverName"`
22- InternalKey string `yaml:"internalKey"`
23- AgentManager string `yaml:"agentManager"`
24- Backend string `yaml:"backend"`
25- CertsFolder string `yaml:"certsFolder"`
26- BdgzPort string `yaml:"bdgzPort"`
16+ Order []string `yaml:"order,omitempty"`
17+ Port int `yaml:"port,omitempty"`
18+ RulesFolder string `yaml:"rulesFolder,omitempty"`
19+ GeoIPFolder string `yaml:"geoipFolder,omitempty"`
20+ Elasticsearch string `yaml:"elasticsearch,omitempty"`
21+ PostgreSQL PostgreConfig `yaml:"postgresql,omitempty"`
22+ ServerName string `yaml:"serverName,omitempty"`
23+ InternalKey string `yaml:"internalKey,omitempty"`
24+ AgentManager string `yaml:"agentManager,omitempty"`
25+ Backend string `yaml:"backend,omitempty"`
26+ CertsFolder string `yaml:"certsFolder,omitempty"`
2727}
2828
2929type PostgreConfig struct {
@@ -34,10 +34,37 @@ type PostgreConfig struct {
3434 Database string `yaml:"database"`
3535}
3636
37- func (c * PluginsConfig ) Set (conf * config.Config , stack * StackConfig ) error {
38- c .Plugins = make (map [string ]PluginConfig )
37+ func SetPluginsConfigs (conf * config.Config , stack * StackConfig ) error {
38+ analysisPipeline := PluginsConfig {}
39+ analysisPipeline .Plugins = make (map [string ]PluginConfig )
40+ analysisPipeline .Plugins ["analysis" ] = PluginConfig {
41+ Order : []string {"com.utmstack.events" , "cel" },
42+ }
43+
44+ correlationPipeline := PluginsConfig {}
45+ correlationPipeline .Plugins = make (map [string ]PluginConfig )
46+ correlationPipeline .Plugins ["correlation" ] = PluginConfig {
47+ Order : []string {"com.utmstack.events" },
48+ }
49+
50+ inputPipeline := PluginsConfig {}
51+ inputPipeline .Plugins = make (map [string ]PluginConfig )
52+ inputPipeline .Plugins ["http-input" ] = PluginConfig {
53+ Port : 8082 ,
54+ }
55+ inputPipeline .Plugins ["grpc-input" ] = PluginConfig {
56+ Port : 8083 ,
57+ }
3958
40- c .Plugins ["com.utmstack" ] = PluginConfig {
59+ notificationPipeline := PluginsConfig {}
60+ notificationPipeline .Plugins = make (map [string ]PluginConfig )
61+ notificationPipeline .Plugins ["notification" ] = PluginConfig {
62+ Order : []string {"com.utmstack.stats" },
63+ }
64+
65+ utmstackPipeline := PluginsConfig {}
66+ utmstackPipeline .Plugins = make (map [string ]PluginConfig )
67+ utmstackPipeline .Plugins ["com.utmstack" ] = PluginConfig {
4168 RulesFolder : "/workdir/rules" ,
4269 GeoIPFolder : "/workdir/geolocation" ,
4370 Elasticsearch : "http://node1:9200" ,
@@ -55,23 +82,33 @@ func (c *PluginsConfig) Set(conf *config.Config, stack *StackConfig) error {
5582 CertsFolder : "/cert" ,
5683 }
5784
58- config , err := yaml .Marshal (c )
85+ pipelineDir := filepath .Join (stack .EventsEngineWorkdir , "pipeline" )
86+ utils .CreatePathIfNotExist (pipelineDir )
87+
88+ err := utils .WriteYAML (filepath .Join (pipelineDir , "system_plugins_analysis.yaml" ), analysisPipeline )
5989 if err != nil {
60- return err
90+ return fmt . Errorf ( "error writing analysis pipeline config: %w" , err )
6191 }
6292
63- pipelineDir := filepath .Join (stack .EventsEngineWorkdir , "pipeline" )
93+ err = utils .WriteYAML (filepath .Join (pipelineDir , "system_plugins_correlation.yaml" ), correlationPipeline )
94+ if err != nil {
95+ return fmt .Errorf ("error writing correlation pipeline config: %w" , err )
96+ }
6497
65- utils .CreatePathIfNotExist (pipelineDir )
98+ err = utils .WriteYAML (filepath .Join (pipelineDir , "system_plugins_input.yaml" ), inputPipeline )
99+ if err != nil {
100+ return fmt .Errorf ("error writing input pipeline config: %w" , err )
101+ }
66102
67- err = os . WriteFile (filepath .Join (pipelineDir , "utmstack_plugins .yaml" ), config , 0644 )
103+ err = utils . WriteYAML (filepath .Join (pipelineDir , "system_plugins_notification .yaml" ), notificationPipeline )
68104 if err != nil {
69- return err
105+ return fmt . Errorf ( "error writing notification pipeline config: %w" , err )
70106 }
71107
72- return nil
73- }
108+ err = utils .WriteYAML (filepath .Join (pipelineDir , "utmstack_plugins.yaml" ), utmstackPipeline )
109+ if err != nil {
110+ return fmt .Errorf ("error writing UTMStack pipeline config: %w" , err )
111+ }
74112
75- func (c * PluginsConfig ) UpdatePlugings () error {
76113 return nil
77114}
0 commit comments