github.com/lazyboychen7/engine@v17.12.1-ce-rc2+incompatible/api/types/backend/backend.go (about)

     1  // Package backend includes types to send information to server backends.
     2  package backend
     3  
     4  import (
     5  	"io"
     6  	"time"
     7  
     8  	"github.com/docker/docker/api/types"
     9  	"github.com/docker/docker/api/types/container"
    10  )
    11  
    12  // ContainerAttachConfig holds the streams to use when connecting to a container to view logs.
    13  type ContainerAttachConfig struct {
    14  	GetStreams func() (io.ReadCloser, io.Writer, io.Writer, error)
    15  	UseStdin   bool
    16  	UseStdout  bool
    17  	UseStderr  bool
    18  	Logs       bool
    19  	Stream     bool
    20  	DetachKeys string
    21  
    22  	// Used to signify that streams are multiplexed and therefore need a StdWriter to encode stdout/stderr messages accordingly.
    23  	// TODO @cpuguy83: This shouldn't be needed. It was only added so that http and websocket endpoints can use the same function, and the websocket function was not using a stdwriter prior to this change...
    24  	// HOWEVER, the websocket endpoint is using a single stream and SHOULD be encoded with stdout/stderr as is done for HTTP since it is still just a single stream.
    25  	// Since such a change is an API change unrelated to the current changeset we'll keep it as is here and change separately.
    26  	MuxStreams bool
    27  }
    28  
    29  // LogMessage is datastructure that represents piece of output produced by some
    30  // container.  The Line member is a slice of an array whose contents can be
    31  // changed after a log driver's Log() method returns.
    32  // changes to this struct need to be reflect in the reset method in
    33  // daemon/logger/logger.go
    34  type LogMessage struct {
    35  	Line      []byte
    36  	Source    string
    37  	Timestamp time.Time
    38  	Attrs     []LogAttr
    39  	Partial   bool
    40  
    41  	// Err is an error associated with a message. Completeness of a message
    42  	// with Err is not expected, tho it may be partially complete (fields may
    43  	// be missing, gibberish, or nil)
    44  	Err error
    45  }
    46  
    47  // LogAttr is used to hold the extra attributes available in the log message.
    48  type LogAttr struct {
    49  	Key   string
    50  	Value string
    51  }
    52  
    53  // LogSelector is a list of services and tasks that should be returned as part
    54  // of a log stream. It is similar to swarmapi.LogSelector, with the difference
    55  // that the names don't have to be resolved to IDs; this is mostly to avoid
    56  // accidents later where a swarmapi LogSelector might have been incorrectly
    57  // used verbatim (and to avoid the handler having to import swarmapi types)
    58  type LogSelector struct {
    59  	Services []string
    60  	Tasks    []string
    61  }
    62  
    63  // ContainerStatsConfig holds information for configuring the runtime
    64  // behavior of a backend.ContainerStats() call.
    65  type ContainerStatsConfig struct {
    66  	Stream    bool
    67  	OutStream io.Writer
    68  	Version   string
    69  }
    70  
    71  // ExecInspect holds information about a running process started
    72  // with docker exec.
    73  type ExecInspect struct {
    74  	ID            string
    75  	Running       bool
    76  	ExitCode      *int
    77  	ProcessConfig *ExecProcessConfig
    78  	OpenStdin     bool
    79  	OpenStderr    bool
    80  	OpenStdout    bool
    81  	CanRemove     bool
    82  	ContainerID   string
    83  	DetachKeys    []byte
    84  	Pid           int
    85  }
    86  
    87  // ExecProcessConfig holds information about the exec process
    88  // running on the host.
    89  type ExecProcessConfig struct {
    90  	Tty        bool     `json:"tty"`
    91  	Entrypoint string   `json:"entrypoint"`
    92  	Arguments  []string `json:"arguments"`
    93  	Privileged *bool    `json:"privileged,omitempty"`
    94  	User       string   `json:"user,omitempty"`
    95  }
    96  
    97  // ContainerCommitConfig is a wrapper around
    98  // types.ContainerCommitConfig that also
    99  // transports configuration changes for a container.
   100  type ContainerCommitConfig struct {
   101  	types.ContainerCommitConfig
   102  	Changes []string
   103  	// TODO: ContainerConfig is only used by the dockerfile Builder, so remove it
   104  	// once the Builder has been updated to use a different interface
   105  	ContainerConfig *container.Config
   106  }