Add an option group to Combined view to select group type (daemonset or deployment)

This is a union set, so it will be suitable even as we continue to add more node types to this view.
This commit is contained in:
Mike Lang
2017-05-16 17:48:27 -07:00
parent 6dae014352
commit d0cbf47c1c
2 changed files with 25 additions and 7 deletions

View File

@@ -197,6 +197,19 @@ 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},
{Value: report.ReplicaSet, Label: "Replica sets", filter: render.IsTopology(report.ReplicaSet), filterPseudo: false},
{Value: report.Pod, Label: "Pods", filter: render.IsTopology(report.Pod), filterPseudo: false},
},
}
// Topology option labels should tell the current state. The first item must
// be the verb to get to that state
registry.Add(
@@ -274,7 +287,7 @@ func MakeRegistry() *Registry {
parent: podsID,
renderer: render.KubeCombinedRenderer,
Name: "combined",
Options: []APITopologyOptionGroup{unmanagedFilter},
Options: []APITopologyOptionGroup{unmanagedFilter, k8sCombinedTypeFilter},
HideIfEmpty: true,
},
APITopologyDesc{

View File

@@ -311,12 +311,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 {
@@ -336,6 +330,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": {},