Skip to content

Commit

Permalink
🧹 use list of cross-connection provider
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-rock committed Jan 14, 2024
1 parent cf10bf7 commit 9efd4ad
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions providers/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"go.mondoo.com/cnquery/v10/providers-sdk/v1/upstream"
"go.mondoo.com/cnquery/v10/types"
"go.mondoo.com/cnquery/v10/utils/multierr"
"go.mondoo.com/cnquery/v10/utils/stringx"
"google.golang.org/grpc/status"
)

Expand Down Expand Up @@ -576,8 +577,15 @@ func (r *Runtime) lookupResourceProvider(resource string) (*ConnectedProvider, *
}

providerConn := r.Provider.Instance.ID
if info.Provider != providerConn && info.Provider != "go.mondoo.com/cnquery/providers/core" && info.Provider != "go.mondoo.com/cnquery/providers/network" {
return nil, nil, errors.New("incorrect provider for asset, not adding")
crossProviderList := []string{
"go.mondoo.com/cnquery/providers/core",
"go.mondoo.com/cnquery/v9/providers/core", // for backwards compatibility
"go.mondoo.com/cnquery/providers/network",
"go.mondoo.com/cnquery/v9/providers/network", // for backwards compatibility
}

if info.Provider != providerConn && !stringx.Contains(crossProviderList, info.Provider) {
return nil, nil, errors.New("incorrect provider for asset, not adding " + info.Provider)
}

res, err := r.addProvider(info.Provider, false)
Expand Down

0 comments on commit 9efd4ad

Please sign in to comment.