github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/api/types/client.go (about)

     1  package types // import "github.com/demonoid81/moby/api/types"
     2  
     3  import (
     4  	"bufio"
     5  	"io"
     6  	"net"
     7  
     8  	"github.com/demonoid81/moby/api/types/container"
     9  	"github.com/demonoid81/moby/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 `json:"ID"`
    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  	// Version specifies the version of the unerlying builder to use
   185  	Version BuilderVersion
   186  	// BuildID is an optional identifier that can be passed together with the
   187  	// build request. The same identifier can be used to gracefully cancel the
   188  	// build with the cancel request.
   189  	BuildID string
   190  	// Outputs defines configurations for exporting build results. Only supported
   191  	// in BuildKit mode
   192  	Outputs []ImageBuildOutput
   193  }
   194  
   195  // ImageBuildOutput defines configuration for exporting a build result
   196  type ImageBuildOutput struct {
   197  	Type  string
   198  	Attrs map[string]string
   199  }
   200  
   201  // BuilderVersion sets the version of underlying builder to use
   202  type BuilderVersion string
   203  
   204  const (
   205  	// BuilderV1 is the first generation builder in docker daemon
   206  	BuilderV1 BuilderVersion = "1"
   207  	// BuilderBuildKit is builder based on moby/buildkit project
   208  	BuilderBuildKit BuilderVersion = "2"
   209  )
   210  
   211  // ImageBuildResponse holds information
   212  // returned by a server after building
   213  // an image.
   214  type ImageBuildResponse struct {
   215  	Body   io.ReadCloser
   216  	OSType string
   217  }
   218  
   219  // ImageCreateOptions holds information to create images.
   220  type ImageCreateOptions struct {
   221  	RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry.
   222  	Platform     string // Platform is the target platform of the image if it needs to be pulled from the registry.
   223  }
   224  
   225  // ImageImportSource holds source information for ImageImport
   226  type ImageImportSource struct {
   227  	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.
   228  	SourceName string    // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
   229  }
   230  
   231  // ImageImportOptions holds information to import images from the client host.
   232  type ImageImportOptions struct {
   233  	Tag      string   // Tag is the name to tag this image with. This attribute is deprecated.
   234  	Message  string   // Message is the message to tag the image with
   235  	Changes  []string // Changes are the raw changes to apply to this image
   236  	Platform string   // Platform is the target platform of the image
   237  }
   238  
   239  // ImageListOptions holds parameters to filter the list of images with.
   240  type ImageListOptions struct {
   241  	All     bool
   242  	Filters filters.Args
   243  }
   244  
   245  // ImageLoadResponse returns information to the client about a load process.
   246  type ImageLoadResponse struct {
   247  	// Body must be closed to avoid a resource leak
   248  	Body io.ReadCloser
   249  	JSON bool
   250  }
   251  
   252  // ImagePullOptions holds information to pull images.
   253  type ImagePullOptions struct {
   254  	All           bool
   255  	RegistryAuth  string // RegistryAuth is the base64 encoded credentials for the registry
   256  	PrivilegeFunc RequestPrivilegeFunc
   257  	Platform      string
   258  }
   259  
   260  // RequestPrivilegeFunc is a function interface that
   261  // clients can supply to retry operations after
   262  // getting an authorization error.
   263  // This function returns the registry authentication
   264  // header value in base 64 format, or an error
   265  // if the privilege request fails.
   266  type RequestPrivilegeFunc func() (string, error)
   267  
   268  // ImagePushOptions holds information to push images.
   269  type ImagePushOptions ImagePullOptions
   270  
   271  // ImageRemoveOptions holds parameters to remove images.
   272  type ImageRemoveOptions struct {
   273  	Force         bool
   274  	PruneChildren bool
   275  }
   276  
   277  // ImageSearchOptions holds parameters to search images with.
   278  type ImageSearchOptions struct {
   279  	RegistryAuth  string
   280  	PrivilegeFunc RequestPrivilegeFunc
   281  	Filters       filters.Args
   282  	Limit         int
   283  }
   284  
   285  // ResizeOptions holds parameters to resize a tty.
   286  // It can be used to resize container ttys and
   287  // exec process ttys too.
   288  type ResizeOptions struct {
   289  	Height uint
   290  	Width  uint
   291  }
   292  
   293  // NodeListOptions holds parameters to list nodes with.
   294  type NodeListOptions struct {
   295  	Filters filters.Args
   296  }
   297  
   298  // NodeRemoveOptions holds parameters to remove nodes with.
   299  type NodeRemoveOptions struct {
   300  	Force bool
   301  }
   302  
   303  // ServiceCreateOptions contains the options to use when creating a service.
   304  type ServiceCreateOptions struct {
   305  	// EncodedRegistryAuth is the encoded registry authorization credentials to
   306  	// use when updating the service.
   307  	//
   308  	// This field follows the format of the X-Registry-Auth header.
   309  	EncodedRegistryAuth string
   310  
   311  	// QueryRegistry indicates whether the service update requires
   312  	// contacting a registry. A registry may be contacted to retrieve
   313  	// the image digest and manifest, which in turn can be used to update
   314  	// platform or other information about the service.
   315  	QueryRegistry bool
   316  }
   317  
   318  // ServiceCreateResponse contains the information returned to a client
   319  // on the creation of a new service.
   320  type ServiceCreateResponse struct {
   321  	// ID is the ID of the created service.
   322  	ID string
   323  	// Warnings is a set of non-fatal warning messages to pass on to the user.
   324  	Warnings []string `json:",omitempty"`
   325  }
   326  
   327  // Values for RegistryAuthFrom in ServiceUpdateOptions
   328  const (
   329  	RegistryAuthFromSpec         = "spec"
   330  	RegistryAuthFromPreviousSpec = "previous-spec"
   331  )
   332  
   333  // ServiceUpdateOptions contains the options to be used for updating services.
   334  type ServiceUpdateOptions struct {
   335  	// EncodedRegistryAuth is the encoded registry authorization credentials to
   336  	// use when updating the service.
   337  	//
   338  	// This field follows the format of the X-Registry-Auth header.
   339  	EncodedRegistryAuth string
   340  
   341  	// TODO(stevvooe): Consider moving the version parameter of ServiceUpdate
   342  	// into this field. While it does open API users up to racy writes, most
   343  	// users may not need that level of consistency in practice.
   344  
   345  	// RegistryAuthFrom specifies where to find the registry authorization
   346  	// credentials if they are not given in EncodedRegistryAuth. Valid
   347  	// values are "spec" and "previous-spec".
   348  	RegistryAuthFrom string
   349  
   350  	// Rollback indicates whether a server-side rollback should be
   351  	// performed. When this is set, the provided spec will be ignored.
   352  	// The valid values are "previous" and "none". An empty value is the
   353  	// same as "none".
   354  	Rollback string
   355  
   356  	// QueryRegistry indicates whether the service update requires
   357  	// contacting a registry. A registry may be contacted to retrieve
   358  	// the image digest and manifest, which in turn can be used to update
   359  	// platform or other information about the service.
   360  	QueryRegistry bool
   361  }
   362  
   363  // ServiceListOptions holds parameters to list services with.
   364  type ServiceListOptions struct {
   365  	Filters filters.Args
   366  
   367  	// Status indicates whether the server should include the service task
   368  	// count of running and desired tasks.
   369  	Status bool
   370  }
   371  
   372  // ServiceInspectOptions holds parameters related to the "service inspect"
   373  // operation.
   374  type ServiceInspectOptions struct {
   375  	InsertDefaults bool
   376  }
   377  
   378  // TaskListOptions holds parameters to list tasks with.
   379  type TaskListOptions struct {
   380  	Filters filters.Args
   381  }
   382  
   383  // PluginRemoveOptions holds parameters to remove plugins.
   384  type PluginRemoveOptions struct {
   385  	Force bool
   386  }
   387  
   388  // PluginEnableOptions holds parameters to enable plugins.
   389  type PluginEnableOptions struct {
   390  	Timeout int
   391  }
   392  
   393  // PluginDisableOptions holds parameters to disable plugins.
   394  type PluginDisableOptions struct {
   395  	Force bool
   396  }
   397  
   398  // PluginInstallOptions holds parameters to install a plugin.
   399  type PluginInstallOptions struct {
   400  	Disabled              bool
   401  	AcceptAllPermissions  bool
   402  	RegistryAuth          string // RegistryAuth is the base64 encoded credentials for the registry
   403  	RemoteRef             string // RemoteRef is the plugin name on the registry
   404  	PrivilegeFunc         RequestPrivilegeFunc
   405  	AcceptPermissionsFunc func(PluginPrivileges) (bool, error)
   406  	Args                  []string
   407  }
   408  
   409  // SwarmUnlockKeyResponse contains the response for Engine API:
   410  // GET /swarm/unlockkey
   411  type SwarmUnlockKeyResponse struct {
   412  	// UnlockKey is the unlock key in ASCII-armored format.
   413  	UnlockKey string
   414  }
   415  
   416  // PluginCreateOptions hold all options to plugin create.
   417  type PluginCreateOptions struct {
   418  	RepoName string
   419  }