github.com/endophage/docker@v1.4.2-0.20161027011718-242853499895/api/types/client.go (about)

     1  package types
     2  
     3  import (
     4  	"bufio"
     5  	"io"
     6  	"net"
     7  
     8  	"github.com/docker/docker/api/types/container"
     9  	"github.com/docker/docker/api/types/filters"
    10  	"github.com/docker/go-units"
    11  )
    12  
    13  // CheckpointCreateOptions holds parameters to create a checkpoint from a container
    14  type CheckpointCreateOptions struct {
    15  	CheckpointID string
    16  	Exit         bool
    17  }
    18  
    19  // ContainerAttachOptions holds parameters to attach to a container.
    20  type ContainerAttachOptions struct {
    21  	Stream     bool
    22  	Stdin      bool
    23  	Stdout     bool
    24  	Stderr     bool
    25  	DetachKeys string
    26  }
    27  
    28  // ContainerCommitOptions holds parameters to commit changes into a container.
    29  type ContainerCommitOptions struct {
    30  	Reference string
    31  	Comment   string
    32  	Author    string
    33  	Changes   []string
    34  	Pause     bool
    35  	Config    *container.Config
    36  }
    37  
    38  // ContainerExecInspect holds information returned by exec inspect.
    39  type ContainerExecInspect struct {
    40  	ExecID      string
    41  	ContainerID string
    42  	Running     bool
    43  	ExitCode    int
    44  	Pid         int
    45  }
    46  
    47  // ContainerListOptions holds parameters to list containers with.
    48  type ContainerListOptions struct {
    49  	Quiet  bool
    50  	Size   bool
    51  	All    bool
    52  	Latest bool
    53  	Since  string
    54  	Before string
    55  	Limit  int
    56  	Filter filters.Args
    57  }
    58  
    59  // ContainerLogsOptions holds parameters to filter logs with.
    60  type ContainerLogsOptions struct {
    61  	ShowStdout bool
    62  	ShowStderr bool
    63  	Since      string
    64  	Timestamps bool
    65  	Follow     bool
    66  	Tail       string
    67  	Details    bool
    68  }
    69  
    70  // ContainerRemoveOptions holds parameters to remove containers.
    71  type ContainerRemoveOptions struct {
    72  	RemoveVolumes bool
    73  	RemoveLinks   bool
    74  	Force         bool
    75  }
    76  
    77  // ContainerStartOptions holds parameters to start containers.
    78  type ContainerStartOptions struct {
    79  	CheckpointID string
    80  }
    81  
    82  // CopyToContainerOptions holds information
    83  // about files to copy into a container
    84  type CopyToContainerOptions struct {
    85  	AllowOverwriteDirWithFile bool
    86  }
    87  
    88  // EventsOptions holds parameters to filter events with.
    89  type EventsOptions struct {
    90  	Since   string
    91  	Until   string
    92  	Filters filters.Args
    93  }
    94  
    95  // NetworkListOptions holds parameters to filter the list of networks with.
    96  type NetworkListOptions struct {
    97  	Filters filters.Args
    98  }
    99  
   100  // HijackedResponse holds connection information for a hijacked request.
   101  type HijackedResponse struct {
   102  	Conn   net.Conn
   103  	Reader *bufio.Reader
   104  }
   105  
   106  // Close closes the hijacked connection and reader.
   107  func (h *HijackedResponse) Close() {
   108  	h.Conn.Close()
   109  }
   110  
   111  // CloseWriter is an interface that implements structs
   112  // that close input streams to prevent from writing.
   113  type CloseWriter interface {
   114  	CloseWrite() error
   115  }
   116  
   117  // CloseWrite closes a readWriter for writing.
   118  func (h *HijackedResponse) CloseWrite() error {
   119  	if conn, ok := h.Conn.(CloseWriter); ok {
   120  		return conn.CloseWrite()
   121  	}
   122  	return nil
   123  }
   124  
   125  // ImageBuildOptions holds the information
   126  // necessary to build images.
   127  type ImageBuildOptions struct {
   128  	Tags           []string
   129  	SuppressOutput bool
   130  	RemoteContext  string
   131  	NoCache        bool
   132  	Remove         bool
   133  	ForceRemove    bool
   134  	PullParent     bool
   135  	Isolation      container.Isolation
   136  	CPUSetCPUs     string
   137  	CPUSetMems     string
   138  	CPUShares      int64
   139  	CPUQuota       int64
   140  	CPUPeriod      int64
   141  	Memory         int64
   142  	MemorySwap     int64
   143  	CgroupParent   string
   144  	NetworkMode    string
   145  	ShmSize        int64
   146  	Dockerfile     string
   147  	Ulimits        []*units.Ulimit
   148  	BuildArgs      map[string]string
   149  	AuthConfigs    map[string]AuthConfig
   150  	Context        io.Reader
   151  	Labels         map[string]string
   152  	// squash the resulting image's layers to the parent
   153  	// preserves the original image and creates a new one from the parent with all
   154  	// the changes applied to a single layer
   155  	Squash bool
   156  	// CacheFrom specifies images that are used for matching cache. Images
   157  	// specified here do not need to have a valid parent chain to match cache.
   158  	CacheFrom   []string
   159  	SecurityOpt []string
   160  }
   161  
   162  // ImageBuildResponse holds information
   163  // returned by a server after building
   164  // an image.
   165  type ImageBuildResponse struct {
   166  	Body   io.ReadCloser
   167  	OSType string
   168  }
   169  
   170  // ImageCreateOptions holds information to create images.
   171  type ImageCreateOptions struct {
   172  	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
   173  }
   174  
   175  // ImageImportSource holds source information for ImageImport
   176  type ImageImportSource struct {
   177  	Source     io.Reader // Source is the data to send to the server to create this image from (mutually exclusive with SourceName)
   178  	SourceName string    // SourceName is the name of the image to pull (mutually exclusive with Source)
   179  }
   180  
   181  // ImageImportOptions holds information to import images from the client host.
   182  type ImageImportOptions struct {
   183  	Tag     string   // Tag is the name to tag this image with. This attribute is deprecated.
   184  	Message string   // Message is the message to tag the image with
   185  	Changes []string // Changes are the raw changes to apply to this image
   186  }
   187  
   188  // ImageListOptions holds parameters to filter the list of images with.
   189  type ImageListOptions struct {
   190  	MatchName string
   191  	All       bool
   192  	Filters   filters.Args
   193  }
   194  
   195  // ImageLoadResponse returns information to the client about a load process.
   196  type ImageLoadResponse struct {
   197  	// Body must be closed to avoid a resource leak
   198  	Body io.ReadCloser
   199  	JSON bool
   200  }
   201  
   202  // ImagePullOptions holds information to pull images.
   203  type ImagePullOptions struct {
   204  	All           bool
   205  	RegistryAuth  string // RegistryAuth is the base64 encoded credentials for the registry
   206  	PrivilegeFunc RequestPrivilegeFunc
   207  }
   208  
   209  // RequestPrivilegeFunc is a function interface that
   210  // clients can supply to retry operations after
   211  // getting an authorization error.
   212  // This function returns the registry authentication
   213  // header value in base 64 format, or an error
   214  // if the privilege request fails.
   215  type RequestPrivilegeFunc func() (string, error)
   216  
   217  //ImagePushOptions holds information to push images.
   218  type ImagePushOptions ImagePullOptions
   219  
   220  // ImageRemoveOptions holds parameters to remove images.
   221  type ImageRemoveOptions struct {
   222  	Force         bool
   223  	PruneChildren bool
   224  }
   225  
   226  // ImageSearchOptions holds parameters to search images with.
   227  type ImageSearchOptions struct {
   228  	RegistryAuth  string
   229  	PrivilegeFunc RequestPrivilegeFunc
   230  	Filters       filters.Args
   231  	Limit         int
   232  }
   233  
   234  // ResizeOptions holds parameters to resize a tty.
   235  // It can be used to resize container ttys and
   236  // exec process ttys too.
   237  type ResizeOptions struct {
   238  	Height uint
   239  	Width  uint
   240  }
   241  
   242  // VersionResponse holds version information for the client and the server
   243  type VersionResponse struct {
   244  	Client *Version
   245  	Server *Version
   246  }
   247  
   248  // ServerOK returns true when the client could connect to the docker server
   249  // and parse the information received. It returns false otherwise.
   250  func (v VersionResponse) ServerOK() bool {
   251  	return v.Server != nil
   252  }
   253  
   254  // NodeListOptions holds parameters to list nodes with.
   255  type NodeListOptions struct {
   256  	Filter filters.Args
   257  }
   258  
   259  // NodeRemoveOptions holds parameters to remove nodes with.
   260  type NodeRemoveOptions struct {
   261  	Force bool
   262  }
   263  
   264  // ServiceCreateOptions contains the options to use when creating a service.
   265  type ServiceCreateOptions struct {
   266  	// EncodedRegistryAuth is the encoded registry authorization credentials to
   267  	// use when updating the service.
   268  	//
   269  	// This field follows the format of the X-Registry-Auth header.
   270  	EncodedRegistryAuth string
   271  }
   272  
   273  // ServiceCreateResponse contains the information returned to a client
   274  // on the  creation of a new service.
   275  type ServiceCreateResponse struct {
   276  	// ID is the ID of the created service.
   277  	ID string
   278  }
   279  
   280  // Values for RegistryAuthFrom in ServiceUpdateOptions
   281  const (
   282  	RegistryAuthFromSpec         = "spec"
   283  	RegistryAuthFromPreviousSpec = "previous-spec"
   284  )
   285  
   286  // ServiceUpdateOptions contains the options to be used for updating services.
   287  type ServiceUpdateOptions struct {
   288  	// EncodedRegistryAuth is the encoded registry authorization credentials to
   289  	// use when updating the service.
   290  	//
   291  	// This field follows the format of the X-Registry-Auth header.
   292  	EncodedRegistryAuth string
   293  
   294  	// TODO(stevvooe): Consider moving the version parameter of ServiceUpdate
   295  	// into this field. While it does open API users up to racy writes, most
   296  	// users may not need that level of consistency in practice.
   297  
   298  	// RegistryAuthFrom specifies where to find the registry authorization
   299  	// credentials if they are not given in EncodedRegistryAuth. Valid
   300  	// values are "spec" and "previous-spec".
   301  	RegistryAuthFrom string
   302  }
   303  
   304  // ServiceListOptions holds parameters to list  services with.
   305  type ServiceListOptions struct {
   306  	Filter filters.Args
   307  }
   308  
   309  // TaskListOptions holds parameters to list  tasks with.
   310  type TaskListOptions struct {
   311  	Filter filters.Args
   312  }
   313  
   314  // PluginRemoveOptions holds parameters to remove plugins.
   315  type PluginRemoveOptions struct {
   316  	Force bool
   317  }
   318  
   319  // PluginInstallOptions holds parameters to install a plugin.
   320  type PluginInstallOptions struct {
   321  	Disabled              bool
   322  	AcceptAllPermissions  bool
   323  	RegistryAuth          string // RegistryAuth is the base64 encoded credentials for the registry
   324  	PrivilegeFunc         RequestPrivilegeFunc
   325  	AcceptPermissionsFunc func(PluginPrivileges) (bool, error)
   326  }