kubelet/rktshim: update cri to protobuf v3

This commit is contained in:
Pengfei Ni 2017-01-20 09:55:19 +08:00
parent 76afc7300d
commit e77e61b3bb
2 changed files with 13 additions and 15 deletions

View File

@ -90,16 +90,14 @@ type fakeContainer struct {
func (c *fakeContainer) Start() { func (c *fakeContainer) Start() {
c.State = runtimeapi.ContainerState_CONTAINER_RUNNING c.State = runtimeapi.ContainerState_CONTAINER_RUNNING
c.Status.State = &c.State c.Status.State = c.State
} }
func (c *fakeContainer) Stop() { func (c *fakeContainer) Stop() {
c.State = runtimeapi.ContainerState_CONTAINER_EXITED c.State = runtimeapi.ContainerState_CONTAINER_EXITED
c.Status.State = &c.State c.Status.State = c.State
c.Status.ExitCode = 0
exitSuccess := int32(0)
c.Status.ExitCode = &exitSuccess
// c.Status.Reason // c.Status.Reason
} }
@ -191,7 +189,7 @@ func (r *FakeRuntime) ListContainers(*runtimeapi.ContainerFilter) ([]*runtimeapi
Metadata: c.Config.Metadata, Metadata: c.Config.Metadata,
Labels: c.Config.Labels, Labels: c.Config.Labels,
ImageRef: c.Status.ImageRef, ImageRef: c.Status.ImageRef,
State: &c.State, State: c.State,
}) })
} }
@ -226,15 +224,15 @@ func (r *FakeRuntime) ExecSync(containerID string, cmd []string, timeout time.Du
} }
func (r *FakeRuntime) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) { func (r *FakeRuntime) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) {
url := "http://" + FakeStreamingHost + ":" + FakeStreamingPort + "/exec/" + req.GetContainerId() url := "http://" + FakeStreamingHost + ":" + FakeStreamingPort + "/exec/" + req.ContainerId
return &runtimeapi.ExecResponse{ return &runtimeapi.ExecResponse{
Url: &url, Url: url,
}, nil }, nil
} }
func (r *FakeRuntime) Attach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) { func (r *FakeRuntime) Attach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) {
url := "http://" + FakeStreamingHost + ":" + FakeStreamingPort + "/attach/" + req.GetContainerId() url := "http://" + FakeStreamingHost + ":" + FakeStreamingPort + "/attach/" + req.ContainerId
return &runtimeapi.AttachResponse{ return &runtimeapi.AttachResponse{
Url: &url, Url: url,
}, nil }, nil
} }

View File

@ -63,19 +63,19 @@ var (
var testImgSpecs = map[string]imageTestCase{ var testImgSpecs = map[string]imageTestCase{
"non-existent-image": { "non-existent-image": {
&runtimeapi.ImageSpec{ &runtimeapi.ImageSpec{
Image: &gibberishStr, Image: gibberishStr,
}, },
nil, nil,
}, },
"busybox": { "busybox": {
&runtimeapi.ImageSpec{ &runtimeapi.ImageSpec{
Image: &busyboxStr, Image: busyboxStr,
}, },
&runtimeapi.Image{ &runtimeapi.Image{
Id: nil, Id: "",
RepoTags: []string{}, RepoTags: []string{},
RepoDigests: []string{}, RepoDigests: []string{},
Size_: nil, Size_: 0,
}, },
}, },
} }
@ -201,7 +201,7 @@ func TestListsImages(t *testing.T) {
} }
for _, img := range imgs { for _, img := range imgs {
expectedImg := *testImgSpecs[*img.Id].ExpectedStatus expectedImg := *testImgSpecs[img.Id].ExpectedStatus
if err := compareContainerImages(img, expectedImg); err != nil { if err := compareContainerImages(img, expectedImg); err != nil {
t.Errorf("rktshim.ImageStore.List() for %q, %v", img.Id, err) t.Errorf("rktshim.ImageStore.List() for %q, %v", img.Id, err)