github.com/getong/docker@v1.13.1/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  	// See the parsing of buildArgs in api/server/router/build/build_routes.go
   164  	// for an explaination of why BuildArgs needs to use *string instead of
   165  	// just a string
   166  	BuildArgs   map[string]*string
   167  	AuthConfigs map[string]AuthConfig
   168  	Context     io.Reader
   169  	Labels      map[string]string
   170  	// squash the resulting image's layers to the parent
   171  	// preserves the original image and creates a new one from the parent with all
   172  	// the changes applied to a single layer
   173  	Squash bool
   174  	// CacheFrom specifies images that are used for matching cache. Images
   175  	// specified here do not need to have a valid parent chain to match cache.
   176  	CacheFrom   []string
   177  	SecurityOpt []string
   178  }
   179  
   180  // ImageBuildResponse holds information
   181  // returned by a server after building
   182  // an image.
   183  type ImageBuildResponse struct {
   184  	Body   io.ReadCloser
   185  	OSType string
   186  }
   187  
   188  // ImageCreateOptions holds information to create images.
   189  type ImageCreateOptions struct {
   190  	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
   191  }
   192  
   193  // ImageImportSource holds source information for ImageImport
   194  type ImageImportSource struct {
   195  	Source     io.Reader // Source is the data to send to the server to create this image from (mutually exclusive with SourceName)
   196  	SourceName string    // SourceName is the name of the image to pull (mutually exclusive with Source)
   197  }
   198  
   199  // ImageImportOptions holds information to import images from the client host.
   200  type ImageImportOptions struct {
   201  	Tag     string   // Tag is the name to tag this image with. This attribute is deprecated.
   202  	Message string   // Message is the message to tag the image with
   203  	Changes []string // Changes are the raw changes to apply to this image
   204  }
   205  
   206  // ImageListOptions holds parameters to filter the list of images with.
   207  type ImageListOptions struct {
   208  	All     bool
   209  	Filters filters.Args
   210  }
   211  
   212  // ImageLoadResponse returns information to the client about a load process.
   213  type ImageLoadResponse struct {
   214  	// Body must be closed to avoid a resource leak
   215  	Body io.ReadCloser
   216  	JSON bool
   217  }
   218  
   219  // ImagePullOptions holds information to pull images.
   220  type ImagePullOptions struct {
   221  	All           bool
   222  	RegistryAuth  string // RegistryAuth is the base64 encoded credentials for the registry
   223  	PrivilegeFunc RequestPrivilegeFunc
   224  }
   225  
   226  // RequestPrivilegeFunc is a function interface that
   227  // clients can supply to retry operations after
   228  // getting an authorization error.
   229  // This function returns the registry authentication
   230  // header value in base 64 format, or an error
   231  // if the privilege request fails.
   232  type RequestPrivilegeFunc func() (string, error)
   233  
   234  //ImagePushOptions holds information to push images.
   235  type ImagePushOptions ImagePullOptions
   236  
   237  // ImageRemoveOptions holds parameters to remove images.
   238  type ImageRemoveOptions struct {
   239  	Force         bool
   240  	PruneChildren bool
   241  }
   242  
   243  // ImageSearchOptions holds parameters to search images with.
   244  type ImageSearchOptions struct {
   245  	RegistryAuth  string
   246  	PrivilegeFunc RequestPrivilegeFunc
   247  	Filters       filters.Args
   248  	Limit         int
   249  }
   250  
   251  // ResizeOptions holds parameters to resize a tty.
   252  // It can be used to resize container ttys and
   253  // exec process ttys too.
   254  type ResizeOptions struct {
   255  	Height uint
   256  	Width  uint
   257  }
   258  
   259  // VersionResponse holds version information for the client and the server
   260  type VersionResponse struct {
   261  	Client *Version
   262  	Server *Version
   263  }
   264  
   265  // ServerOK returns true when the client could connect to the docker server
   266  // and parse the information received. It returns false otherwise.
   267  func (v VersionResponse) ServerOK() bool {
   268  	return v.Server != nil
   269  }
   270  
   271  // NodeListOptions holds parameters to list nodes with.
   272  type NodeListOptions struct {
   273  	Filters filters.Args
   274  }
   275  
   276  // NodeRemoveOptions holds parameters to remove nodes with.
   277  type NodeRemoveOptions struct {
   278  	Force bool
   279  }
   280  
   281  // ServiceCreateOptions contains the options to use when creating a service.
   282  type ServiceCreateOptions struct {
   283  	// EncodedRegistryAuth is the encoded registry authorization credentials to
   284  	// use when updating the service.
   285  	//
   286  	// This field follows the format of the X-Registry-Auth header.
   287  	EncodedRegistryAuth string
   288  }
   289  
   290  // ServiceCreateResponse contains the information returned to a client
   291  // on the creation of a new service.
   292  type ServiceCreateResponse struct {
   293  	// ID is the ID of the created service.
   294  	ID string
   295  	// Warnings is a set of non-fatal warning messages to pass on to the user.
   296  	Warnings []string `json:",omitempty"`
   297  }
   298  
   299  // Values for RegistryAuthFrom in ServiceUpdateOptions
   300  const (
   301  	RegistryAuthFromSpec         = "spec"
   302  	RegistryAuthFromPreviousSpec = "previous-spec"
   303  )
   304  
   305  // ServiceUpdateOptions contains the options to be used for updating services.
   306  type ServiceUpdateOptions struct {
   307  	// EncodedRegistryAuth is the encoded registry authorization credentials to
   308  	// use when updating the service.
   309  	//
   310  	// This field follows the format of the X-Registry-Auth header.
   311  	EncodedRegistryAuth string
   312  
   313  	// TODO(stevvooe): Consider moving the version parameter of ServiceUpdate
   314  	// into this field. While it does open API users up to racy writes, most
   315  	// users may not need that level of consistency in practice.
   316  
   317  	// RegistryAuthFrom specifies where to find the registry authorization
   318  	// credentials if they are not given in EncodedRegistryAuth. Valid
   319  	// values are "spec" and "previous-spec".
   320  	RegistryAuthFrom string
   321  }
   322  
   323  // ServiceListOptions holds parameters to list  services with.
   324  type ServiceListOptions struct {
   325  	Filters filters.Args
   326  }
   327  
   328  // TaskListOptions holds parameters to list  tasks with.
   329  type TaskListOptions struct {
   330  	Filters filters.Args
   331  }
   332  
   333  // PluginRemoveOptions holds parameters to remove plugins.
   334  type PluginRemoveOptions struct {
   335  	Force bool
   336  }
   337  
   338  // PluginEnableOptions holds parameters to enable plugins.
   339  type PluginEnableOptions struct {
   340  	Timeout int
   341  }
   342  
   343  // PluginDisableOptions holds parameters to disable plugins.
   344  type PluginDisableOptions struct {
   345  	Force bool
   346  }
   347  
   348  // PluginInstallOptions holds parameters to install a plugin.
   349  type PluginInstallOptions struct {
   350  	Disabled              bool
   351  	AcceptAllPermissions  bool
   352  	RegistryAuth          string // RegistryAuth is the base64 encoded credentials for the registry
   353  	RemoteRef             string // RemoteRef is the plugin name on the registry
   354  	PrivilegeFunc         RequestPrivilegeFunc
   355  	AcceptPermissionsFunc func(PluginPrivileges) (bool, error)
   356  	Args                  []string
   357  }
   358  
   359  // SecretRequestOption is a type for requesting secrets
   360  type SecretRequestOption struct {
   361  	Source string
   362  	Target string
   363  	UID    string
   364  	GID    string
   365  	Mode   os.FileMode
   366  }
   367  
   368  // SwarmUnlockKeyResponse contains the response for Engine API:
   369  // GET /swarm/unlockkey
   370  type SwarmUnlockKeyResponse struct {
   371  	// UnlockKey is the unlock key in ASCII-armored format.
   372  	UnlockKey string
   373  }
   374  
   375  // PluginCreateOptions hold all options to plugin create.
   376  type PluginCreateOptions struct {
   377  	RepoName string
   378  }