cri-o/libkpod/image/metadata.go
Ryan Cole 95e17b4a73 move driver and image metadata to libkpod
Signed-off-by: Ryan Cole <rcyoalne@gmail.com>
2017-07-24 14:34:55 -04:00

32 lines
876 B
Go

package image
import (
"encoding/json"
"strings"
"time"
"github.com/containers/image/types"
"github.com/containers/storage"
)
// Metadata stores all of the metadata for an image
type Metadata struct {
Tag string `json:"tag"`
CreatedTime time.Time `json:"created-time"`
ID string `json:"id"`
Blobs []types.BlobInfo `json:"blob-list"`
Layers map[string][]string `json:"layers"`
SignatureSizes []string `json:"signature-sizes"`
}
// ParseMetadata takes an image, parses the json stored in it's metadata
// field, and converts it to a Metadata struct
func ParseMetadata(image storage.Image) (Metadata, error) {
var m Metadata
dec := json.NewDecoder(strings.NewReader(image.Metadata))
if err := dec.Decode(&m); err != nil {
return Metadata{}, err
}
return m, nil
}