Use typeurl package for spec types

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-07-05 15:11:59 -07:00
parent f8720382b3
commit a60511d5aa
22 changed files with 163 additions and 264 deletions

View File

@@ -230,8 +230,11 @@ func readContainer(container *containers.Container, bkt *bolt.Bucket) error {
}
container.Runtime.Options = &any
case string(bucketKeySpec):
container.Spec = make([]byte, len(v))
copy(container.Spec, v)
var any types.Any
if err := proto.Unmarshal(v, &any); err != nil {
return err
}
container.Spec = &any
case string(bucketKeyRootFS):
container.RootFS = string(v)
case string(bucketKeyCreatedAt):
@@ -269,10 +272,14 @@ func writeContainer(container *containers.Container, bkt *bolt.Bucket) error {
if err != nil {
return err
}
spec, err := container.Spec.Marshal()
if err != nil {
return err
}
for _, v := range [][2][]byte{
{bucketKeyImage, []byte(container.Image)},
{bucketKeySpec, container.Spec},
{bucketKeySpec, spec},
{bucketKeyRootFS, []byte(container.RootFS)},
{bucketKeyCreatedAt, createdAt},
{bucketKeyUpdatedAt, updatedAt},