container: add exec command prototype
Signed-off-by: Jacek J. Łakis <jacek.lakis@intel.com>
This commit is contained in:
parent
3babbf0de1
commit
b75b6f6e4b
1 changed files with 28 additions and 1 deletions
|
@ -1,11 +1,38 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/Sirupsen/logrus"
|
||||||
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Exec prepares a streaming endpoint to execute a command in the container.
|
// Exec prepares a streaming endpoint to execute a command in the container.
|
||||||
func (s *Server) Exec(ctx context.Context, req *pb.ExecRequest) (*pb.ExecResponse, error) {
|
func (s *Server) Exec(ctx context.Context, req *pb.ExecRequest) (*pb.ExecResponse, error) {
|
||||||
return &pb.ExecResponse{}, nil
|
logrus.Debugf("ExecRequest %+v", req)
|
||||||
|
c, err := s.getContainerFromRequest(req.ContainerId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = s.runtime.UpdateStatus(c); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
cState := s.runtime.ContainerStatus(c)
|
||||||
|
if !(cState.Status == oci.ContainerStateRunning || cState.Status == oci.ContainerStateCreated) {
|
||||||
|
return nil, fmt.Errorf("container is not created or running")
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Cmd == nil {
|
||||||
|
return nil, fmt.Errorf("exec command cannot be empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "url"
|
||||||
|
|
||||||
|
return &pb.ExecResponse{
|
||||||
|
Url: url,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue