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

@@ -7,6 +7,7 @@ import (
"log"
"net/http"
"runtime"
"strconv"
"sync"
"time"
@@ -31,9 +32,11 @@ import (
imagesservice "github.com/containerd/containerd/services/images"
snapshotservice "github.com/containerd/containerd/services/snapshot"
"github.com/containerd/containerd/snapshot"
"github.com/containerd/containerd/typeurl"
pempty "github.com/golang/protobuf/ptypes/empty"
"github.com/opencontainers/image-spec/identity"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/grpclog"
@@ -43,6 +46,13 @@ import (
func init() {
// reset the grpc logger so that it does not output in the STDIO of the calling process
grpclog.SetLogger(log.New(ioutil.Discard, "", log.LstdFlags))
// register TypeUrls for commonly marshaled external types
major := strconv.Itoa(specs.VersionMajor)
typeurl.Register(specs.Spec{}, "opencontainers/runtime-spec", major, "Spec")
typeurl.Register(specs.Process{}, "opencontainers/runtime-spec", major, "Process")
typeurl.Register(specs.LinuxResources{}, "opencontainers/runtime-spec", major, "LinuxResources")
typeurl.Register(specs.WindowsResources{}, "opencontainers/runtime-spec", major, "WindowsResources")
}
type clientOpts struct {