Automatically publish policies and logs during cluster initialization

This commit is contained in:
Liujian
2024-12-09 00:43:05 +08:00
parent bc00f2d577
commit 3dd44c97e9
5 changed files with 102 additions and 21 deletions
+5 -16
View File
@@ -25,23 +25,7 @@ type imlLogService struct {
}
func (i *imlLogService) OnComplete() {
drivers := log_driver.Drivers()
for _, d := range drivers {
factory, has := log_driver.GetFactory(d)
if !has {
continue
}
s, err := i.GetLogSource(context.Background(), d)
if err != nil {
continue
}
driver, _, err := factory.Create(s.Config)
if err != nil {
continue
}
log_driver.SetDriver(d, driver)
}
}
func (i *imlLogService) UpdateLogSource(ctx context.Context, driver string, input *Save) error {
@@ -80,6 +64,11 @@ func (i *imlLogService) UpdateLogSource(ctx context.Context, driver string, inpu
s.UpdateAt = time.Now()
}
err = i.store.Save(ctx, s)
if err != nil {
return err
}
return nil
}