github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/pkg/workspace/workspace_resources.go (about) 1 package workspace 2 3 import ( 4 "github.com/turbot/steampipe/pkg/steampipeconfig/modconfig" 5 "log" 6 ) 7 8 func (w *Workspace) GetQueryProvider(queryName string) (modconfig.QueryProvider, bool) { 9 parsedName, err := modconfig.ParseResourceName(queryName) 10 if err != nil { 11 return nil, false 12 } 13 // try to find the resource 14 if resource, ok := w.GetResource(parsedName); ok { 15 // found a resource - is itr a query provider 16 if qp := resource.(modconfig.QueryProvider); ok { 17 return qp, true 18 } 19 log.Printf("[TRACE] GetQueryProviderImpl found a resource for '%s' but it is not a query provider", queryName) 20 } 21 22 return nil, false 23 } 24 25 // GetResourceMaps implements ResourceMapsProvider 26 func (w *Workspace) GetResourceMaps() *modconfig.ResourceMaps { 27 w.loadLock.Lock() 28 defer w.loadLock.Unlock() 29 30 // if this a source snapshot workspace, create a ResourceMaps containing ONLY source snapshot paths 31 if len(w.SourceSnapshots) != 0 { 32 return modconfig.NewSourceSnapshotModResources(w.SourceSnapshots) 33 } 34 return w.Mod.ResourceMaps 35 } 36 37 func (w *Workspace) GetResource(parsedName *modconfig.ParsedResourceName) (resource modconfig.HclResource, found bool) { 38 return w.GetResourceMaps().GetResource(parsedName) 39 }