mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
ngalerting: represent nil/empty labels the same (#32652)
was getting duplicates of [] and null before
This commit is contained in:
@@ -78,9 +78,6 @@ func (t *tupleLabels) sortBtKey() {
|
||||
|
||||
// labelsToTupleLabels converts Labels (map[string]string) to tupleLabels.
|
||||
func labelsToTupleLabels(l InstanceLabels) tupleLabels {
|
||||
if l == nil {
|
||||
return nil
|
||||
}
|
||||
t := make(tupleLabels, 0, len(l))
|
||||
for k, v := range l {
|
||||
t = append(t, tupleLabel{k, v})
|
||||
@@ -92,7 +89,7 @@ func labelsToTupleLabels(l InstanceLabels) tupleLabels {
|
||||
// tupleLabelsToLabels converts tupleLabels to Labels (map[string]string), erroring if there are duplicate keys.
|
||||
func tupleLablesToLabels(tuples tupleLabels) (InstanceLabels, error) {
|
||||
if tuples == nil {
|
||||
return nil, nil
|
||||
return InstanceLabels{}, nil
|
||||
}
|
||||
labels := make(map[string]string)
|
||||
for _, tuple := range tuples {
|
||||
|
||||
@@ -54,6 +54,7 @@ func TestAlertInstanceOperations(t *testing.T) {
|
||||
DefinitionOrgID: alertDefinition2.OrgID,
|
||||
DefinitionUID: alertDefinition2.UID,
|
||||
State: models.InstanceStateNormal,
|
||||
Labels: models.InstanceLabels{},
|
||||
}
|
||||
err := dbstore.SaveAlertInstance(saveCmd)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user