metadata: switch value encoding to json.RawMessage
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>docker-18.09
parent
504818c289
commit
2c5ff4fc59
|
@ -261,8 +261,8 @@ func (s *StorageItem) SetValue(b *bolt.Bucket, key string, v Value) error {
|
|||
}
|
||||
|
||||
type Value struct {
|
||||
Data []byte
|
||||
Index string
|
||||
Value json.RawMessage `json:"value,omitempty"`
|
||||
Index string `json:"index,omitempty"`
|
||||
// External bool
|
||||
}
|
||||
|
||||
|
@ -271,11 +271,11 @@ func NewValue(v interface{}) (*Value, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Value{Data: dt}, nil
|
||||
return &Value{Value: json.RawMessage(dt)}, nil
|
||||
}
|
||||
|
||||
func (v *Value) Unmarshal(target interface{}) error {
|
||||
err := json.Unmarshal(v.Data, target)
|
||||
err := json.Unmarshal(v.Value, target)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package debug
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/moby/buildkit/cache/metadata"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -22,15 +20,7 @@ var DumpMetadataCommand = cli.Command{
|
|||
Action: func(clicontext *cli.Context) error {
|
||||
dbFile := filepath.Join(clicontext.String("root"), "metadata.db")
|
||||
return dumpBolt(dbFile, func(k, v []byte) string {
|
||||
raw := fmt.Sprintf("%q: %q", string(k), string(v))
|
||||
if len(v) == 0 {
|
||||
return raw
|
||||
}
|
||||
var mv metadata.Value
|
||||
if err := json.Unmarshal(v, &mv); err != nil {
|
||||
return raw
|
||||
}
|
||||
return fmt.Sprintf("%q: {\"Data\":%q, \"Index\":%q}", string(k), string(mv.Data), mv.Index)
|
||||
return fmt.Sprintf("%q: %s", string(k), string(v))
|
||||
})
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue