Remove github.com/gogo/protobuf again

While we need to support CRI v1alpha2, the implementation doesn't have
to be tied to gogo/protobuf.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
Kazuyoshi Kato 2022-12-15 18:19:45 +00:00
parent a4bc380b91
commit 52a7480399
9 changed files with 9985 additions and 36706 deletions

View File

@ -105,9 +105,9 @@ GO_LDFLAGS+='
SHIM_GO_LDFLAGS=-ldflags '-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PACKAGE) -extldflags "-static" $(EXTRA_LDFLAGS)' SHIM_GO_LDFLAGS=-ldflags '-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PACKAGE) -extldflags "-static" $(EXTRA_LDFLAGS)'
# Project packages. # Project packages.
PACKAGES=$(shell $(GO) list ${GO_TAGS} ./... | grep -v /vendor/ | grep -v /integration | grep -v /third_party) PACKAGES=$(shell $(GO) list ${GO_TAGS} ./... | grep -v /vendor/ | grep -v /integration)
API_PACKAGES=$(shell (cd api && $(GO) list ${GO_TAGS} ./... | grep -v /vendor/ | grep -v /integration | grep -v /third_party)) API_PACKAGES=$(shell (cd api && $(GO) list ${GO_TAGS} ./... | grep -v /vendor/ | grep -v /integration))
NON_API_PACKAGES=$(shell $(GO) list ${GO_TAGS} ./... | grep -v /vendor/ | grep -v /integration | grep -v /third_party | grep -v "containerd/api") NON_API_PACKAGES=$(shell $(GO) list ${GO_TAGS} ./... | grep -v /vendor/ | grep -v /integration | grep -v "containerd/api")
TEST_REQUIRES_ROOT_PACKAGES=$(filter \ TEST_REQUIRES_ROOT_PACKAGES=$(filter \
${PACKAGES}, \ ${PACKAGES}, \
$(shell \ $(shell \
@ -172,7 +172,7 @@ generate: protos
protos: bin/protoc-gen-go-fieldpath protos: bin/protoc-gen-go-fieldpath
@echo "$(WHALE) $@" @echo "$(WHALE) $@"
@find . -path ./vendor -prune -false -o -path ./third_party -prune -false -o -name '*.pb.go' | xargs rm @find . -path ./vendor -prune -false -o -name '*.pb.go' | xargs rm
$(eval TMPDIR := $(shell mktemp -d)) $(eval TMPDIR := $(shell mktemp -d))
@mv ${ROOTDIR}/vendor ${TMPDIR} @mv ${ROOTDIR}/vendor ${TMPDIR}
@(cd ${ROOTDIR}/api && PATH="${ROOTDIR}/bin:${PATH}" protobuild --quiet ${API_PACKAGES}) @(cd ${ROOTDIR}/api && PATH="${ROOTDIR}/bin:${PATH}" protobuild --quiet ${API_PACKAGES})
@ -195,7 +195,7 @@ check-api-descriptors: protos ## check that protobuf changes aren't present.
proto-fmt: ## check format of proto files proto-fmt: ## check format of proto files
@echo "$(WHALE) $@" @echo "$(WHALE) $@"
@test -z "$$(find . -path ./vendor -prune -o -path ./protobuf/google/rpc -prune -o -path ./third_party -prune -false -o -name '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \ @test -z "$$(find . -path ./vendor -prune -o -path ./protobuf/google/rpc -prune -o -name '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \
(echo "$(ONI) please indent proto files with tabs only" && false) (echo "$(ONI) please indent proto files with tabs only" && false)
build: ## build the go packages build: ## build the go packages

View File

@ -22,6 +22,12 @@ prefixes = [
] ]
generators = ["go", "go-ttrpc"] generators = ["go", "go-ttrpc"]
[[overrides]]
prefixes = [
"github.com/containerd/containerd/third_party/k8s.io/cri-api/pkg/apis/runtime/v1alpha2",
]
generators = ["go", "go-grpc"]
# Lock down runc config # Lock down runc config
[[descriptors]] [[descriptors]]
prefix = "github.com/containerd/containerd/runtime/linux/runctypes" prefix = "github.com/containerd/containerd/runtime/linux/runctypes"

2
go.mod
View File

@ -30,7 +30,6 @@ require (
github.com/docker/go-units v0.4.0 github.com/docker/go-units v0.4.0
github.com/emicklei/go-restful/v3 v3.8.0 github.com/emicklei/go-restful/v3 v3.8.0
github.com/fsnotify/fsnotify v1.6.0 github.com/fsnotify/fsnotify v1.6.0
github.com/gogo/protobuf v1.3.2
github.com/google/go-cmp v0.5.9 github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.0 github.com/google/uuid v1.3.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
@ -97,6 +96,7 @@ require (
github.com/go-logr/logr v1.2.3 // indirect github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect
github.com/godbus/dbus/v5 v5.0.6 // indirect github.com/godbus/dbus/v5 v5.0.6 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect github.com/google/gofuzz v1.2.0 // indirect

View File

@ -41,6 +41,8 @@ func newInstrumentedService(c *criService) grpcServices {
// instrumentedAlphaService wraps service with containerd namespace and logs. // instrumentedAlphaService wraps service with containerd namespace and logs.
type instrumentedAlphaService struct { type instrumentedAlphaService struct {
c *criService c *criService
runtime_alpha.UnimplementedRuntimeServiceServer
runtime_alpha.UnimplementedImageServiceServer
} }
func newInstrumentedAlphaService(c *criService) grpcAlphaServices { func newInstrumentedAlphaService(c *criService) grpcAlphaServices {
@ -99,14 +101,14 @@ func (in *instrumentedAlphaService) RunPodSandbox(ctx context.Context, r *runtim
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.RunPodSandboxRequest var v1r runtime.RunPodSandboxRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.RunPodSandboxResponse var v1res *runtime.RunPodSandboxResponse
v1res, err = in.c.RunPodSandbox(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.RunPodSandbox(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.RunPodSandboxResponse{} resp := &runtime_alpha.RunPodSandboxResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -152,14 +154,14 @@ func (in *instrumentedAlphaService) ListPodSandbox(ctx context.Context, r *runti
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ListPodSandboxRequest var v1r runtime.ListPodSandboxRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ListPodSandboxResponse var v1res *runtime.ListPodSandboxResponse
v1res, err = in.c.ListPodSandbox(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ListPodSandbox(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ListPodSandboxResponse{} resp := &runtime_alpha.ListPodSandboxResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -205,14 +207,14 @@ func (in *instrumentedAlphaService) PodSandboxStatus(ctx context.Context, r *run
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.PodSandboxStatusRequest var v1r runtime.PodSandboxStatusRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.PodSandboxStatusResponse var v1res *runtime.PodSandboxStatusResponse
v1res, err = in.c.PodSandboxStatus(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.PodSandboxStatus(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.PodSandboxStatusResponse{} resp := &runtime_alpha.PodSandboxStatusResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -258,14 +260,14 @@ func (in *instrumentedAlphaService) StopPodSandbox(ctx context.Context, r *runti
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.StopPodSandboxRequest var v1r runtime.StopPodSandboxRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.StopPodSandboxResponse var v1res *runtime.StopPodSandboxResponse
v1res, err = in.c.StopPodSandbox(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.StopPodSandbox(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.StopPodSandboxResponse{} resp := &runtime_alpha.StopPodSandboxResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -311,14 +313,14 @@ func (in *instrumentedAlphaService) RemovePodSandbox(ctx context.Context, r *run
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.RemovePodSandboxRequest var v1r runtime.RemovePodSandboxRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.RemovePodSandboxResponse var v1res *runtime.RemovePodSandboxResponse
v1res, err = in.c.RemovePodSandbox(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.RemovePodSandbox(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.RemovePodSandboxResponse{} resp := &runtime_alpha.RemovePodSandboxResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -364,14 +366,14 @@ func (in *instrumentedAlphaService) PortForward(ctx context.Context, r *runtime_
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.PortForwardRequest var v1r runtime.PortForwardRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.PortForwardResponse var v1res *runtime.PortForwardResponse
v1res, err = in.c.PortForward(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.PortForward(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.PortForwardResponse{} resp := &runtime_alpha.PortForwardResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -423,14 +425,14 @@ func (in *instrumentedAlphaService) CreateContainer(ctx context.Context, r *runt
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.CreateContainerRequest var v1r runtime.CreateContainerRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.CreateContainerResponse var v1res *runtime.CreateContainerResponse
v1res, err = in.c.CreateContainer(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.CreateContainer(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.CreateContainerResponse{} resp := &runtime_alpha.CreateContainerResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -477,14 +479,14 @@ func (in *instrumentedAlphaService) StartContainer(ctx context.Context, r *runti
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.StartContainerRequest var v1r runtime.StartContainerRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.StartContainerResponse var v1res *runtime.StartContainerResponse
v1res, err = in.c.StartContainer(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.StartContainer(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.StartContainerResponse{} resp := &runtime_alpha.StartContainerResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -532,14 +534,14 @@ func (in *instrumentedAlphaService) ListContainers(ctx context.Context, r *runti
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ListContainersRequest var v1r runtime.ListContainersRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ListContainersResponse var v1res *runtime.ListContainersResponse
v1res, err = in.c.ListContainers(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ListContainers(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ListContainersResponse{} resp := &runtime_alpha.ListContainersResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -585,14 +587,14 @@ func (in *instrumentedAlphaService) ContainerStatus(ctx context.Context, r *runt
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ContainerStatusRequest var v1r runtime.ContainerStatusRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ContainerStatusResponse var v1res *runtime.ContainerStatusResponse
v1res, err = in.c.ContainerStatus(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ContainerStatus(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ContainerStatusResponse{} resp := &runtime_alpha.ContainerStatusResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -638,14 +640,14 @@ func (in *instrumentedAlphaService) StopContainer(ctx context.Context, r *runtim
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.StopContainerRequest var v1r runtime.StopContainerRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.StopContainerResponse var v1res *runtime.StopContainerResponse
v1res, err = in.c.StopContainer(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.StopContainer(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.StopContainerResponse{} resp := &runtime_alpha.StopContainerResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -691,14 +693,14 @@ func (in *instrumentedAlphaService) RemoveContainer(ctx context.Context, r *runt
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.RemoveContainerRequest var v1r runtime.RemoveContainerRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.RemoveContainerResponse var v1res *runtime.RemoveContainerResponse
v1res, err = in.c.RemoveContainer(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.RemoveContainer(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.RemoveContainerResponse{} resp := &runtime_alpha.RemoveContainerResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -744,14 +746,14 @@ func (in *instrumentedAlphaService) ExecSync(ctx context.Context, r *runtime_alp
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ExecSyncRequest var v1r runtime.ExecSyncRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ExecSyncResponse var v1res *runtime.ExecSyncResponse
v1res, err = in.c.ExecSync(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ExecSync(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ExecSyncResponse{} resp := &runtime_alpha.ExecSyncResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -799,14 +801,14 @@ func (in *instrumentedAlphaService) Exec(ctx context.Context, r *runtime_alpha.E
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ExecRequest var v1r runtime.ExecRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ExecResponse var v1res *runtime.ExecResponse
v1res, err = in.c.Exec(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.Exec(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ExecResponse{} resp := &runtime_alpha.ExecResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -852,14 +854,14 @@ func (in *instrumentedAlphaService) Attach(ctx context.Context, r *runtime_alpha
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.AttachRequest var v1r runtime.AttachRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.AttachResponse var v1res *runtime.AttachResponse
v1res, err = in.c.Attach(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.Attach(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.AttachResponse{} resp := &runtime_alpha.AttachResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -905,14 +907,14 @@ func (in *instrumentedAlphaService) UpdateContainerResources(ctx context.Context
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.UpdateContainerResourcesRequest var v1r runtime.UpdateContainerResourcesRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.UpdateContainerResourcesResponse var v1res *runtime.UpdateContainerResourcesResponse
v1res, err = in.c.UpdateContainerResources(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.UpdateContainerResources(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.UpdateContainerResourcesResponse{} resp := &runtime_alpha.UpdateContainerResourcesResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -966,14 +968,14 @@ func (in *instrumentedAlphaService) PullImage(ctx context.Context, r *runtime_al
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.PullImageRequest var v1r runtime.PullImageRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.PullImageResponse var v1res *runtime.PullImageResponse
v1res, err = in.c.PullImage(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.PullImage(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.PullImageResponse{} resp := &runtime_alpha.PullImageResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1027,14 +1029,14 @@ func (in *instrumentedAlphaService) ListImages(ctx context.Context, r *runtime_a
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ListImagesRequest var v1r runtime.ListImagesRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ListImagesResponse var v1res *runtime.ListImagesResponse
v1res, err = in.c.ListImages(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ListImages(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ListImagesResponse{} resp := &runtime_alpha.ListImagesResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1088,14 +1090,14 @@ func (in *instrumentedAlphaService) ImageStatus(ctx context.Context, r *runtime_
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ImageStatusRequest var v1r runtime.ImageStatusRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ImageStatusResponse var v1res *runtime.ImageStatusResponse
v1res, err = in.c.ImageStatus(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ImageStatus(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ImageStatusResponse{} resp := &runtime_alpha.ImageStatusResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1147,14 +1149,14 @@ func (in *instrumentedAlphaService) RemoveImage(ctx context.Context, r *runtime_
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.RemoveImageRequest var v1r runtime.RemoveImageRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.RemoveImageResponse var v1res *runtime.RemoveImageResponse
v1res, err = in.c.RemoveImage(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.RemoveImage(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.RemoveImageResponse{} resp := &runtime_alpha.RemoveImageResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1206,14 +1208,14 @@ func (in *instrumentedAlphaService) ImageFsInfo(ctx context.Context, r *runtime_
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ImageFsInfoRequest var v1r runtime.ImageFsInfoRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ImageFsInfoResponse var v1res *runtime.ImageFsInfoResponse
v1res, err = in.c.ImageFsInfo(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ImageFsInfo(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ImageFsInfoResponse{} resp := &runtime_alpha.ImageFsInfoResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1259,14 +1261,14 @@ func (in *instrumentedAlphaService) PodSandboxStats(ctx context.Context, r *runt
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.PodSandboxStatsRequest var v1r runtime.PodSandboxStatsRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.PodSandboxStatsResponse var v1res *runtime.PodSandboxStatsResponse
v1res, err = in.c.PodSandboxStats(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.PodSandboxStats(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.PodSandboxStatsResponse{} resp := &runtime_alpha.PodSandboxStatsResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1312,14 +1314,14 @@ func (in *instrumentedAlphaService) ContainerStats(ctx context.Context, r *runti
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ContainerStatsRequest var v1r runtime.ContainerStatsRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ContainerStatsResponse var v1res *runtime.ContainerStatsResponse
v1res, err = in.c.ContainerStats(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ContainerStats(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ContainerStatsResponse{} resp := &runtime_alpha.ContainerStatsResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1365,14 +1367,14 @@ func (in *instrumentedAlphaService) ListPodSandboxStats(ctx context.Context, r *
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ListPodSandboxStatsRequest var v1r runtime.ListPodSandboxStatsRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ListPodSandboxStatsResponse var v1res *runtime.ListPodSandboxStatsResponse
v1res, err = in.c.ListPodSandboxStats(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ListPodSandboxStats(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ListPodSandboxStatsResponse{} resp := &runtime_alpha.ListPodSandboxStatsResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1418,14 +1420,14 @@ func (in *instrumentedAlphaService) ListContainerStats(ctx context.Context, r *r
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ListContainerStatsRequest var v1r runtime.ListContainerStatsRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ListContainerStatsResponse var v1res *runtime.ListContainerStatsResponse
v1res, err = in.c.ListContainerStats(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ListContainerStats(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ListContainerStatsResponse{} resp := &runtime_alpha.ListContainerStatsResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1471,14 +1473,14 @@ func (in *instrumentedAlphaService) Status(ctx context.Context, r *runtime_alpha
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.StatusRequest var v1r runtime.StatusRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.StatusResponse var v1res *runtime.StatusResponse
v1res, err = in.c.Status(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.Status(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.StatusResponse{} resp := &runtime_alpha.StatusResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1556,14 +1558,14 @@ func (in *instrumentedAlphaService) UpdateRuntimeConfig(ctx context.Context, r *
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.UpdateRuntimeConfigRequest var v1r runtime.UpdateRuntimeConfigRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.UpdateRuntimeConfigResponse var v1res *runtime.UpdateRuntimeConfigResponse
v1res, err = in.c.UpdateRuntimeConfig(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.UpdateRuntimeConfig(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.UpdateRuntimeConfigResponse{} resp := &runtime_alpha.UpdateRuntimeConfigResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1609,14 +1611,14 @@ func (in *instrumentedAlphaService) ReopenContainerLog(ctx context.Context, r *r
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ReopenContainerLogRequest var v1r runtime.ReopenContainerLogRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ReopenContainerLogResponse var v1res *runtime.ReopenContainerLogResponse
v1res, err = in.c.ReopenContainerLog(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ReopenContainerLog(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ReopenContainerLogResponse{} resp := &runtime_alpha.ReopenContainerLogResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1700,33 +1702,3 @@ func (in *instrumentedService) ListPodSandboxMetrics(ctx context.Context, r *run
res, err = in.c.ListPodSandboxMetrics(ctx, r) res, err = in.c.ListPodSandboxMetrics(ctx, r)
return res, errdefs.ToGRPC(err) return res, errdefs.ToGRPC(err)
} }
func alphaReqToV1Req(
alphar interface{ Marshal() ([]byte, error) },
v1r interface{ Unmarshal(_ []byte) error },
) error {
p, err := alphar.Marshal()
if err != nil {
return err
}
if err = v1r.Unmarshal(p); err != nil {
return err
}
return nil
}
func v1RespToAlphaResp(
v1res interface{ Marshal() ([]byte, error) },
alphares interface{ Unmarshal(_ []byte) error },
) error {
p, err := v1res.Marshal()
if err != nil {
return err
}
if err = alphares.Unmarshal(p); err != nil {
return err
}
return nil
}

View File

@ -41,6 +41,8 @@ func newInstrumentedService(c *criService) grpcServices {
// instrumentedAlphaService wraps service with containerd namespace and logs. // instrumentedAlphaService wraps service with containerd namespace and logs.
type instrumentedAlphaService struct { type instrumentedAlphaService struct {
c *criService c *criService
runtime_alpha.UnimplementedRuntimeServiceServer
runtime_alpha.UnimplementedImageServiceServer
} }
func newInstrumentedAlphaService(c *criService) grpcAlphaServices { func newInstrumentedAlphaService(c *criService) grpcAlphaServices {
@ -99,14 +101,14 @@ func (in *instrumentedAlphaService) RunPodSandbox(ctx context.Context, r *runtim
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.RunPodSandboxRequest var v1r runtime.RunPodSandboxRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.RunPodSandboxResponse var v1res *runtime.RunPodSandboxResponse
v1res, err = in.c.RunPodSandbox(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.RunPodSandbox(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.RunPodSandboxResponse{} resp := &runtime_alpha.RunPodSandboxResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -152,14 +154,14 @@ func (in *instrumentedAlphaService) ListPodSandbox(ctx context.Context, r *runti
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ListPodSandboxRequest var v1r runtime.ListPodSandboxRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ListPodSandboxResponse var v1res *runtime.ListPodSandboxResponse
v1res, err = in.c.ListPodSandbox(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ListPodSandbox(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ListPodSandboxResponse{} resp := &runtime_alpha.ListPodSandboxResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -205,14 +207,14 @@ func (in *instrumentedAlphaService) PodSandboxStatus(ctx context.Context, r *run
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.PodSandboxStatusRequest var v1r runtime.PodSandboxStatusRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.PodSandboxStatusResponse var v1res *runtime.PodSandboxStatusResponse
v1res, err = in.c.PodSandboxStatus(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.PodSandboxStatus(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.PodSandboxStatusResponse{} resp := &runtime_alpha.PodSandboxStatusResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -258,14 +260,14 @@ func (in *instrumentedAlphaService) StopPodSandbox(ctx context.Context, r *runti
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.StopPodSandboxRequest var v1r runtime.StopPodSandboxRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.StopPodSandboxResponse var v1res *runtime.StopPodSandboxResponse
v1res, err = in.c.StopPodSandbox(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.StopPodSandbox(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.StopPodSandboxResponse{} resp := &runtime_alpha.StopPodSandboxResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -311,14 +313,14 @@ func (in *instrumentedAlphaService) RemovePodSandbox(ctx context.Context, r *run
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.RemovePodSandboxRequest var v1r runtime.RemovePodSandboxRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.RemovePodSandboxResponse var v1res *runtime.RemovePodSandboxResponse
v1res, err = in.c.RemovePodSandbox(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.RemovePodSandbox(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.RemovePodSandboxResponse{} resp := &runtime_alpha.RemovePodSandboxResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -364,14 +366,14 @@ func (in *instrumentedAlphaService) PortForward(ctx context.Context, r *runtime_
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.PortForwardRequest var v1r runtime.PortForwardRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.PortForwardResponse var v1res *runtime.PortForwardResponse
v1res, err = in.c.PortForward(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.PortForward(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.PortForwardResponse{} resp := &runtime_alpha.PortForwardResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -423,14 +425,14 @@ func (in *instrumentedAlphaService) CreateContainer(ctx context.Context, r *runt
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.CreateContainerRequest var v1r runtime.CreateContainerRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.CreateContainerResponse var v1res *runtime.CreateContainerResponse
v1res, err = in.c.CreateContainer(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.CreateContainer(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.CreateContainerResponse{} resp := &runtime_alpha.CreateContainerResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -477,14 +479,14 @@ func (in *instrumentedAlphaService) StartContainer(ctx context.Context, r *runti
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.StartContainerRequest var v1r runtime.StartContainerRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.StartContainerResponse var v1res *runtime.StartContainerResponse
v1res, err = in.c.StartContainer(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.StartContainer(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.StartContainerResponse{} resp := &runtime_alpha.StartContainerResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -532,14 +534,14 @@ func (in *instrumentedAlphaService) ListContainers(ctx context.Context, r *runti
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ListContainersRequest var v1r runtime.ListContainersRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ListContainersResponse var v1res *runtime.ListContainersResponse
v1res, err = in.c.ListContainers(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ListContainers(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ListContainersResponse{} resp := &runtime_alpha.ListContainersResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -585,14 +587,14 @@ func (in *instrumentedAlphaService) ContainerStatus(ctx context.Context, r *runt
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ContainerStatusRequest var v1r runtime.ContainerStatusRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ContainerStatusResponse var v1res *runtime.ContainerStatusResponse
v1res, err = in.c.ContainerStatus(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ContainerStatus(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ContainerStatusResponse{} resp := &runtime_alpha.ContainerStatusResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -638,14 +640,14 @@ func (in *instrumentedAlphaService) StopContainer(ctx context.Context, r *runtim
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.StopContainerRequest var v1r runtime.StopContainerRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.StopContainerResponse var v1res *runtime.StopContainerResponse
v1res, err = in.c.StopContainer(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.StopContainer(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.StopContainerResponse{} resp := &runtime_alpha.StopContainerResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -691,14 +693,14 @@ func (in *instrumentedAlphaService) RemoveContainer(ctx context.Context, r *runt
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.RemoveContainerRequest var v1r runtime.RemoveContainerRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.RemoveContainerResponse var v1res *runtime.RemoveContainerResponse
v1res, err = in.c.RemoveContainer(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.RemoveContainer(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.RemoveContainerResponse{} resp := &runtime_alpha.RemoveContainerResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -744,14 +746,14 @@ func (in *instrumentedAlphaService) ExecSync(ctx context.Context, r *runtime_alp
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ExecSyncRequest var v1r runtime.ExecSyncRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ExecSyncResponse var v1res *runtime.ExecSyncResponse
v1res, err = in.c.ExecSync(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ExecSync(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ExecSyncResponse{} resp := &runtime_alpha.ExecSyncResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -799,14 +801,14 @@ func (in *instrumentedAlphaService) Exec(ctx context.Context, r *runtime_alpha.E
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ExecRequest var v1r runtime.ExecRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ExecResponse var v1res *runtime.ExecResponse
v1res, err = in.c.Exec(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.Exec(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ExecResponse{} resp := &runtime_alpha.ExecResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -852,14 +854,14 @@ func (in *instrumentedAlphaService) Attach(ctx context.Context, r *runtime_alpha
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.AttachRequest var v1r runtime.AttachRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.AttachResponse var v1res *runtime.AttachResponse
v1res, err = in.c.Attach(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.Attach(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.AttachResponse{} resp := &runtime_alpha.AttachResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -905,14 +907,14 @@ func (in *instrumentedAlphaService) UpdateContainerResources(ctx context.Context
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.UpdateContainerResourcesRequest var v1r runtime.UpdateContainerResourcesRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.UpdateContainerResourcesResponse var v1res *runtime.UpdateContainerResourcesResponse
v1res, err = in.c.UpdateContainerResources(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.UpdateContainerResources(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.UpdateContainerResourcesResponse{} resp := &runtime_alpha.UpdateContainerResourcesResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -966,14 +968,14 @@ func (in *instrumentedAlphaService) PullImage(ctx context.Context, r *runtime_al
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.PullImageRequest var v1r runtime.PullImageRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.PullImageResponse var v1res *runtime.PullImageResponse
v1res, err = in.c.PullImage(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.PullImage(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.PullImageResponse{} resp := &runtime_alpha.PullImageResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1027,14 +1029,14 @@ func (in *instrumentedAlphaService) ListImages(ctx context.Context, r *runtime_a
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ListImagesRequest var v1r runtime.ListImagesRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ListImagesResponse var v1res *runtime.ListImagesResponse
v1res, err = in.c.ListImages(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ListImages(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ListImagesResponse{} resp := &runtime_alpha.ListImagesResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1088,14 +1090,14 @@ func (in *instrumentedAlphaService) ImageStatus(ctx context.Context, r *runtime_
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ImageStatusRequest var v1r runtime.ImageStatusRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ImageStatusResponse var v1res *runtime.ImageStatusResponse
v1res, err = in.c.ImageStatus(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ImageStatus(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ImageStatusResponse{} resp := &runtime_alpha.ImageStatusResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1147,14 +1149,14 @@ func (in *instrumentedAlphaService) RemoveImage(ctx context.Context, r *runtime_
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.RemoveImageRequest var v1r runtime.RemoveImageRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.RemoveImageResponse var v1res *runtime.RemoveImageResponse
v1res, err = in.c.RemoveImage(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.RemoveImage(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.RemoveImageResponse{} resp := &runtime_alpha.RemoveImageResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1206,14 +1208,14 @@ func (in *instrumentedAlphaService) ImageFsInfo(ctx context.Context, r *runtime_
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ImageFsInfoRequest var v1r runtime.ImageFsInfoRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ImageFsInfoResponse var v1res *runtime.ImageFsInfoResponse
v1res, err = in.c.ImageFsInfo(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ImageFsInfo(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ImageFsInfoResponse{} resp := &runtime_alpha.ImageFsInfoResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1259,14 +1261,14 @@ func (in *instrumentedAlphaService) PodSandboxStats(ctx context.Context, r *runt
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.PodSandboxStatsRequest var v1r runtime.PodSandboxStatsRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.PodSandboxStatsResponse var v1res *runtime.PodSandboxStatsResponse
v1res, err = in.c.PodSandboxStats(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.PodSandboxStats(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.PodSandboxStatsResponse{} resp := &runtime_alpha.PodSandboxStatsResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1312,14 +1314,14 @@ func (in *instrumentedAlphaService) ContainerStats(ctx context.Context, r *runti
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ContainerStatsRequest var v1r runtime.ContainerStatsRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ContainerStatsResponse var v1res *runtime.ContainerStatsResponse
v1res, err = in.c.ContainerStats(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ContainerStats(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ContainerStatsResponse{} resp := &runtime_alpha.ContainerStatsResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1365,14 +1367,14 @@ func (in *instrumentedAlphaService) ListPodSandboxStats(ctx context.Context, r *
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ListPodSandboxStatsRequest var v1r runtime.ListPodSandboxStatsRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ListPodSandboxStatsResponse var v1res *runtime.ListPodSandboxStatsResponse
v1res, err = in.c.ListPodSandboxStats(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ListPodSandboxStats(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ListPodSandboxStatsResponse{} resp := &runtime_alpha.ListPodSandboxStatsResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1418,14 +1420,14 @@ func (in *instrumentedAlphaService) ListContainerStats(ctx context.Context, r *r
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ListContainerStatsRequest var v1r runtime.ListContainerStatsRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ListContainerStatsResponse var v1res *runtime.ListContainerStatsResponse
v1res, err = in.c.ListContainerStats(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ListContainerStats(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ListContainerStatsResponse{} resp := &runtime_alpha.ListContainerStatsResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1471,14 +1473,14 @@ func (in *instrumentedAlphaService) Status(ctx context.Context, r *runtime_alpha
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.StatusRequest var v1r runtime.StatusRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.StatusResponse var v1res *runtime.StatusResponse
v1res, err = in.c.Status(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.Status(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.StatusResponse{} resp := &runtime_alpha.StatusResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1556,14 +1558,14 @@ func (in *instrumentedAlphaService) UpdateRuntimeConfig(ctx context.Context, r *
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.UpdateRuntimeConfigRequest var v1r runtime.UpdateRuntimeConfigRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.UpdateRuntimeConfigResponse var v1res *runtime.UpdateRuntimeConfigResponse
v1res, err = in.c.UpdateRuntimeConfig(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.UpdateRuntimeConfig(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.UpdateRuntimeConfigResponse{} resp := &runtime_alpha.UpdateRuntimeConfigResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1609,14 +1611,14 @@ func (in *instrumentedAlphaService) ReopenContainerLog(ctx context.Context, r *r
}() }()
// converts request and response for earlier CRI version to call and get response from the current version // converts request and response for earlier CRI version to call and get response from the current version
var v1r runtime.ReopenContainerLogRequest var v1r runtime.ReopenContainerLogRequest
if err := alphaReqToV1Req(r, &v1r); err != nil { if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil {
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
var v1res *runtime.ReopenContainerLogResponse var v1res *runtime.ReopenContainerLogResponse
v1res, err = in.c.ReopenContainerLog(ctrdutil.WithNamespace(ctx), &v1r) v1res, err = in.c.ReopenContainerLog(ctrdutil.WithNamespace(ctx), &v1r)
if v1res != nil { if v1res != nil {
resp := &runtime_alpha.ReopenContainerLogResponse{} resp := &runtime_alpha.ReopenContainerLogResponse{}
perr := v1RespToAlphaResp(v1res, resp) perr := ctrdutil.V1RespToAlphaResp(v1res, resp)
if perr == nil { if perr == nil {
res = resp res = resp
} else { } else {
@ -1700,33 +1702,3 @@ func (in *instrumentedService) ListPodSandboxMetrics(ctx context.Context, r *run
res, err = in.c.ListPodSandboxMetrics(ctx, r) res, err = in.c.ListPodSandboxMetrics(ctx, r)
return res, errdefs.ToGRPC(err) return res, errdefs.ToGRPC(err)
} }
func alphaReqToV1Req(
alphar interface{ Marshal() ([]byte, error) },
v1r interface{ Unmarshal(_ []byte) error },
) error {
p, err := alphar.Marshal()
if err != nil {
return err
}
if err = v1r.Unmarshal(p); err != nil {
return err
}
return nil
}
func v1RespToAlphaResp(
v1res interface{ Marshal() ([]byte, error) },
alphares interface{ Unmarshal(_ []byte) error },
) error {
p, err := v1res.Marshal()
if err != nil {
return err
}
if err = alphares.Unmarshal(p); err != nil {
return err
}
return nil
}

52
pkg/cri/util/alpha.go Normal file
View File

@ -0,0 +1,52 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package util
import (
"github.com/containerd/containerd/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
)
func AlphaReqToV1Req(
alphar protoreflect.ProtoMessage,
v1r interface{ Unmarshal(_ []byte) error },
) error {
p, err := proto.Marshal(alphar)
if err != nil {
return err
}
if err = v1r.Unmarshal(p); err != nil {
return err
}
return nil
}
func V1RespToAlphaResp(
v1res interface{ Marshal() ([]byte, error) },
alphares protoreflect.ProtoMessage,
) error {
p, err := v1res.Marshal()
if err != nil {
return err
}
if err = proto.Unmarshal(p, alphares); err != nil {
return err
}
return nil
}

File diff suppressed because it is too large Load Diff

View File

@ -18,17 +18,7 @@ limitations under the License.
syntax = "proto3"; syntax = "proto3";
package runtime.v1alpha2; package runtime.v1alpha2;
option go_package = "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"; option go_package = "github.com/containerd/containerd/third_party/k8s.io/cri-api/pkg/apis/runtime/v1alpha2";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.stringer_all) = true;
option (gogoproto.goproto_getters_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.goproto_unrecognized_all) = false;
// Runtime service defines the public APIs for remote container runtimes // Runtime service defines the public APIs for remote container runtimes
service RuntimeService { service RuntimeService {

File diff suppressed because it is too large Load Diff