github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/pkg/connection/plugin_limiter_map.go (about) 1 package connection 2 3 import ( 4 "github.com/turbot/steampipe/pkg/steampipeconfig/modconfig" 5 "golang.org/x/exp/maps" 6 ) 7 8 // PluginLimiterMap map of plugin image ref to Limiter map for the plugin 9 type PluginLimiterMap map[string]LimiterMap 10 11 func (l PluginLimiterMap) Equals(other PluginLimiterMap) bool { 12 return maps.EqualFunc(l, other, func(m1, m2 LimiterMap) bool { return m1.Equals(m2) }) 13 } 14 15 type PluginMap map[string]*modconfig.Plugin 16 17 func (p PluginMap) ToPluginLimiterMap() PluginLimiterMap { 18 var limiterPluginMap = make(PluginLimiterMap) 19 for pluginInstance, p := range p { 20 if len(p.Limiters) > 0 { 21 limiterPluginMap[pluginInstance] = NewLimiterMap(p.Limiters) 22 } 23 } 24 return limiterPluginMap 25 } 26 27 //func (p PluginMap) Diff(otherMap PluginMap) (added, deleted, changed map[string][]*modconfig.Plugin) { 28 // // results are maps of connections keyed by plugin instance 29 // added = make(map[string][]*modconfig.Plugin) 30 // deleted = make(map[string][]*modconfig.Plugin) 31 // changed = make(map[string][]*modconfig.Plugin) 32 // 33 // for name, plugin := range p { 34 // if otherConnection, ok := otherMap[name]; !ok { 35 // deleted[plugin.Instance] = append(deleted[plugin.Instance], plugin) 36 // } else { 37 // // check for changes 38 // 39 // // special case - if the plugin has changed, treat this as a deletion and a re-add 40 // if plugin.Instance != otherConnection.Plugin { 41 // added[otherConnection.Plugin] = append(added[otherConnection.Plugin], otherConnection) 42 // deleted[plugin.Instance] = append(deleted[plugin.Instance], plugin) 43 // } else { 44 // if !plugin.Equals(otherConnection) { 45 // changed[plugin.Instance] = append(changed[plugin.Instance], otherConnection) 46 // } 47 // } 48 // } 49 // } 50 // 51 // for otherName, otherConnection := range otherMap { 52 // if _, ok := p[otherName]; !ok { 53 // added[otherConnection.Plugin] = append(added[otherConnection.Plugin], otherConnection) 54 // } 55 // } 56 // 57 // return 58 //}