Skip to content

Commit

Permalink
✨ add asset.annotations (#3625)
Browse files Browse the repository at this point in the history
* ✨ add asset.annotations

To access annotations programmatically

Signed-off-by: Dominik Richter <[email protected]>

* 🟢 re-generate core.resources to match

see failing https://github.com/mondoohq/cnquery/actions/runs/8380871911/job/22951097722\?pr\=3625

Signed-off-by: Dominik Richter <[email protected]>

---------

Signed-off-by: Dominik Richter <[email protected]>
  • Loading branch information
arlimus authored Mar 21, 2024
1 parent df77dbb commit 48b64be
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
25 changes: 13 additions & 12 deletions providers/core/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,19 @@ 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.Platform.Labels), 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.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/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
// SPDX-License-Identifier: BUSL-1.1

package resources

// Look into provider/providers.go for how asset information is attached.
2 changes: 2 additions & 0 deletions providers/core/resources/core.lr
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ asset @defaults("name platform version") {
build string
// Optional platform information
labels map[string]string
// Custom annotiations (tags) on the asset
annotations map[string]string
}

// Information about the assets platform end-of-life.
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 @@ -4,6 +4,8 @@
resources:
asset:
fields:
annotations:
min_mondoo_version: 10.8.3
arch: {}
build: {}
family: {}
Expand Down
Loading

0 comments on commit 48b64be

Please sign in to comment.