github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/pkg/connection_sync/wait_for_search_path.go (about) 1 package connection_sync 2 3 import ( 4 "context" 5 6 "github.com/turbot/steampipe/pkg/db/db_common" 7 "github.com/turbot/steampipe/pkg/steampipeconfig" 8 ) 9 10 // WaitForSearchPathSchemas identifies the first connection in the search path for each plugin, 11 // and wait for these connections to be ready 12 // if any of the connections are in error state, return an error 13 // this is used to ensure unqualified queries and tables are resolved to the correct connection 14 func WaitForSearchPathSchemas(ctx context.Context, client db_common.Client, searchPath []string) error { 15 conn, err := client.AcquireManagementConnection(ctx) 16 if err != nil { 17 return err 18 } 19 defer conn.Release() 20 21 _, err = steampipeconfig.LoadConnectionState(ctx, conn.Conn(), steampipeconfig.WithWaitForSearchPath(searchPath)) 22 23 // NOTE: if we failed to load conection state, this must be because we are connected to an older version of the CLI 24 // just return nil error 25 if db_common.IsRelationNotFoundError(err) { 26 return nil 27 } 28 29 return err 30 }