@@ -268,39 +268,39 @@ func (scopeSrv *ScopeSrvHelper[C, S, SC]) getAffectedTables() ([]string, errors.
268268 if err != nil {
269269 return nil , err
270270 }
271- if pluginModel , ok := meta .(plugin.PluginModel ); ! ok {
271+ pluginModel , ok := meta .(plugin.PluginModel )
272+ if ! ok {
272273 panic (errors .Default .New (fmt .Sprintf ("plugin \" %s\" does not implement listing its tables" , scopeSrv .pluginName )))
273- } else {
274- // Unfortunately, can't cache the tables because Python creates some tables on a per-demand basis, so such a cache would possibly get outdated.
275- // It's a rare scenario in practice, but might as well play it safe and sacrifice some performance here
276- var allTables []string
277- if allTables , err = scopeSrv .db .AllTables (); err != nil {
278- return nil , err
279- }
280- // collect raw tables
281- for _ , table := range allTables {
282- if strings .HasPrefix (table , "_raw_" + scopeSrv .pluginName ) {
283- tables = append (tables , table )
284- }
274+ }
275+ // Unfortunately, can't cache the tables because Python creates some tables on a per-demand basis, so such a cache would possibly get outdated.
276+ // It's a rare scenario in practice, but might as well play it safe and sacrifice some performance here
277+ var allTables []string
278+ if allTables , err = scopeSrv .db .AllTables (); err != nil {
279+ return nil , err
280+ }
281+ // collect raw tables
282+ for _ , table := range allTables {
283+ if strings .HasPrefix (table , "_raw_" + scopeSrv .pluginName ) {
284+ tables = append (tables , table )
285285 }
286- // collect tool tables
287- toolModels := pluginModel . GetTablesInfo ()
288- for _ , toolModel := range toolModels {
289- if ! isScopeModel ( toolModel ) && hasField ( toolModel , "RawDataParams" ) {
290- tables = append ( tables , toolModel . TableName ())
291- }
286+ }
287+ // collect tool tables
288+ toolModels := pluginModel . GetTablesInfo ()
289+ for _ , toolModel := range toolModels {
290+ if ! isScopeModel ( toolModel ) && hasField ( toolModel , "RawDataParams" ) {
291+ tables = append ( tables , toolModel . TableName ())
292292 }
293- // collect domain tables
294- for _ , domainModel := range domaininfo . GetDomainTablesInfo () {
295- // we only care about tables with RawOrigin
296- ok = hasField ( domainModel , "RawDataParams" )
297- if ok {
298- tables = append ( tables , domainModel . TableName ())
299- }
293+ }
294+ // collect domain tables
295+ for _ , domainModel := range domaininfo . GetDomainTablesInfo () {
296+ // we only care about tables with RawOrigin
297+ ok = hasField ( domainModel , "RawDataParams" )
298+ if ok {
299+ tables = append ( tables , domainModel . TableName ())
300300 }
301- // additional tables
302- tables = append (tables , models.CollectorLatestState {}.TableName ())
303301 }
302+ // additional tables
303+ tables = append (tables , models.CollectorLatestState {}.TableName ())
304304 scopeSrv .log .Debug ("Discovered %d tables used by plugin \" %s\" : %v" , len (tables ), scopeSrv .pluginName , tables )
305305 return tables , nil
306306}
0 commit comments