func MetaToTags(kind string, meta metav1.Object) ([]string, error) {
	objUID := string(meta.GetUID())
	if objUID == "" {
		return nil, errors.New("empty object UID")
	}

	tagsCacheKey := tagsCacheKeyPrefix + objUID
	if tagsCache, found := cache.Cache.Get(tagsCacheKey); found {
		tags, ok := tagsCache.([]string)
		if !ok {
			return nil, errors.New("couldn't cast tags list from cache")
		}

		return tags, nil
	}

	builder := newTagListBuilder()
	builder.addNotEmpty(kubernetes.NamespaceTagName, meta.GetNamespace())
	builder.addNotEmpty(kubernetes.ResourceNameTagName, meta.GetName())
	builder.addNotEmpty(kubernetes.ResourceKindTagName, strings.ToLower(kind))
	builder.addNotEmpty(kubernetes.KindToTagName[kind], meta.GetName())

	for _, owner := range meta.GetOwnerReferences() {
		builder.addNotEmpty(kubernetes.OwnerRefNameTagName, owner.Name)
		builder.addNotEmpty(kubernetes.OwnerRefKindTagName, strings.ToLower(owner.Kind))
		builder.addNotEmpty(kubernetes.KindToTagName[owner.Kind], owner.Name)
	}

	tags := builder.tags()
	cache.Cache.Set(tagsCacheKey, tags, tagsCacheTTL)

	return tags, nil
}
// MetaToTags extracts tags for structured Kubernetes objects based on kind and metadata.
// Use UnstructuredTotags for unstructured objects.
// Kind string (e.g Deployment, Pod) needs to be provided manually by the caller, see https://github.com/kubernetes/client-go/issues/541
// Results are cached in-memory for 1 hour.
MetaToTags extracts tags for structured Kubernetes objects based on kind and metadata.
Use UnstructuredTotags for unstructured objects.
// MetaToTags extracts tags for structured Kubernetes objects based on kind and metadata . // Use UnstructuredTotags for unstructured objects . // Kind string ( e . g Deployment Pod ) needs to be provided manually by the caller see https : // github . com / kubernetes / client - go / issues / 541 // Results are cached in - memory for 1 hour .
func MetaToTags(kind string, meta metav1.Object) ([]string, error) {
	objUID := string(meta.GetUID())
	if objUID == "" {
		return nil, errors.New("empty object UID")
	}
	tagsCacheKey := tagsCacheKeyPrefix + objUID
	if tagsCache, found := cache.Cache.Get(tagsCacheKey); found {
		tags, ok := tagsCache.([]string)
		if !ok {
			return nil, errors.New("couldn't cast tags list from cache")
		}
		return tags, nil
	}
	builder := newTagListBuilder()
	builder.addNotEmpty(kubernetes.NamespaceTagName, meta.GetNamespace())
	builder.addNotEmpty(kubernetes.ResourceNameTagName, meta.GetName())
	builder.addNotEmpty(kubernetes.ResourceKindTagName, strings.ToLower(kind))
	builder.addNotEmpty(kubernetes.KindToTagName[kind], meta.GetName())
	for _, owner := range meta.GetOwnerReferences() {
		builder.addNotEmpty(kubernetes.OwnerRefNameTagName, owner.Name)
		builder.addNotEmpty(kubernetes.OwnerRefKindTagName, strings.ToLower(owner.Kind))
		builder.addNotEmpty(kubernetes.KindToTagName[owner.Kind], owner.Name)
	}
	tags := builder.tags()
	cache.Cache.Set(tagsCacheKey, tags, tagsCacheTTL)
	return tags, nil
}
func MetaToTags ( kind string , meta metav1 . Object ) ( [ ] string , error ) { objUID := string ( meta . GetUID ( ) ) if objUID == " " { return nil , errors . New ( " " ) } tagsCacheKey := tagsCacheKeyPrefix + objUID if tagsCache , found := cache . Cache . Get ( tagsCacheKey ) ; found { tags , ok := tagsCache . ( [ ] string ) if ! ok { return nil , errors . New ( " " ) } return tags , nil } builder := newTagListBuilder ( ) builder . addNotEmpty ( kubernetes . NamespaceTagName , meta . GetNamespace ( ) ) builder . addNotEmpty ( kubernetes . ResourceNameTagName , meta . GetName ( ) ) builder . addNotEmpty ( kubernetes . ResourceKindTagName , strings . ToLower ( kind ) ) builder . addNotEmpty ( kubernetes . KindToTagName [ kind ] , meta . GetName ( ) ) for _ , owner := range meta . GetOwnerReferences ( ) { builder . addNotEmpty ( kubernetes . OwnerRefNameTagName , owner . Name ) builder . addNotEmpty ( kubernetes . OwnerRefKindTagName , strings . ToLower ( owner . Kind ) ) builder . addNotEmpty ( kubernetes . KindToTagName [ owner . Kind ] , owner . Name ) } tags := builder . tags ( ) cache . Cache . Set ( tagsCacheKey , tags , tagsCacheTTL ) return tags , nil }
MetaToTags extracts tags for structured Kubernetes objects based on kind and metadata.
MetaToTags extracts tags for structured Kubernetes objects based on kind and metadata .