// compare a tag against a list of strings and checks if it should
// be ignored or not
357892
func tagIgnoredSSM(t *ssm.Tag) bool {
	filter := []string{"^aws:"}
	for _, v := range filter {
		log.Printf("[DEBUG] Matching %v with %v\n", v, *t.Key)
		r, _ := regexp.MatchString(v, *t.Key)
		if r {
			log.Printf("[DEBUG] Found AWS specific tag %s (val: %s), ignoring.\n", *t.Key, *t.Value)
			return true
		}
	}
	return false
}
658669
func (c *Config) ListTags() string {
	var tags []string

	for k, v := range c.Tags {
		tags = append(tags, fmt.Sprintf("%s=%s", k, v))
	}

	sort.Strings(tags)

	return strings.Join(tags, " ")
}
491403
func tagSetsMatch(a, b map[string]string) bool {
	if len(a) != len(b) {
		return false
	}

	for ak, av := range a {
		bv, ok := b[ak]
		if !ok {
			return false
		}
		if av != bv {
			return false
		}
	}

	return true
}
443795
func (t *Tags) Add(tag string) error {
	ts := *t
	trim := strings.TrimSpace(tag)
	if trim == "" {
		return e.New(e.ErrEmptyString)
	}
	if err := CheckTag(trim); err != nil {
		return e.Forward(err)
	}
	i := sort.SearchStrings(ts, trim)
	if i >= ts.Len() || ts[i] != trim { // Not found
		//ts = append(ts, trim)
		//sort.Strings(ts)
		ts = append(ts[:i], append(Tags{trim}, ts[i:]...)...)
	} else {
		return e.New(ErrTagExist)
	}
	*t = ts
	return nil
}
1090425
func SortTags(tags []Tag) []Tag {
	// Insertion sort since these arrays are very small and allocation is the
	// primary enemy of performance here.
	if len(tags) >= 20 {
		sort.Sort(tagsByName(tags))
	} else {
		for i := 0; i < len(tags); i++ {
			for j := i; j > 0 && tags[j-1].Name > tags[j].Name; j-- {
				tags[j], tags[j-1] = tags[j-1], tags[j]
			}
		}
	}
	return tags
}
1036046
func ValidateTags(tags []string) error {
	if len(tags) > maxTagCount {
		return fmt.Errorf("too many tags given (%d), expecting up to %d tags", len(tags), maxTagCount)
	}
	var merr errors.MultiError
	for i, tag := range tags {
		parts := strings.SplitN(tag, ":", 2) // ':' in values are allowed
		msg := ""
		switch {
		case len(parts) != 2:
			msg = "not in <key>:<value> form"
		case len(parts[0]) > maxTagKeySize:
			msg = fmt.Sprintf("the key length must not exceed %d", maxTagKeySize)
		case len(parts[1]) > maxTagValueSize:
			msg = fmt.Sprintf("the value length must not exceed %d", maxTagValueSize)
		}
		if msg != "" {
			merr = append(merr, fmt.Errorf("tag #%d: %s", i+1, msg))
		}
	}
	if len(merr) == 0 {
		return nil
	}
	return merr
}
139789
func (r *Reference) Tags(fn func(t Tag, value string)) {
	if fn == nil {
		return
	}
	fn(refNameTag, r.Name())
	fn(refLengthTag, fmt.Sprint(r.lRef))
	if r.assemID != "" {
		fn(assemblyIDTag, r.assemID)
	}
	if r.md5 != "" {
		fn(md5Tag, fmt.Sprintf("%x", []byte(r.md5)))
	}
	if r.species != "" {
		fn(speciesTag, r.species)
	}
	if r.uri != nil {
		fn(uriTag, r.uri.String())
	}
	for _, tp := range r.otherTags {
		fn(tp.tag, tp.value)
	}
}
383470
func (r *Reader) CheckTags(expectTags []byte) (tag byte) {
	tag = r.readByte()
	if bytes.IndexByte(expectTags, tag) == -1 {
		unexpectedTag(tag, expectTags)
	}
	return
}
1251162
func (c IndexEntries) StringByTag(tag int) string {
	s := c.StringsByTag(tag)
	if s == nil || len(s) == 0 {
		return ""
	}
	return s[0]
}
267825
func (c *SearchCall) Tag(tag ...string) *SearchCall {
	c.urlParams_.SetMulti("tag", append([]string{}, tag...))
	return c
}
896738
func (p *Parser) SkipUntilTag(names ...string) *Error {
	for p.Remaining() > 0 {
		// New tag, check whether we have to stop wrapping here
		if p.Peek(TokenSymbol, "{%") != nil {
			tagIdent := p.PeekTypeN(1, TokenIdentifier)

			if tagIdent != nil {
				// We've found a (!) end-tag

				found := false
				for _, n := range names {
					if tagIdent.Val == n {
						found = true
						break
					}
				}

				// We only process the tag if we've found an end tag
				if found {
					// Okay, endtag found.
					p.ConsumeN(2) // '{%' tagname

					for {
						if p.Match(TokenSymbol, "%}") != nil {
							// Done skipping, exit.
							return nil
						}
					}
				}
			}
		}
		t := p.Current()
		p.Consume()
		if t == nil {
			return p.Error("Unexpected EOF.", p.lastToken)
		}
	}

	return p.Error(fmt.Sprintf("Unexpected EOF, expected tag %s.", strings.Join(names, " or ")), p.lastToken)
}
528549
func (s *Sentry) Tag(key, value string) {
	s.Lock()
	s.client.Tags[key] = value
	s.Unlock()
}
745018
func (t *Tags) Remove(tag string) error {
	ts := *t
	i := sort.SearchStrings(ts, tag)
	if i < len(ts) && ts[i] == tag {
		if i+1 == len(ts) {
			ts = ts[:i]
		} else {
			ts = append(ts[:i], ts[i+1:]...)
		}
		*t = ts
		return nil
	}
	return e.New(ErrTagNotFound)
}
889626
func (r *PURuntime) Tag(key string) (string, bool) {
	r.Lock()
	defer r.Unlock()

	tag, ok := r.tags.Get(key)
	return tag, ok
}
126483
func (a Tags) Values() []string {
	if len(a) == 0 {
		return nil
	}
	values := make([]string, len(a))
	for i, tag := range a {
		values[i] = string(tag.Value)
	}
	return values
}
1041591
func (t Tags) Find(name string) Tag {
	for _, popTag := range t {
		if popTag.Name == name {
			return popTag
		}
	}
	return Tag{}
}
902042
func (fiInfo *FieldInfo) Ignored() bool {
	tagJSON := ucon.NewTagJSON(fiInfo.Base.Tag)
	if tagJSON.Ignored() {
		return true
	}

	return false
}