You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
✨ add garbage collection for stale node scan assets (#1435)
* 🐛 fix(bump) cnspec version
* 🧹bump mql version v13.1.1
* ✨ add garbage collection for stale node scan assets
fix: update MondooClientBuilder reference and clarify garbage collection comment
refactor: streamline garbage collection logic for nodes and K8s resources
refactor: simplify garbage collection logic by removing cluster UID dependency
fix: platform runtime for nodes
* ✨ refactor: use ManagedByLabel for consistency in asset management
* fix: replace gopkg.in/yaml.v2 with sigs.k8s.io/yaml to fix ManagedBy propagation
The ManagedBy field on the protobuf Asset struct has only a JSON tag
(json:"managed_by,omitempty") but no yaml tag. gopkg.in/yaml.v2
serializes it as "managedby" (lowercase field name fallback), while
cnspec reads inventories with sigs.k8s.io/yaml which expects
"managed_by" (from JSON tags). This caused ManagedBy to be silently
lost during serialization for k8s resource and container image scans.
Node scans already used sigs.k8s.io/yaml, which is why they were
unaffected. This also removes the gopkg.in/yaml.v2 dependency entirely.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: cmd/mondoo-operator/garbage_collect/cmd.go
+22-18Lines changed: 22 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,6 @@ import (
8
8
"errors"
9
9
"fmt"
10
10
"os"
11
-
"strings"
12
11
"time"
13
12
14
13
"github.com/go-logr/logr"
@@ -31,7 +30,6 @@ func init() {
31
30
filterPlatformRuntime:=Cmd.Flags().String("filter-platform-runtime", "", "Cleanup assets by an asset's PlatformRuntime (k8s-cluster or docker-image).")
32
31
filterManagedBy:=Cmd.Flags().String("filter-managed-by", "", "Cleanup assets with matching ManagedBy field.")
33
32
filterOlderThan:=Cmd.Flags().String("filter-older-than", "", "Cleanup assets which have not been updated in over the time provided (eg 12m or 48h or anything time.ParseDuration() accepts).")
34
-
labelsInput:=Cmd.Flags().StringSlice("labels", []string{}, "Cleanup assets with matching labels (eg --labels key1=value1,key2=value2).")
0 commit comments