Ejemplo n.º 1
0
func getDockerLabelRows(nmd report.Node) []Row {
	rows := []Row{}
	// Add labels in alphabetical order
	labels := docker.ExtractLabels(nmd)
	labelKeys := make([]string, 0, len(labels))
	for k := range labels {
		labelKeys = append(labelKeys, k)
	}
	sort.Strings(labelKeys)
	for _, labelKey := range labelKeys {
		rows = append(rows, Row{Key: fmt.Sprintf("Label %q", labelKey), ValueMajor: labels[labelKey]})
	}
	return rows
}
Ejemplo n.º 2
0
func TestLabels(t *testing.T) {
	want := map[string]string{
		"foo1": "bar1",
		"foo2": "bar2",
	}
	nmd := report.MakeNodeMetadata()

	docker.AddLabels(nmd, want)
	have := docker.ExtractLabels(nmd)

	if !reflect.DeepEqual(want, have) {
		t.Error(test.Diff(want, have))
	}
}