github.com/sams1990/dockerrepo@v17.12.1-ce-rc2+incompatible/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  	units "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  	CheckpointDir string
    17  	Exit          bool
    18  }
    19  
    20  // CheckpointListOptions holds parameters to list checkpoints for a container
    21  type CheckpointListOptions struct {
    22  	CheckpointDir string
    23  }
    24  
    25  // CheckpointDeleteOptions holds parameters to delete a checkpoint from a container
    26  type CheckpointDeleteOptions struct {
    27  	CheckpointID  string
    28  	CheckpointDir string
    29  }
    30  
    31  // ContainerAttachOptions holds parameters to attach to a container.
    32  type ContainerAttachOptions struct {
    33  	Stream     bool
    34  	Stdin      bool
    35  	Stdout     bool
    36  	Stderr     bool
    37  	DetachKeys string
    38  	Logs       bool
    39  }
    40  
    41  // ContainerCommitOptions holds parameters to commit changes into a container.
    42  type ContainerCommitOptions struct {
    43  	Reference string
    44  	Comment   string
    45  	Author    string
    46  	Changes   []string
    47  	Pause     bool
    48  	Config    *container.Config
    49  }
    50  
    51  // ContainerExecInspect holds information returned by exec inspect.
    52  type ContainerExecInspect struct {
    53  	ExecID      string
    54  	ContainerID string
    55  	Running     bool
    56  	ExitCode    int
    57  	Pid         int
    58  }
    59  
    60  // ContainerListOptions holds parameters to list containers with.
    61  type ContainerListOptions struct {
    62  	Quiet   bool
    63  	Size    bool
    64  	All     bool
    65  	Latest  bool
    66  	Since   string
    67  	Before  string
    68  	Limit   int
    69  	Filters filters.Args
    70  }
    71  
    72  // ContainerLogsOptions holds parameters to filter logs with.
    73  type ContainerLogsOptions struct {
    74  	ShowStdout bool
    75  	ShowStderr bool
    76  	Since      string
    77  	Until      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  	CopyUIDGID                bool
   102  }
   103  
   104  // EventsOptions holds parameters to filter events with.
   105  type EventsOptions struct {
   106  	Since   string
   107  	Until   string
   108  	Filters filters.Args
   109  }
   110  
   111  // NetworkListOptions holds parameters to filter the list of networks with.
   112  type NetworkListOptions struct {
   113  	Filters filters.Args
   114  }
   115  
   116  // HijackedResponse holds connection information for a hijacked request.
   117  type HijackedResponse struct {
   118  	Conn   net.Conn
   119  	Reader *bufio.Reader
   120  }
   121  
   122  // Close closes the hijacked connection and reader.
   123  func (h *HijackedResponse) Close() {
   124  	h.Conn.Close()
   125  }
   126  
   127  // CloseWriter is an interface that implements structs
   128  // that close input streams to prevent from writing.
   129  type CloseWriter interface {
   130  	CloseWrite() error
   131  }
   132  
   133  // CloseWrite closes a readWriter for writing.
   134  func (h *HijackedResponse) CloseWrite() error {
   135  	if conn, ok := h.Conn.(CloseWriter); ok {
   136  		return conn.CloseWrite()
   137  	}
   138  	return nil
   139  }
   140  
   141  // ImageBuildOptions holds the information
   142  // necessary to build images.
   143  type ImageBuildOptions struct {
   144  	Tags           []string
   145  	SuppressOutput bool
   146  	RemoteContext  string
   147  	NoCache        bool
   148  	Remove         bool
   149  	ForceRemove    bool
   150  	PullParent     bool
   151  	Isolation      container.Isolation
   152  	CPUSetCPUs     string
   153  	CPUSetMems     string
   154  	CPUShares      int64
   155  	CPUQuota       int64
   156  	CPUPeriod      int64
   157  	Memory         int64
   158  	MemorySwap     int64
   159  	CgroupParent   string
   160  	NetworkMode    string
   161  	ShmSize        int64
   162  	Dockerfile     string
   163  	Ulimits        []*units.Ulimit
   164  	// BuildArgs needs to be a *string instead of just a string so that
   165  	// we can tell the difference between "" (empty string) and no value
   166  	// at all (nil). See the parsing of buildArgs in
   167  	// api/server/router/build/build_routes.go for even more info.
   168  	BuildArgs   map[string]*string
   169  	AuthConfigs map[string]AuthConfig
   170  	Context     io.Reader
   171  	Labels      map[string]string
   172  	// squash the resulting image's layers to the parent
   173  	// preserves the original image and creates a new one from the parent with all
   174  	// the changes applied to a single layer
   175  	Squash bool
   176  	// CacheFrom specifies images that are used for matching cache. Images
   177  	// specified here do not need to have a valid parent chain to match cache.
   178  	CacheFrom   []string
   179  	SecurityOpt []string
   180  	ExtraHosts  []string // List of extra hosts
   181  	Target      string
   182  	SessionID   string
   183  	Platform    string
   184  }
   185  
   186  // ImageBuildResponse holds information
   187  // returned by a server after building
   188  // an image.
   189  type ImageBuildResponse struct {
   190  	Body   io.ReadCloser
   191  	OSType string
   192  }
   193  
   194  // ImageCreateOptions holds information to create images.
   195  type ImageCreateOptions struct {
   196  	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry.
   197  	Platform     string // Platform is the target platform of the image if it needs to be pulled from the registry.
   198  }
   199  
   200  // ImageImportSource holds source information for ImageImport
   201  type ImageImportSource struct {
   202  	Source     io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this.
   203  	SourceName string    // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
   204  }
   205  
   206  // ImageImportOptions holds information to import images from the client host.
   207  type ImageImportOptions struct {
   208  	Tag      string   // Tag is the name to tag this image with. This attribute is deprecated.
   209  	Message  string   // Message is the message to tag the image with
   210  	Changes  []string // Changes are the raw changes to apply to this image
   211  	Platform string   // Platform is the target platform of the image
   212  }
   213  
   214  // ImageListOptions holds parameters to filter the list of images with.
   215  type ImageListOptions struct {
   216  	All     bool
   217  	Filters filters.Args
   218  }
   219  
   220  // ImageLoadResponse returns information to the client about a load process.
   221  type ImageLoadResponse struct {
   222  	// Body must be closed to avoid a resource leak
   223  	Body io.ReadCloser
   224  	JSON bool
   225  }
   226  
   227  // ImagePullOptions holds information to pull images.
   228  type ImagePullOptions struct {
   229  	All           bool
   230  	RegistryAuth  string // RegistryAuth is the base64 encoded credentials for the registry
   231  	PrivilegeFunc RequestPrivilegeFunc
   232  	Platform      string
   233  }
   234  
   235  // RequestPrivilegeFunc is a function interface that
   236  // clients can supply to retry operations after
   237  // getting an authorization error.
   238  // This function returns the registry authentication
   239  // header value in base 64 format, or an error
   240  // if the privilege request fails.
   241  type RequestPrivilegeFunc func() (string, error)
   242  
   243  //ImagePushOptions holds information to push images.
   244  type ImagePushOptions ImagePullOptions
   245  
   246  // ImageRemoveOptions holds parameters to remove images.
   247  type ImageRemoveOptions struct {
   248  	Force         bool
   249  	PruneChildren bool
   250  }
   251  
   252  // ImageSearchOptions holds parameters to search images with.
   253  type ImageSearchOptions struct {
   254  	RegistryAuth  string
   255  	PrivilegeFunc RequestPrivilegeFunc
   256  	Filters       filters.Args
   257  	Limit         int
   258  }
   259  
   260  // ResizeOptions holds parameters to resize a tty.
   261  // It can be used to resize container ttys and
   262  // exec process ttys too.
   263  type ResizeOptions struct {
   264  	Height uint
   265  	Width  uint
   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  	// QueryRegistry indicates whether the service update requires
   287  	// contacting a registry. A registry may be contacted to retrieve
   288  	// the image digest and manifest, which in turn can be used to update
   289  	// platform or other information about the service.
   290  	QueryRegistry bool
   291  }
   292  
   293  // ServiceCreateResponse contains the information returned to a client
   294  // on the creation of a new service.
   295  type ServiceCreateResponse struct {
   296  	// ID is the ID of the created service.
   297  	ID string
   298  	// Warnings is a set of non-fatal warning messages to pass on to the user.
   299  	Warnings []string `json:",omitempty"`
   300  }
   301  
   302  // Values for RegistryAuthFrom in ServiceUpdateOptions
   303  const (
   304  	RegistryAuthFromSpec         = "spec"
   305  	RegistryAuthFromPreviousSpec = "previous-spec"
   306  )
   307  
   308  // ServiceUpdateOptions contains the options to be used for updating services.
   309  type ServiceUpdateOptions struct {
   310  	// EncodedRegistryAuth is the encoded registry authorization credentials to
   311  	// use when updating the service.
   312  	//
   313  	// This field follows the format of the X-Registry-Auth header.
   314  	EncodedRegistryAuth string
   315  
   316  	// TODO(stevvooe): Consider moving the version parameter of ServiceUpdate
   317  	// into this field. While it does open API users up to racy writes, most
   318  	// users may not need that level of consistency in practice.
   319  
   320  	// RegistryAuthFrom specifies where to find the registry authorization
   321  	// credentials if they are not given in EncodedRegistryAuth. Valid
   322  	// values are "spec" and "previous-spec".
   323  	RegistryAuthFrom string
   324  
   325  	// Rollback indicates whether a server-side rollback should be
   326  	// performed. When this is set, the provided spec will be ignored.
   327  	// The valid values are "previous" and "none". An empty value is the
   328  	// same as "none".
   329  	Rollback string
   330  
   331  	// QueryRegistry indicates whether the service update requires
   332  	// contacting a registry. A registry may be contacted to retrieve
   333  	// the image digest and manifest, which in turn can be used to update
   334  	// platform or other information about the service.
   335  	QueryRegistry bool
   336  }
   337  
   338  // ServiceListOptions holds parameters to list services with.
   339  type ServiceListOptions struct {
   340  	Filters filters.Args
   341  }
   342  
   343  // ServiceInspectOptions holds parameters related to the "service inspect"
   344  // operation.
   345  type ServiceInspectOptions struct {
   346  	InsertDefaults bool
   347  }
   348  
   349  // TaskListOptions holds parameters to list tasks with.
   350  type TaskListOptions struct {
   351  	Filters filters.Args
   352  }
   353  
   354  // PluginRemoveOptions holds parameters to remove plugins.
   355  type PluginRemoveOptions struct {
   356  	Force bool
   357  }
   358  
   359  // PluginEnableOptions holds parameters to enable plugins.
   360  type PluginEnableOptions struct {
   361  	Timeout int
   362  }
   363  
   364  // PluginDisableOptions holds parameters to disable plugins.
   365  type PluginDisableOptions struct {
   366  	Force bool
   367  }
   368  
   369  // PluginInstallOptions holds parameters to install a plugin.
   370  type PluginInstallOptions struct {
   371  	Disabled              bool
   372  	AcceptAllPermissions  bool
   373  	RegistryAuth          string // RegistryAuth is the base64 encoded credentials for the registry
   374  	RemoteRef             string // RemoteRef is the plugin name on the registry
   375  	PrivilegeFunc         RequestPrivilegeFunc
   376  	AcceptPermissionsFunc func(PluginPrivileges) (bool, error)
   377  	Args                  []string
   378  }
   379  
   380  // SwarmUnlockKeyResponse contains the response for Engine API:
   381  // GET /swarm/unlockkey
   382  type SwarmUnlockKeyResponse struct {
   383  	// UnlockKey is the unlock key in ASCII-armored format.
   384  	UnlockKey string
   385  }
   386  
   387  // PluginCreateOptions hold all options to plugin create.
   388  type PluginCreateOptions struct {
   389  	RepoName string
   390  }