func (r *replicaSet) GetNode(probeID string) report.Node { return r.MetaNode(report.MakeReplicaSetNodeID(r.UID())).WithLatests(map[string]string{ ObservedGeneration: fmt.Sprint(r.Status.ObservedGeneration), Replicas: fmt.Sprint(r.Status.Replicas), DesiredReplicas: fmt.Sprint(r.Spec.Replicas), FullyLabeledReplicas: fmt.Sprint(r.Status.FullyLabeledReplicas), report.ControlProbeID: probeID, }).WithParents(r.parents).WithControls(ScaleUp, ScaleDown) }
func (r *Reporter) podTopology(services []Service, replicaSets []ReplicaSet) (report.Topology, error) { var ( pods = report.MakeTopology(). WithMetadataTemplates(PodMetadataTemplates). WithMetricTemplates(PodMetricTemplates). WithTableTemplates(TableTemplates) selectors = []func(labelledChild){} ) pods.Controls.AddControl(report.Control{ ID: GetLogs, Human: "Get logs", Icon: "fa-desktop", Rank: 0, }) pods.Controls.AddControl(report.Control{ ID: DeletePod, Human: "Delete", Icon: "fa-trash-o", Rank: 1, }) for _, service := range services { selectors = append(selectors, match( service.Selector(), report.Service, report.MakeServiceNodeID(service.UID()), )) } for _, replicaSet := range replicaSets { selectors = append(selectors, match( replicaSet.Selector(), report.ReplicaSet, report.MakeReplicaSetNodeID(replicaSet.UID()), )) } thisNodeName, err := GetNodeName(r) if err != nil { return pods, err } err = r.client.WalkPods(func(p Pod) error { if p.NodeName() != thisNodeName { return nil } for _, selector := range selectors { selector(p) } pods = pods.AddNode(p.GetNode(r.probeID)) return nil }) return pods, err }