Skip to content

Commit

Permalink
Fixes a panic in dry-run when using external labels. (#2075)
Browse files Browse the repository at this point in the history
Fixes #1972.

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
  • Loading branch information
cyriltovena authored May 14, 2020
1 parent c2f100c commit 0de1a42
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/util/flagext/labelset.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"strings"

"github.com/prometheus/common/model"
"gopkg.in/yaml.v2"

"github.com/grafana/loki/pkg/util"
)

// LabelSet is a labelSet that can be used as a flag.
Expand Down Expand Up @@ -78,3 +81,12 @@ func (v *LabelSet) UnmarshalYAML(unmarshal func(interface{}) error) error {
v.LabelSet = lbSet
return nil
}

// MarshalYAML implements yaml.Marshaller.
func (v LabelSet) MarshalYAML() (interface{}, error) {
out, err := yaml.Marshal(util.ModelLabelSetToMap(v.LabelSet))
if err != nil {
return nil, err
}
return string(out), nil
}

0 comments on commit 0de1a42

Please sign in to comment.