예제 #1
0
func (r *registry) rendererForTopology(topologyID string, values url.Values, rpt report.Report) (render.Renderer, render.Decorator, error) {
	topology, ok := r.get(topologyID)
	if !ok {
		return nil, nil, fmt.Errorf("topology not found: %s", topologyID)
	}
	topology = updateFilters(rpt, []APITopologyDesc{topology})[0]

	var filters []render.FilterFunc
	for _, group := range topology.Options {
		value := values.Get(group.ID)
		for _, opt := range group.Options {
			if opt.filter == nil {
				continue
			}
			if (value == "" && group.Default == opt.Value) || (opt.Value != "" && opt.Value == value) {
				filters = append(filters, opt.filter)
			}
		}
	}
	var decorator render.Decorator
	if len(filters) > 0 {
		decorator = func(renderer render.Renderer) render.Renderer {
			return render.MakeFilter(render.ComposeFilterFuncs(filters...), renderer)
		}
	}
	return topology.renderer, decorator, nil
}
예제 #2
0
파일: pod_test.go 프로젝트: dilgerma/scope
func filterNonKubeSystem(renderer render.Renderer) render.Renderer {
	return render.MakeFilter(render.Complement(render.IsNamespace("kube-system")), renderer)
}