metadata: expand container runtime into bucket

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day
2017-06-21 16:16:02 -07:00
parent 6fbe4bd568
commit ea44901921
3 changed files with 49 additions and 43 deletions

View File

@@ -1,10 +1,7 @@
package containers
import (
"bytes"
"context"
"encoding/gob"
"errors"
"time"
)
@@ -28,39 +25,6 @@ type RuntimeInfo struct {
Options map[string]string
}
type marshaledRuntimeInfo struct {
Name string
Options map[string]string
}
func (r *RuntimeInfo) MarshalBinary() ([]byte, error) {
buf := bytes.NewBuffer(nil)
if err := gob.NewEncoder(buf).Encode(marshaledRuntimeInfo{
Name: r.Name,
Options: r.Options,
}); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func (r *RuntimeInfo) UnmarshalBinary(data []byte) error {
buf := data
if len(buf) == 0 {
return errors.New("RuntimeInfo: no data")
}
var (
mr marshaledRuntimeInfo
reader = bytes.NewReader(buf)
)
if err := gob.NewDecoder(reader).Decode(&mr); err != nil {
return err
}
r.Name = mr.Name
r.Options = mr.Options
return nil
}
type Store interface {
Get(ctx context.Context, id string) (Container, error)
List(ctx context.Context, filter string) ([]Container, error)