Skip to content

Commit

Permalink
Add creation timestamp for the k8s node
Browse files Browse the repository at this point in the history
Copy/paste from other k8s objects.

Signed-off-by: Tim Smith <[email protected]>
  • Loading branch information
tas50 committed Dec 21, 2024
1 parent 916c468 commit abc7cc6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions providers/k8s/resources/k8s.lr
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ private k8s.node @defaults("name labels['kubernetes.io/arch'] labels['kubernetes
name string
// Kubernetes object type
kind string
// Kubernetes object creation timestamp
created time
}

// Kubernetes Pod
Expand Down
12 changes: 12 additions & 0 deletions providers/k8s/resources/k8s.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/k8s/resources/k8s.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ resources:
fields:
annotations:
min_mondoo_version: 5.29.2
created:
min_mondoo_version: 9.0.0
id:
min_mondoo_version: 6.10.0
kind: {}
Expand Down
3 changes: 3 additions & 0 deletions providers/k8s/resources/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@ func initK8sNode(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[str
func (k *mqlK8s) nodes() ([]interface{}, error) {
k.mqlK8sInternal.nodesByName = make(map[string]*mqlK8sNode)
return k8sResourceToMql(k.MqlRuntime, gvkString(corev1.SchemeGroupVersion.WithKind("nodes")), func(kind string, resource runtime.Object, obj metav1.Object, objT metav1.Type) (interface{}, error) {
ts := obj.GetCreationTimestamp()

r, err := CreateResource(k.MqlRuntime, "k8s.node", map[string]*llx.RawData{
"id": llx.StringData(objIdFromK8sObj(obj, objT)),
"uid": llx.StringData(string(obj.GetUID())),
"resourceVersion": llx.StringData(obj.GetResourceVersion()),
"name": llx.StringData(obj.GetName()),
"kind": llx.StringData(objT.GetKind()),
"created": llx.TimeData(ts.Time),
})
if err != nil {
return nil, err
Expand Down

0 comments on commit abc7cc6

Please sign in to comment.