Skip to content

Commit 7cc99e0

Browse files
Kbayeroylladaosmonteromjabascal10
authored
Bugfix/10.8.0/macos (#1174)
* feat: Improve installer to add RHELD support * fix: Update windows ARM collector * wip * feat: Add SELinux configuration for RedHat systems * fix interface agent problem * add bad gateway page * complete macos agent * feat(module-integration): add SOC AI model selection field * feat(module-integration): add SOC AI model selection field * feat(module-integration): add SOC AI model selection field * feat(module-integration): update MacOS guide * fix custom bad gateway page creation * not contains operator grammar(Jose Angel) * fix(agent-details): show correct agent version and format OS version * Update and publish SOC-AI models * Update UTMStack Version * update service agent problem * fix nil pointer --------- Co-authored-by: Yadian Llada Lopez <[email protected]> Co-authored-by: Osmany Montero <[email protected]> Co-authored-by: Manuel Abascal <[email protected]>
1 parent 52f14e7 commit 7cc99e0

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

soc-ai/configurations/config.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package configurations
22

33
import (
4+
"sync"
45
"time"
56

67
UTMStackConfigurationClient "github.com/utmstack/config-client-go"
@@ -9,7 +10,8 @@ import (
910
)
1011

1112
var (
12-
gptConfig GPTConfig
13+
gptConfig GPTConfig
14+
gptConfigOnce sync.Once
1315
)
1416

1517
type GPTConfig struct {
@@ -21,10 +23,14 @@ type GPTConfig struct {
2123
}
2224

2325
func GetGPTConfig() *GPTConfig {
26+
gptConfigOnce.Do(func() {
27+
gptConfig = GPTConfig{}
28+
})
29+
2430
return &gptConfig
2531
}
2632

27-
func UpdateGPTConfigurations() {
33+
func (c *GPTConfig) UpdateGPTConfigurations() {
2834
intKey := GetInternalKey()
2935
panelServ := GetPanelServiceName()
3036
client := UTMStackConfigurationClient.NewUTMClient(intKey, panelServ)
@@ -41,26 +47,26 @@ func UpdateGPTConfigurations() {
4147
continue
4248
}
4349

44-
gptConfig.ModuleActive = tempModuleConfig.ModuleActive
50+
c.ModuleActive = tempModuleConfig.ModuleActive
4551

46-
if gptConfig.ModuleActive && tempModuleConfig != nil && len(tempModuleConfig.ConfigurationGroups) > 0 {
52+
if c.ModuleActive && tempModuleConfig != nil && len(tempModuleConfig.ConfigurationGroups) > 0 {
4753
for _, config := range tempModuleConfig.ConfigurationGroups[0].Configurations {
4854
switch config.ConfKey {
4955
case "utmstack.socai.key":
5056
if config.ConfValue != "" && config.ConfValue != " " {
51-
gptConfig.APIKey = config.ConfValue
57+
c.APIKey = config.ConfValue
5258
}
5359
case "utmstack.socai.incidentCreation":
5460
if config.ConfValue != "" && config.ConfValue != " " {
55-
gptConfig.AutomaticIncidentCreation = config.ConfValue == "true"
61+
c.AutomaticIncidentCreation = config.ConfValue == "true"
5662
}
5763
case "utmstack.socai.changeAlertStatus":
5864
if config.ConfValue != "" && config.ConfValue != " " {
59-
gptConfig.ChangeAlertStatus = config.ConfValue == "true"
65+
c.ChangeAlertStatus = config.ConfValue == "true"
6066
}
6167
case "utmstack.socai.model":
6268
if config.ConfValue != "" && config.ConfValue != " " {
63-
gptConfig.Model = config.ConfValue
69+
c.Model = config.ConfValue
6470
}
6571
}
6672
}

soc-ai/processor/processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func NewProcessor() *Processor {
3737
func (p *Processor) ProcessData() {
3838
utils.Logger.Info("Starting SOC-AI Processor...")
3939

40-
go configurations.UpdateGPTConfigurations()
40+
go configurations.GetGPTConfig().UpdateGPTConfigurations()
4141
go p.restRouter()
4242
go p.processAlertsInfo()
4343

0 commit comments

Comments
 (0)