// compare a tag against a list of strings and checks if it should
// be ignored or not
321175
func tagIgnoredSfn(t *sfn.Tag) bool {
	filter := []string{"^aws:"}
	for _, v := range filter {
		log.Printf("[DEBUG] Matching %v with %v\n", v, aws.StringValue(t.Key))
		r, _ := regexp.MatchString(v, aws.StringValue(t.Key))
		if r {
			log.Printf("[DEBUG] Found AWS specific tag %s (val: %s), ignoring.\n", aws.StringValue(t.Key), aws.StringValue(t.Value))
			return true
		}
	}
	return false
}
836367
func Tag(c context.Context, v string) context.Context {
	return context.WithValue(c, &clockTagKey, append(Tags(c), v))
}
574303
func CheckTags(tags string) error {
	if len(tags) <= TagStringMin && len(tags) >= TagStringMax {
		return e.New(ErrInvalidTagsLength)
	}
	for _, v := range tags {
		if !u.IsLetter(v) && !unicode.IsDigit(v) && v != ',' && v != ' ' && v != '-' && v != '_' && v != '.' && v != '/' && v != ':' {
			return e.Push(e.New(ErrInvalidTagChar), e.New("the character '%v' is invalid", string([]byte{byte(v)})))
		}
	}
	return nil
}
83895
func (t *Tags) Same(tr *Tags) bool {
	tags1 := *t
	tags2 := *tr
	if len(tags1) != len(tags2) {
		return false
	}
	for i, tag := range tags1 {
		if tag != tags2[i] {
			return false
		}
	}
	return true
}
1046397
func ListTags() (tags []string, err error) {
	var task = "Get release tags"

	// Get all release tags.
	stdout, err := git.RunCommand("tag", "--list", "v*.*.*")
	if err != nil {
		return nil, errs.NewError(task, err)
	}

	// Parse the output to get sortable versions.
	var vers []*version.Version
	scanner := bufio.NewScanner(stdout)
	for scanner.Scan() {
		line := scanner.Text()
		if line == "" {
			continue
		}
		line = line[1:] // strip "v"
		ver, _ := version.Parse(line)
		vers = append(vers, ver)
	}
	if err := scanner.Err(); err != nil {
		return nil, errs.NewError(task, err)
	}

	// Sort the versions.
	sort.Sort(version.Versions(vers))

	// Convert versions back to tag names and return.
	tgs := make([]string, 0, len(vers))
	for _, ver := range vers {
		tgs = append(tgs, "v"+ver.String())
	}
	return tgs, nil
}
1141686
func acceptedHTMLTag(tagName string) bool {
	for _, tag := range acceptedHTMLTags {
		if tag == tagName {
			return true
		}
	}
	return false
}
509637
func (e Error) Tag(tag Error) Error {
	return Error(string(tag) + ":" + string(e))
}
1260510
func tagInSlice(a YamlTag, list []YamlTag) bool {
	for _, b := range list {
		if b == a {
			return true
		}
	}
	return false
}
664504
func matchesAsgTags(tags map[string]string, actual []*autoscaling.TagDescription) bool {
	for k, v := range tags {
		found := false
		for _, a := range actual {
			if aws.StringValue(a.Key) == k {
				if aws.StringValue(a.Value) == v {
					found = true
					break
				}
			}
		}
		if !found {
			return false
		}
	}
	return true
}
98252
func (bh *Header) Tags(fn func(t Tag, value string)) {
	if fn == nil {
		return
	}
	fn(versionTag, bh.Version)
	if bh.SortOrder != UnknownOrder {
		fn(sortOrderTag, bh.SortOrder.String())
	}
	if bh.GroupOrder != GroupNone {
		fn(groupOrderTag, bh.GroupOrder.String())
	}
	for _, tp := range bh.otherTags {
		fn(tp.tag, tp.value)
	}
}
857705
func tagsMatch(wanted, have []string) bool {
	machineTags := map[string]struct{}{}
	for _, tag := range have {
		machineTags[tag] = struct{}{}
	}
	for _, tag := range wanted {
		if _, ok := machineTags[tag]; !ok {
			return false
		}
	}
	return true
}
412393
func ValidateTags(tags ...Trytes) Validatable {
	return func() error {
		for i := range tags {
			if !IsTag(tags[i]) {
				return errors.Wrapf(ErrInvalidTag, "%s at index %d", tags[i], i)
			}
		}
		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
}
584401
func NewTagStringsIterator(inputs ...string) (TagIterator, error) {
	if len(inputs)%2 != 0 {
		return nil, errInvalidNumberInputsToIteratorMatcher
	}
	tags := make([]Tag, 0, len(inputs)/2)
	for i := 0; i < len(inputs); i += 2 {
		tags = append(tags, StringTag(inputs[i], inputs[i+1]))
	}
	return NewTagsIterator(NewTags(tags...)), nil
}
175382
func (a Tags) Equal(other Tags) bool {
	if len(a) != len(other) {
		return false
	}
	for i := range a {
		if !bytes.Equal(a[i].Key, other[i].Key) || !bytes.Equal(a[i].Value, other[i].Value) {
			return false
		}
	}
	return true
}
175047
func (tag *BuildTag) TagString() string {
	result := tag.Name
	if tag.isNoomitempty() {
		if tag.OmitEmpty {
			result += ",omitempty"
		}
	} else {
		if tag.OmitEmpty || !tag.ShouldEmit {
			result += ",omitempty"
		}
	}
	if tag.String { // TODO add special support for int64
		result += ",string"
	}
	return "json:\"" + result + "\""
}
820447
func ValidateTag(tag string) ([]string, error) {
	ltag := strings.ToLower(tag)
	if !validTagRe.MatchString(ltag) {
		return nil, fmt.Errorf("invalid tag: %q", tag)
	}
	ltags := strings.Split(ltag, ":")
	return ltags, nil
}