Exemple #1
0
func (d *deployment) GetNode(probeID string) report.Node {
	return d.MetaNode(report.MakeDeploymentNodeID(d.UID())).WithLatests(map[string]string{
		ObservedGeneration:    fmt.Sprint(d.Status.ObservedGeneration),
		DesiredReplicas:       fmt.Sprint(d.Spec.Replicas),
		Replicas:              fmt.Sprint(d.Status.Replicas),
		UpdatedReplicas:       fmt.Sprint(d.Status.UpdatedReplicas),
		AvailableReplicas:     fmt.Sprint(d.Status.AvailableReplicas),
		UnavailableReplicas:   fmt.Sprint(d.Status.UnavailableReplicas),
		Strategy:              string(d.Spec.Strategy.Type),
		report.ControlProbeID: probeID,
	}).WithControls(ScaleUp, ScaleDown)
}
Exemple #2
0
func (r *Reporter) replicaSetTopology(probeID string, deployments []Deployment) (report.Topology, []ReplicaSet, error) {
	var (
		result = report.MakeTopology().
			WithMetadataTemplates(ReplicaSetMetadataTemplates).
			WithTableTemplates(TableTemplates)
		replicaSets = []ReplicaSet{}
		selectors   = []func(labelledChild){}
	)
	result.Controls.AddControls(ScalingControls)

	for _, deployment := range deployments {
		selectors = append(selectors, match(
			deployment.Selector(),
			report.Deployment,
			report.MakeDeploymentNodeID(deployment.UID()),
		))
	}

	err := r.client.WalkReplicaSets(func(r ReplicaSet) error {
		for _, selector := range selectors {
			selector(r)
		}
		result = result.AddNode(r.GetNode(probeID))
		replicaSets = append(replicaSets, r)
		return nil
	})
	if err != nil {
		return result, replicaSets, err
	}

	err = r.client.WalkReplicationControllers(func(r ReplicationController) error {
		for _, selector := range selectors {
			selector(r)
		}
		result = result.AddNode(r.GetNode(probeID))
		replicaSets = append(replicaSets, ReplicaSet(r))
		return nil
	})
	return result, replicaSets, err
}