func (g *GenDefaultMeta) GenerateMetaData(pod *Pod) common.MapStr {
	labelMap := common.MapStr{}
	annotationsMap := common.MapStr{}

	if len(g.labels) == 0 {
		for k, v := range pod.Metadata.Labels {
			labelMap[k] = v
		}
	} else {
		labelMap = generateMapSubset(pod.Metadata.Labels, g.labels)
	}

	// Exclude any labels that are present in the exclude_labels config
	for _, label := range g.labelsExclude {
		delete(labelMap, label)
	}

	annotationsMap = generateMapSubset(pod.Metadata.Annotations, g.annotations)

	meta := common.MapStr{
		"pod": common.MapStr{
			"name": pod.Metadata.Name,
		},
		"namespace": pod.Metadata.Namespace,
	}

	if len(labelMap) != 0 {
		meta["labels"] = labelMap
	}

	if len(annotationsMap) != 0 {
		meta["annotations"] = annotationsMap
	}

	return meta
}
// GenerateMetaData generates default metadata for the given pod taking to account certain filters
GenerateMetaData generates default metadata for the given pod taking to account certain filters
// GenerateMetaData generates default metadata for the given pod taking to account certain filters
func (g *GenDefaultMeta) GenerateMetaData(pod *Pod) common.MapStr {
	labelMap := common.MapStr{}
	annotationsMap := common.MapStr{}
	if len(g.labels) == 0 {
		for k, v := range pod.Metadata.Labels {
			labelMap[k] = v
		}
	} else {
		labelMap = generateMapSubset(pod.Metadata.Labels, g.labels)
	}
	for _, label := range g.labelsExclude {
		delete(labelMap, label)
	}
	annotationsMap = generateMapSubset(pod.Metadata.Annotations, g.annotations)
	meta := common.MapStr{
		"pod": common.MapStr{
			"name": pod.Metadata.Name,
		},
		"namespace": pod.Metadata.Namespace,
	}
	if len(labelMap) != 0 {
		meta["labels"] = labelMap
	}
	if len(annotationsMap) != 0 {
		meta["annotations"] = annotationsMap
	}
	return meta
}
func ( g * GenDefaultMeta ) GenerateMetaData ( pod * Pod ) common . MapStr { labelMap := common . MapStr { } annotationsMap := common . MapStr { } if len ( g . labels ) == 0 { for k , v := range pod . Metadata . Labels { labelMap [ k ] = v } } else { labelMap = generateMapSubset ( pod . Metadata . Labels , g . labels ) } for _ , label := range g . labelsExclude { delete ( labelMap , label ) } annotationsMap = generateMapSubset ( pod . Metadata . Annotations , g . annotations ) meta := common . MapStr { " " : common . MapStr { " " : pod . Metadata . Name , } , " " : pod . Metadata . Namespace , } if len ( labelMap ) != 0 { meta [ " " ] = labelMap } if len ( annotationsMap ) != 0 { meta [ " " ] = annotationsMap } return meta }
GenerateMetaData generates default metadata for the given pod taking to account certain filters
GenerateMetaData generates default metadata for the given pod taking to account certain filters
// Exclude any labels that are present in the exclude_labels config