diff --git a/internal/kubernetesagent/agent.go b/internal/kubernetesagent/agent.go index fc1028b..467a7ee 100644 --- a/internal/kubernetesagent/agent.go +++ b/internal/kubernetesagent/agent.go @@ -468,7 +468,7 @@ func (a *Agent) collectPods(ctx context.Context) ([]agentsk8s.Pod, error) { if !a.namespaceAllowed(pod.Namespace) { continue } - if !a.cfg.IncludeAllPods && isProblemPod(pod) { + if !a.cfg.IncludeAllPods && !isProblemPod(pod) { continue } @@ -600,7 +600,7 @@ func (a *Agent) collectDeployments(ctx context.Context) ([]agentsk8s.Deployment, if !a.namespaceAllowed(dep.Namespace) { continue } - if isProblemDeployment(dep) { + if !isProblemDeployment(dep) { continue } diff --git a/internal/kubernetesagent/agent_test.go b/internal/kubernetesagent/agent_test.go index 7931e79..6dc40a2 100644 --- a/internal/kubernetesagent/agent_test.go +++ b/internal/kubernetesagent/agent_test.go @@ -62,8 +62,8 @@ users: func TestNamespaceAllowed_IncludeExclude(t *testing.T) { a := &Agent{ - includeNamespaces: makeNamespaceSet([]string{"a", "b"}), - excludeNamespaces: makeNamespaceSet([]string{"b"}), + includeNamespaces: []string{"a", "b"}, + excludeNamespaces: []string{"b"}, } if !a.namespaceAllowed("a") { @@ -122,9 +122,9 @@ func TestCollectPods_FiltersProblemsAndSorts(t *testing.T) { MaxPods: 2, IncludeAllPods: false, }, - kubeClient: clientset, - includeNamespaces: makeNamespaceSet(nil), - excludeNamespaces: makeNamespaceSet(nil), + kubeClient: clientset, + includeNamespaces: nil, + excludeNamespaces: nil, } pods, err := a.collectPods(context.Background()) @@ -165,10 +165,10 @@ func TestCollectDeployments_FiltersProblems(t *testing.T) { ) a := &Agent{ - cfg: Config{IncludeAllPods: false}, - kubeClient: clientset, - includeNamespaces: makeNamespaceSet(nil), - excludeNamespaces: makeNamespaceSet(nil), + cfg: Config{IncludeAllPods: false}, + kubeClient: clientset, + includeNamespaces: nil, + excludeNamespaces: nil, } deps, err := a.collectDeployments(context.Background())