move driver and image metadata to libkpod
Signed-off-by: Ryan Cole <rcyoalne@gmail.com>
This commit is contained in:
parent
a95bbe9608
commit
95e17b4a73
10 changed files with 81 additions and 903 deletions
1
libkpod/image/image.go
Normal file
1
libkpod/image/image.go
Normal file
|
@ -0,0 +1 @@
|
|||
package image
|
32
libkpod/image/metadata.go
Normal file
32
libkpod/image/metadata.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue