Example #1
0
// 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.
func GetImageFilesJson(s storage.Storage, imageID string) ([]byte, error) {
	// if the files json exists in the cache, return it
	filesJson, err := GetImageFilesCache(s, imageID)
	if err != nil {
		return filesJson, nil
	}

	// cache doesn't exist. download remote layer
	// docker-registry 0.6.5 has an lzma decompress here. it actually doesn't seem to be used so i've omitted it
	// will add it later if need be.
	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()
}