Skip to content

Commit

Permalink
adjust code to work with provider types
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev committed Oct 2, 2023
1 parent 20acc75 commit e39794d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 3 additions & 1 deletion providers-sdk/v1/inventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"

"github.com/cockroachdb/errors"
"github.com/rs/zerolog/log"
"github.com/segmentio/ksuid"
"go.mondoo.com/cnquery/providers-sdk/v1/vault"
"google.golang.org/protobuf/proto"
Expand Down Expand Up @@ -56,7 +57,8 @@ func InventoryFromYAML(data []byte) (*Inventory, error) {
for _, asset := range res.Spec.Assets {
for _, conn := range asset.Connections {
if conn.Type == "" {
conn.Type = connBackendToType(conn.Backend)
log.Warn().Msg("no connection type provided, falling back to deprecated option backend")
conn.Type = ConnBackendToType(conn.Backend)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion providers-sdk/v1/inventory/v8_inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (s *ProviderType) UnmarshalJSON(data []byte) error {
return nil
}

func connBackendToType(backend ProviderType) string {
func ConnBackendToType(backend ProviderType) string {
switch backend {
case ProviderType_LOCAL_OS:
return "os"
Expand Down
7 changes: 2 additions & 5 deletions providers/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,8 @@ func (r *Runtime) DetectProvider(asset *inventory.Asset) error {
for i := range asset.Connections {
conn := asset.Connections[i]
if conn.Type == "" {
if conn.Backend != "" {
conn.Type = conn.Backend
} else {
continue
}
log.Warn().Msg("no connection type provided, falling back to deprecated option backend")
conn.Type = inventory.ConnBackendToType(conn.Backend)
}

provider, err := EnsureProvider("", conn.Type, true, r.coordinator.Providers)
Expand Down

0 comments on commit e39794d

Please sign in to comment.