mirror of
https://github.com/turbot/steampipe.git
synced 2025-12-25 12:00:27 -05:00
* Add test demonstrating bug #4784 - OnConnectionConfigChanged panics with nil pool 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix #4784: Add nil pool check in handlePluginInstanceChanges 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package pluginmanager_service
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/turbot/pipe-fittings/v2/plugin"
|
|
"github.com/turbot/steampipe/v2/pkg/connection"
|
|
"github.com/turbot/steampipe/v2/pkg/db/db_local"
|
|
"golang.org/x/exp/maps"
|
|
)
|
|
|
|
func (m *PluginManager) handlePluginInstanceChanges(ctx context.Context, newPlugins connection.PluginMap) error {
|
|
if maps.EqualFunc(m.plugins, newPlugins, func(l *plugin.Plugin, r *plugin.Plugin) bool {
|
|
return l.Equals(r)
|
|
}) {
|
|
return nil
|
|
}
|
|
|
|
// now determine whether there are any new or deleted connections
|
|
//addedConnections, deletedConnections, changedConnections := m.plugins.Diff(newPlugins)
|
|
|
|
//m.handleDeletedPlugins(deletedConnections, requestMap)
|
|
//
|
|
//m.handleAddedPlugins(addedConnections, requestMap)
|
|
//m.handleUpdatedPlugins(changedConnections, requestMap)
|
|
|
|
// update connectionConfigMap
|
|
m.plugins = newPlugins
|
|
|
|
// if pool is nil, we're in a test environment or the plugin manager hasn't been fully initialized
|
|
// in this case, we can't repopulate the plugin table, so just return early
|
|
if m.pool == nil {
|
|
return nil
|
|
}
|
|
|
|
// repopulate the plugin table
|
|
conn, err := m.pool.Acquire(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer conn.Release()
|
|
return db_local.PopulatePluginTable(ctx, conn.Conn())
|
|
|
|
}
|