github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/libcontainerd/client_daemon_windows.go (about)

     1  package libcontainerd
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/containerd/containerd/cio"
     7  	"github.com/containerd/containerd/windows/hcsshimtypes"
     8  	specs "github.com/opencontainers/runtime-spec/specs-go"
     9  	"github.com/pkg/errors"
    10  )
    11  
    12  func summaryFromInterface(i interface{}) (*Summary, error) {
    13  	switch pd := i.(type) {
    14  	case *hcsshimtypes.ProcessDetails:
    15  		return &Summary{
    16  			CreateTimestamp:              pd.CreatedAt,
    17  			ImageName:                    pd.ImageName,
    18  			KernelTime100ns:              pd.KernelTime_100Ns,
    19  			MemoryCommitBytes:            pd.MemoryCommitBytes,
    20  			MemoryWorkingSetPrivateBytes: pd.MemoryWorkingSetPrivateBytes,
    21  			MemoryWorkingSetSharedBytes:  pd.MemoryWorkingSetSharedBytes,
    22  			ProcessId:                    pd.ProcessID,
    23  			UserTime100ns:                pd.UserTime_100Ns,
    24  		}, nil
    25  	default:
    26  		return nil, errors.Errorf("Unknown process details type %T", pd)
    27  	}
    28  }
    29  
    30  func prepareBundleDir(bundleDir string, ociSpec *specs.Spec) (string, error) {
    31  	return bundleDir, nil
    32  }
    33  
    34  func pipeName(containerID, processID, name string) string {
    35  	return fmt.Sprintf(`\\.\pipe\containerd-%s-%s-%s`, containerID, processID, name)
    36  }
    37  
    38  func newFIFOSet(bundleDir, containerID, processID string, withStdin, withTerminal bool) *cio.FIFOSet {
    39  	fifos := &cio.FIFOSet{
    40  		Terminal: withTerminal,
    41  		Out:      pipeName(containerID, processID, "stdout"),
    42  	}
    43  
    44  	if withStdin {
    45  		fifos.In = pipeName(containerID, processID, "stdin")
    46  	}
    47  
    48  	if !fifos.Terminal {
    49  		fifos.Err = pipeName(containerID, processID, "stderr")
    50  	}
    51  
    52  	return fifos
    53  }