github.com/devdivbcp/moby@v17.12.0-ce-rc1.0.20200726071732-2d4bfdc789ad+incompatible/libcontainerd/remote/client_windows.go (about)

     1  package remote // import "github.com/docker/docker/libcontainerd/remote"
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  	"os"
     7  	"path/filepath"
     8  
     9  	"github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
    10  	"github.com/containerd/containerd"
    11  	"github.com/containerd/containerd/cio"
    12  	"github.com/containerd/containerd/containers"
    13  
    14  	libcontainerdtypes "github.com/docker/docker/libcontainerd/types"
    15  	specs "github.com/opencontainers/runtime-spec/specs-go"
    16  	"github.com/pkg/errors"
    17  )
    18  
    19  const runtimeName = "io.containerd.runhcs.v1"
    20  
    21  func summaryFromInterface(i interface{}) (*libcontainerdtypes.Summary, error) {
    22  	switch pd := i.(type) {
    23  	case *options.ProcessDetails:
    24  		return &libcontainerdtypes.Summary{
    25  			ImageName:                    pd.ImageName,
    26  			CreatedAt:                    pd.CreatedAt,
    27  			KernelTime_100Ns:             pd.KernelTime_100Ns,
    28  			MemoryCommitBytes:            pd.MemoryCommitBytes,
    29  			MemoryWorkingSetPrivateBytes: pd.MemoryWorkingSetPrivateBytes,
    30  			MemoryWorkingSetSharedBytes:  pd.MemoryWorkingSetSharedBytes,
    31  			ProcessID:                    pd.ProcessID,
    32  			UserTime_100Ns:               pd.UserTime_100Ns,
    33  			ExecID:                       pd.ExecID,
    34  		}, nil
    35  	default:
    36  		return nil, errors.Errorf("Unknown process details type %T", pd)
    37  	}
    38  }
    39  
    40  // WithBundle creates the bundle for the container
    41  func WithBundle(bundleDir string, ociSpec *specs.Spec) containerd.NewContainerOpts {
    42  	return func(ctx context.Context, client *containerd.Client, c *containers.Container) error {
    43  		// TODO: (containerd) Determine if we need to use system.MkdirAllWithACL here
    44  		if c.Labels == nil {
    45  			c.Labels = make(map[string]string)
    46  		}
    47  		c.Labels[DockerContainerBundlePath] = bundleDir
    48  		return os.MkdirAll(bundleDir, 0755)
    49  	}
    50  }
    51  
    52  func pipeName(containerID, processID, name string) string {
    53  	return fmt.Sprintf(`\\.\pipe\containerd-%s-%s-%s`, containerID, processID, name)
    54  }
    55  
    56  func newFIFOSet(bundleDir, processID string, withStdin, withTerminal bool) *cio.FIFOSet {
    57  	containerID := filepath.Base(bundleDir)
    58  	config := cio.Config{
    59  		Terminal: withTerminal,
    60  		Stdout:   pipeName(containerID, processID, "stdout"),
    61  	}
    62  
    63  	if withStdin {
    64  		config.Stdin = pipeName(containerID, processID, "stdin")
    65  	}
    66  
    67  	if !config.Terminal {
    68  		config.Stderr = pipeName(containerID, processID, "stderr")
    69  	}
    70  
    71  	return cio.NewFIFOSet(config, nil)
    72  }
    73  
    74  func (c *client) newDirectIO(ctx context.Context, fifos *cio.FIFOSet) (*cio.DirectIO, error) {
    75  	pipes, err := c.newStdioPipes(fifos)
    76  	if err != nil {
    77  		return nil, err
    78  	}
    79  	return cio.NewDirectIOFromFIFOSet(ctx, pipes.stdin, pipes.stdout, pipes.stderr, fifos), nil
    80  }
    81  
    82  func (c *client) UpdateResources(ctx context.Context, containerID string, resources *libcontainerdtypes.Resources) error {
    83  	// TODO: (containerd): Not implemented, but don't error.
    84  	return nil
    85  }
    86  
    87  func getSpecUser(ociSpec *specs.Spec) (int, int) {
    88  	// TODO: (containerd): Not implemented, but don't error.
    89  	// Not clear if we can even do this for LCOW.
    90  	return 0, 0
    91  }