diff --git a/app/api_topologies.go b/app/api_topologies.go index b1ed68022..fb3e30170 100644 --- a/app/api_topologies.go +++ b/app/api_topologies.go @@ -196,6 +196,17 @@ func MakeRegistry() *Registry { }, } + k8sCombinedTypeFilter := APITopologyOptionGroup{ + ID: "grouptype", + Default: "", + SelectType: "union", + NoneLabel: "All Types", + Options: []APITopologyOption{ + {Value: report.Deployment, Label: "Deployments", filter: render.IsTopology(report.Deployment), filterPseudo: false}, + {Value: report.DaemonSet, Label: "Daemonsets", filter: render.IsTopology(report.DaemonSet), filterPseudo: false}, + }, + } + // Topology option labels should tell the current state. The first item must // be the verb to get to that state registry.Add( @@ -273,7 +284,7 @@ func MakeRegistry() *Registry { parent: podsID, renderer: render.KubeCombinedRenderer, Name: "combined", - Options: []APITopologyOptionGroup{unmanagedFilter}, + Options: []APITopologyOptionGroup{unmanagedFilter, k8sCombinedTypeFilter}, HideIfEmpty: true, }, APITopologyDesc{ diff --git a/render/filters.go b/render/filters.go index 93721d36a..a49c26032 100644 --- a/render/filters.go +++ b/render/filters.go @@ -322,12 +322,6 @@ func IsNotPseudo(n report.Node) bool { return n.Topology != Pseudo || strings.HasSuffix(n.ID, TheInternetID) || strings.HasPrefix(n.ID, ServiceNodeIDPrefix) } -// IsPseudoTopology returns true if the node is in a pseudo topology, -// mimicing the check performed by MakeFilter() instead of the more complex check in IsNotPseudo() -func IsPseudoTopology(n report.Node) bool { - return n.Topology == Pseudo -} - // IsNamespace checks if the node is a pod/service in the specified namespace func IsNamespace(namespace string) FilterFunc { return func(n report.Node) bool { @@ -347,6 +341,17 @@ func IsNamespace(namespace string) FilterFunc { } } +// IsTopology checks if the node is from a particular report topology +func IsTopology(topology string) FilterFunc { + return func(n report.Node) bool { + return n.Topology == topology + } +} + +// IsPseudoTopology returns true if the node is in a pseudo topology, +// mimicing the check performed by MakeFilter() instead of the more complex check in IsNotPseudo() +var IsPseudoTopology = IsTopology(Pseudo) + var systemContainerNames = map[string]struct{}{ "weavescope": {}, "weavedns": {},