func FilterAndSortRepositoryMetadata(rm image.RepositoryMetadata, pattern policy.Pattern) (SortedImageInfos, error) {
	filteredMetadata := image.RepositoryMetadata{
		Tags:   filterTags(rm.Tags, pattern),
		Images: rm.Images,
	}
	filteredImages, err := filteredMetadata.GetImageTagInfo()
	if err != nil {
		return nil, err
	}
	return SortImages(filteredImages, pattern), nil
}
FilterAndSortRepositoryMetadata obtains all the image information from the metadata
after filtering and sorting. Filtering happens in the metadata directly to minimize
problems with tag inconsistencies (i.e. tags without matching image information)
package update
import (
	"fmt"
	"strings"
	"github.com/go-kit/kit/log"
	"github.com/pkg/errors"
	fluxerr "github.com/fluxcd/flux/pkg/errors"
	"github.com/fluxcd/flux/pkg/image"
	"github.com/fluxcd/flux/pkg/policy"
	"github.com/fluxcd/flux/pkg/registry"
	"github.com/fluxcd/flux/pkg/resource"
)
type imageReposMap map[image.CanonicalName]image.RepositoryMetadata
type ImageRepos struct {
	imageRepos imageReposMap
}
func (r ImageRepos) GetRepositoryMetadata(repo image.Name) image.RepositoryMetadata {
	if metadata, ok := r.imageRepos[repo.CanonicalName()]; ok {
		tagsCopy := make([]string, len(metadata.Tags))
		copy(tagsCopy, metadata.Tags)
		imagesCopy := make(map[string]image.Info, len(metadata.Images))
		for tag, info := range metadata.Images {
			info.ID = repo.ToRef(info.ID.Tag)
			imagesCopy[tag] = info
		}
		return image.RepositoryMetadata{tagsCopy, imagesCopy}
	}
	return image.RepositoryMetadata{}
}
type SortedImageInfos []image.Info
func FilterImages(images []image.Info, pattern policy.Pattern) []image.Info {
	return filterImages(images, pattern)
}
func SortImages(images []image.Info, pattern policy.Pattern) SortedImageInfos {
	return sortImages(images, pattern)
}