// queryMarkedTags returns a query for markedTags entities produced by a job.
767681
func queryMarkedTags(job mapper.JobID) *datastore.Query {
	return datastore.NewQuery("mapper.MarkedTag").Eq("Job", job)
}
1027560
func (vm *VM) getTags() *compute.Tags {
	if len(vm.Attributes.GetTag()) == 0 {
		return nil
	}
	tags := &compute.Tags{
		Items: make([]string, len(vm.Attributes.Tag)),
	}
	for i, tag := range vm.Attributes.Tag {
		tags.Items[i] = tag
	}
	return tags
}
413249
func tagIgnoredKMS(t *kms.Tag) bool {
	filter := []string{"^aws:"}
	for _, v := range filter {
		log.Printf("[DEBUG] Matching %v with %v\n", v, *t.TagKey)
		r, _ := regexp.MatchString(v, *t.TagKey)
		if r {
			log.Printf("[DEBUG] Found AWS specific tag %s (val: %s), ignoring.\n", *t.TagKey, *t.TagValue)
			return true
		}
	}
	return false
}
1097847
func (s *ProjectsService) ListTags(projectName string, opt *ProjectBaseOptions) (*[]TagInfo, *Response, error) {
	u := fmt.Sprintf("projects/%s/tags/", url.QueryEscape(projectName))
	u, err := addOptions(u, opt)
	if err != nil {
		return nil, nil, err
	}

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	v := new([]TagInfo)
	resp, err := s.client.Do(req, v)
	if err != nil {
		return nil, resp, err
	}

	return v, resp, err
}
1212133
func (writer *ConsoleWriter) Tags() map[string]string {
	writer.lock.RLock()
	defer writer.lock.RUnlock()

	return writer.blog.Tags()
}
1093126
func tagsFromMapELB(m map[string]interface{}) []*elb.Tag {
	var result []*elb.Tag
	for k, v := range m {
		t := &elb.Tag{
			Key:   aws.String(k),
			Value: aws.String(v.(string)),
		}
		if !tagIgnoredELB(t) {
			result = append(result, t)
		}
	}

	return result
}
325375
func isTagged(tag string, tags []string) bool {
	for _, t := range tags {
		if t == tag {
			return true
		}
	}
	return false
}
1247533
func (e *Engine) TagKeys(ctx context.Context, orgID, bucketID influxdb.ID, start, end int64, predicate influxql.Expr) (cursors.StringIterator, error) {
	e.mu.RLock()
	defer e.mu.RUnlock()
	if e.closing == nil {
		return cursors.EmptyStringIterator, nil
	}

	return e.engine.TagKeys(ctx, orgID, bucketID, start, end, predicate)
}
96551
func (c *retryRepository) Tags(ctx context.Context) distribution.TagService {
	return &retryTags{TagService: c.Repository.Tags(ctx), repo: c}
}
923091
func queryByTag(c context.Context, pkg, tag string, cursor datastore.Cursor, pageSize int32) (
	out []*datastore.Key,
	next datastore.Cursor,
	err error) {

	// TODO(vadimsh): 'registered_ts' here is when the tag was attached. The
	// callers likely expect results ordered by instance registration time. This
	// is not possible currently. We'll need to copy Instance.registered_ts into
	// InstanceTag entities, so we can order by instance registration time.

	// TODO(vadimsh): Should we exclude unprocessed instances from the result?

	q := datastore.NewQuery("InstanceTag").
		Ancestor(PackageKey(c, pkg)).
		Eq("tag", tag).
		Order("-registered_ts").
		Limit(pageSize).
		KeysOnly(true)
	if cursor != nil {
		q = q.Start(cursor)
	}

	err = datastore.Run(c, q, func(k *datastore.Key, cb datastore.CursorCB) error {
		out = append(out, k.Parent())
		if len(out) >= int(pageSize) {
			if next, err = cb(); err != nil {
				return err
			}
			return datastore.Stop
		}
		return nil
	})
	if err != nil {
		return nil, nil, errors.Annotate(err, "failed to query by tag %q", tag).Tag(transient.Tag).Err()
	}
	return
}
355039
func tagsFromMapDS(m map[string]interface{}) []*directoryservice.Tag {
	result := make([]*directoryservice.Tag, 0, len(m))
	for k, v := range m {
		t := &directoryservice.Tag{
			Key:   aws.String(k),
			Value: aws.String(v.(string)),
		}
		if !tagIgnoredDS(t) {
			result = append(result, t)
		}
	}

	return result
}
996694
func SortTags(tags map[string]string) [][]string {
	keys := make([]string, len(tags))
	result := make([][]string, len(tags))
	i := 0
	for k := range tags {
		keys[i] = k
		i++
	}
	sort.Strings(keys)
	for i, k := range keys {
		result[i] = []string{k, tags[k]}
	}
	return result
}
32582
func (r *ReqInfo) AppendTags(key string, val string) *ReqInfo {
	if r == nil {
		return nil
	}
	r.Lock()
	defer r.Unlock()
	r.tags = append(r.tags, KeyVal{key, val})
	return r
}
754752
func tagsFromMapElasticsearchService(m map[string]interface{}) []*elasticsearch.Tag {
	var result []*elasticsearch.Tag
	for k, v := range m {
		t := &elasticsearch.Tag{
			Key:   aws.String(k),
			Value: aws.String(v.(string)),
		}
		if !tagIgnoredElasticsearchService(t) {
			result = append(result, t)
		}
	}

	return result
}
19473
func (impl *adminImpl) FixMarkedTags(c context.Context, id *api.JobID) (*api.TagFixReport, error) {
	tags, err := fixMarkedTags(c, mapper.JobID(id.JobId))
	if err != nil {
		return nil, toStatus(err)
	}
	return &api.TagFixReport{Fixed: tags}, nil
}
1227221
func (c *awsCloudImplementation) GetTags(resourceID string) (map[string]string, error) {
	return getTags(c, resourceID)
}
718590
func (t *Tracer) Tags() []opentracing.Tag {
	tags := make([]opentracing.Tag, len(t.tags))
	for i, tag := range t.tags {
		tags[i] = opentracing.Tag{Key: tag.key, Value: tag.value}
	}
	return tags
}