func GetImageFilesJson(s storage.Storage, imageID string) ([]byte, error) {
	filesJson, err := GetImageFilesCache(s, imageID)
	if err != nil {
		return filesJson, nil
	}
	tarFilesInfo := NewTarFilesInfo()
	if reader, err := s.GetReader(storage.ImageLayerPath(imageID)); err != nil {
		return nil, err
	} else if err := tarFilesInfo.Load(reader); err != nil {
		return nil, err
	}
	return tarFilesInfo.Json()
}
return json file listing for given image id
Download the specified layer and determine the file contents. If the cache already exists, just return it.
package layers
import (
	"encoding/json"
	"errors"
	"regexp"
	"registry/logger"
	"registry/storage"
	"strings"
)
func UpdateIndexImages(s storage.Storage, namespace, repo string, additionalBytes []byte,
	additional []map[string]interface{}) error {
	path := storage.RepoIndexImagesPath(namespace, repo)
	previousData, err := s.Get(path)
	if err != nil {
		return s.Put(path, additionalBytes)
	}
	var previous []map[string]interface{}
	if err := json.Unmarshal(previousData, &previous); err != nil {
		return err
	}
	if len(previous) == 0 {
		return s.Put(path, additionalBytes)
	}
	newImagesMap := map[string]map[string]interface{}{}
	for _, value := range additional {
		id, ok := value["id"].(string)
		if !ok {
			return errors.New("Invalid Data")
		}
		if imageData, ok := newImagesMap[id]; ok {
			if _, ok := imageData["checksum"]; ok {
				continue
			}
		}
		newImagesMap[id] = value
	}
	for _, value := range previous {
		id, ok := value["id"].(string)
		if !ok {
			return errors.New("Invalid Data")
		}
		if imageData, ok := newImagesMap[id]; ok {
			if _, ok := imageData["checksum"]; ok {
				continue
			}
		}
		newImagesMap[id] = value
	}
	newImagesArr := make([]map[string]interface{}, len(newImagesMap))
	i := 0
	for _, image := range newImagesMap {
		newImagesArr[i] = image
		i++
	}
	data, err := json.Marshal(&newImagesArr)
	if err != nil {
		return err
	}
	return s.Put(path, data)
}
func GetImageFilesCache(s storage.Storage, imageID string) ([]byte, error) {
	return s.Get(storage.ImageFilesPath(imageID))
}
func SetImageFilesCache(s storage.Storage, imageID string, filesJson []byte) error {
	return s.Put(storage.ImageFilesPath(imageID), filesJson)
}