go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers-sdk/v1/inventory/deprecated_v8.go (about) 1 // Copyright (c) Mondoo, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package inventory 5 6 import "strings" 7 8 func DeprecatedV8CompatAssets(assets []*Asset) { 9 for i := range assets { 10 DeprecatedV8CompatAsset(assets[i]) 11 } 12 } 13 14 func DeprecatedV8CompatAsset(asset *Asset) { 15 if asset == nil { 16 return 17 } 18 19 if asset.Platform != nil { 20 asset.Platform.DeprecatedV8Kind = Kind2DeprecatedV8Kind(asset.Platform.Kind) 21 } 22 23 for i := range asset.Connections { 24 conn := asset.Connections[i] 25 conn.Kind = Kind2DeprecatedV8Kind(asset.KindString) 26 } 27 28 // FIXME: Remove this and solve it at its core 29 var ids []string 30 for _, id := range asset.PlatformIds { 31 if strings.HasPrefix(id, "//") { 32 ids = append(ids, id) 33 } 34 } 35 asset.PlatformIds = ids 36 } 37 38 func Kind2DeprecatedV8Kind(kind string) DeprecatedV8_Kind { 39 switch kind { 40 case "virtual-machine-image": 41 return DeprecatedV8_Kind_KIND_VIRTUAL_MACHINE 42 case "container-image": 43 return DeprecatedV8_Kind_KIND_CONTAINER_IMAGE 44 case "code": 45 return DeprecatedV8_Kind_KIND_CODE 46 case "package": 47 return DeprecatedV8_Kind_KIND_PACKAGE 48 case "virtual-machine": 49 return DeprecatedV8_Kind_KIND_VIRTUAL_MACHINE 50 case "container": 51 return DeprecatedV8_Kind_KIND_CONTAINER 52 case "process": 53 return DeprecatedV8_Kind_KIND_PROCESS 54 case "api": 55 return DeprecatedV8_Kind_KIND_API 56 case "bare-metal": 57 return DeprecatedV8_Kind_KIND_BARE_METAL 58 case "network": 59 return DeprecatedV8_Kind_KIND_NETWORK 60 case "k8s-object": 61 return DeprecatedV8_Kind_KIND_K8S_OBJECT 62 case "aws_object": 63 return DeprecatedV8_Kind_KIND_AWS_OBJECT 64 case "gcp-object": 65 return DeprecatedV8_Kind_KIND_GCP_OBJECT 66 case "azure-object": 67 return DeprecatedV8_Kind_KIND_AZURE_OBJECT 68 default: 69 return DeprecatedV8_Kind_KIND_UNKNOWN 70 } 71 }