Skip to content

Commit

Permalink
⚙️ expose platform labels as asset.platformMetadata
Browse files Browse the repository at this point in the history
Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
  • Loading branch information
afiune committed Feb 21, 2025
1 parent 0521458 commit 2138e1d
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 204 deletions.
401 changes: 211 additions & 190 deletions providers-sdk/v1/inventory/inventory.pb.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions providers-sdk/v1/inventory/inventory.proto
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,12 @@ message Platform {
// ^^

string runtime = 21;
// FIXME: DEPRECATED, remove in v12 (or later) vv
map<string, string> labels = 22;
// ^^

// Additional platform specific/operating system data
map<string, string> metadata = 23;
}

// NOTE: the k8s types are apache 2 licenced and copied from
Expand Down
27 changes: 14 additions & 13 deletions providers/core/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,20 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba

asset := req.Asset
_, err = resources.CreateResource(runtime, "asset", map[string]*llx.RawData{
"ids": llx.ArrayData(llx.TArr2Raw(asset.PlatformIds), types.String),
"platform": llx.StringData(asset.Platform.Name),
"name": llx.StringData(asset.Name),
"kind": llx.StringData(asset.Platform.Kind),
"runtime": llx.StringData(asset.Platform.Runtime),
"version": llx.StringData(asset.Platform.Version),
"arch": llx.StringData(asset.Platform.Arch),
"title": llx.StringData(asset.Platform.PrettyTitle()),
"family": llx.ArrayData(llx.TArr2Raw(asset.Platform.Family), types.String),
"build": llx.StringData(asset.Platform.Build),
"labels": llx.MapData(llx.TMap2Raw(asset.Labels), types.String),
"annotations": llx.MapData(llx.TMap2Raw(asset.Annotations), types.String),
"fqdn": llx.StringData(asset.Fqdn),
"ids": llx.ArrayData(llx.TArr2Raw(asset.PlatformIds), types.String),
"platform": llx.StringData(asset.Platform.Name),
"name": llx.StringData(asset.Name),
"kind": llx.StringData(asset.Platform.Kind),
"runtime": llx.StringData(asset.Platform.Runtime),
"version": llx.StringData(asset.Platform.Version),
"arch": llx.StringData(asset.Platform.Arch),
"title": llx.StringData(asset.Platform.PrettyTitle()),
"family": llx.ArrayData(llx.TArr2Raw(asset.Platform.Family), types.String),
"build": llx.StringData(asset.Platform.Build),
"labels": llx.MapData(llx.TMap2Raw(asset.Labels), types.String),
"platformMetadata": llx.MapData(llx.TMap2Raw(asset.Platform.Labels), types.String),
"annotations": llx.MapData(llx.TMap2Raw(asset.Annotations), types.String),
"fqdn": llx.StringData(asset.Fqdn),
})
if err != nil {
return nil, errors.New("failed to init core, cannot set asset metadata")
Expand Down
2 changes: 2 additions & 0 deletions providers/core/resources/core.lr
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ asset @defaults("name platform version") {
fqdn string
// Build version of the platform (optional)
build string
// Platform Metadata (e.g. key values from /etc/os/release)
platformMetadata map[string]string
// Optional platform information
labels map[string]string
// Custom annotations (tags) on the asset
Expand Down
12 changes: 12 additions & 0 deletions providers/core/resources/core.lr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions providers/core/resources/core.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ resources:
labels: {}
name: {}
platform: {}
platformMetadata:
min_mondoo_version: 9.0.0
runtime: {}
title: {}
version: {}
Expand Down
2 changes: 1 addition & 1 deletion providers/core/resources/core.resources.json

Large diffs are not rendered by default.

0 comments on commit 2138e1d

Please sign in to comment.