Skip to content

Commit 320bfdd

Browse files
committed
fix: tests helper GetWorkloadNames with skipping child workloads
1 parent 8e828d9 commit 320bfdd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/framework/utils/k8s_helper.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"strings"
2323
"time"
2424

25+
cnquery_k8s "go.mondoo.com/cnquery/v11/providers/k8s/resources"
2526
"go.mondoo.com/mondoo-operator/api/v1alpha2"
2627
api "go.mondoo.com/mondoo-operator/api/v1alpha2"
2728
"go.mondoo.com/mondoo-operator/pkg/utils/k8s"
@@ -754,6 +755,9 @@ func (k8sh *K8sHelper) GetWorkloadNames(ctx context.Context) ([]string, error) {
754755
}
755756

756757
for _, w := range pods.Items {
758+
if cnquery_k8s.PodOwnerReferencesFilter(w.GetOwnerReferences()) {
759+
continue
760+
}
757761
names = append(names, fmt.Sprintf("%s/%s", w.GetNamespace(), w.GetName()))
758762
}
759763

@@ -763,6 +767,9 @@ func (k8sh *K8sHelper) GetWorkloadNames(ctx context.Context) ([]string, error) {
763767
}
764768

765769
for _, w := range jobs.Items {
770+
if cnquery_k8s.JobOwnerReferencesFilter(w.GetOwnerReferences()) {
771+
continue
772+
}
766773
names = append(names, fmt.Sprintf("%s/%s", w.Namespace, w.Name))
767774
}
768775

@@ -813,6 +820,9 @@ func (k8sh *K8sHelper) GetWorkloadNames(ctx context.Context) ([]string, error) {
813820
}
814821

815822
for _, w := range replicasets.Items {
823+
if cnquery_k8s.ReplicaSetOwnerReferencesFilter(w.GetOwnerReferences()) {
824+
continue
825+
}
816826
names = append(names, fmt.Sprintf("%s/%s", w.Namespace, w.Name))
817827
}
818828

0 commit comments

Comments
 (0)