diff --git a/lib/storage/tag_filters.go b/lib/storage/tag_filters.go index 0baac3eed..ace532b22 100644 --- a/lib/storage/tag_filters.go +++ b/lib/storage/tag_filters.go @@ -75,10 +75,16 @@ func (tfs *TagFilters) Add(key, value []byte, isNegative, isRegexp bool) error { // String returns human-readable value for tfs. func (tfs *TagFilters) String() string { var bb bytes.Buffer - fmt.Fprintf(&bb, "AccountID=%d, ProjectID=%d", tfs.accountID, tfs.projectID) - for i := range tfs.tfs { + fmt.Fprintf(&bb, "AccountID=%d, ProjectID=%d ", tfs.accountID, tfs.projectID) + if len(tfs.tfs) == 0 { + fmt.Fprintf(&bb, "{}") + return bb.String() + } + fmt.Fprintf(&bb, "{%s", tfs.tfs[0].String()) + for i := range tfs.tfs[1:] { fmt.Fprintf(&bb, ", %s", tfs.tfs[i].String()) } + fmt.Fprintf(&bb, "}") return bb.String() } @@ -121,11 +127,16 @@ type tagFilter struct { // String returns human-readable tf value. func (tf *tagFilter) String() string { - var bb bytes.Buffer - fmt.Fprintf(&bb, "[isNegative=%v, isRegexp=%v, prefix=%q", tf.isNegative, tf.isRegexp, tf.prefix) - fmt.Fprintf(&bb, ", orSuffixes=%v, reSuffixMatch=%p", tf.orSuffixes, tf.reSuffixMatch) - fmt.Fprintf(&bb, "]") - return bb.String() + op := "=" + if tf.isNegative { + op = "!=" + if tf.isRegexp { + op = "!~" + } + } else if tf.isRegexp { + op = "=~" + } + return fmt.Sprintf("%s%s%q", tf.key, op, tf.value) } func (tf *tagFilter) Marshal(dst []byte, accountID, projectID uint32) []byte {