Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions internal/oci/oci.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package oci

import (
"bytes"
"fmt"
"io"
"path/filepath"
Expand All @@ -11,6 +10,7 @@ import (
"time"

"github.com/cri-o/cri-o/pkg/config"
"github.com/cri-o/cri-o/server/cri/types"
rspec "github.com/opencontainers/runtime-spec/specs-go"
"golang.org/x/net/context"

Expand Down Expand Up @@ -54,7 +54,7 @@ type RuntimeImpl interface {
StartContainer(context.Context, *Container) error
ExecContainer(context.Context, *Container, []string, io.Reader, io.WriteCloser, io.WriteCloser,
bool, <-chan remotecommand.TerminalSize) error
ExecSyncContainer(context.Context, *Container, []string, int64) (*ExecSyncResponse, error)
ExecSyncContainer(context.Context, *Container, []string, int64) (*types.ExecSyncResponse, error)
UpdateContainer(context.Context, *Container, *rspec.LinuxResources) error
StopContainer(context.Context, *Container, int64) error
DeleteContainer(context.Context, *Container) error
Expand Down Expand Up @@ -287,7 +287,7 @@ func (r *Runtime) ExecContainer(ctx context.Context, c *Container, cmd []string,
}

// ExecSyncContainer execs a command in a container and returns it's stdout, stderr and return code.
func (r *Runtime) ExecSyncContainer(ctx context.Context, c *Container, command []string, timeout int64) (*ExecSyncResponse, error) {
func (r *Runtime) ExecSyncContainer(ctx context.Context, c *Container, command []string, timeout int64) (*types.ExecSyncResponse, error) {
impl, err := r.RuntimeImpl(c)
if err != nil {
return nil, err
Expand Down Expand Up @@ -418,25 +418,6 @@ func (r *Runtime) ReopenContainerLog(ctx context.Context, c *Container) error {
return impl.ReopenContainerLog(ctx, c)
}

// ExecSyncResponse is returned from ExecSync.
type ExecSyncResponse struct {
Stdout []byte
Stderr []byte
ExitCode int32
}

// ExecSyncError wraps command's streams, exit code and error on ExecSync error.
type ExecSyncError struct {
Stdout bytes.Buffer
Stderr bytes.Buffer
ExitCode int32
Err error
}

func (e *ExecSyncError) Error() string {
return fmt.Sprintf("command error: %+v, stdout: %s, stderr: %s, exit code %d", e.Err, e.Stdout.Bytes(), e.Stderr.Bytes(), e.ExitCode)
}

// BuildContainerdBinaryName() is responsible for ensuring the binary passed will
// be properly converted to the containerd binary naming pattern.
//
Expand Down
13 changes: 0 additions & 13 deletions internal/oci/oci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,6 @@ var _ = t.Describe("Oci", func() {
})
})

t.Describe("ExecSyncError", func() {
It("should succeed to get the exec sync error", func() {
// Given
sut := oci.ExecSyncError{}

// When
result := sut.Error()

// Then
Expect(result).To(ContainSubstring("error"))
})
})

t.Describe("BuildContainerdBinaryName", func() {
It("Simple binary name (containerd-shim-kata-v2)", func() {
binaryName := oci.BuildContainerdBinaryName("containerd-shim-kata-v2")
Expand Down
Loading