github.com/nullne/docker@v1.13.0-rc1/api/types/client.go (about)

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