github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/api/types/client.go (about) 1 package types // import "github.com/Prakhar-Agarwal-byte/moby/api/types" 2 3 import ( 4 "bufio" 5 "io" 6 "net" 7 8 "github.com/Prakhar-Agarwal-byte/moby/api/types/container" 9 "github.com/Prakhar-Agarwal-byte/moby/api/types/filters" 10 "github.com/Prakhar-Agarwal-byte/moby/api/types/registry" 11 units "github.com/docker/go-units" 12 ) 13 14 // ContainerExecInspect holds information returned by exec inspect. 15 type ContainerExecInspect struct { 16 ExecID string `json:"ID"` 17 ContainerID string 18 Running bool 19 ExitCode int 20 Pid int 21 } 22 23 // CopyToContainerOptions holds information 24 // about files to copy into a container 25 type CopyToContainerOptions struct { 26 AllowOverwriteDirWithFile bool 27 CopyUIDGID bool 28 } 29 30 // EventsOptions holds parameters to filter events with. 31 type EventsOptions struct { 32 Since string 33 Until string 34 Filters filters.Args 35 } 36 37 // NetworkListOptions holds parameters to filter the list of networks with. 38 type NetworkListOptions struct { 39 Filters filters.Args 40 } 41 42 // NewHijackedResponse intializes a HijackedResponse type 43 func NewHijackedResponse(conn net.Conn, mediaType string) HijackedResponse { 44 return HijackedResponse{Conn: conn, Reader: bufio.NewReader(conn), mediaType: mediaType} 45 } 46 47 // HijackedResponse holds connection information for a hijacked request. 48 type HijackedResponse struct { 49 mediaType string 50 Conn net.Conn 51 Reader *bufio.Reader 52 } 53 54 // Close closes the hijacked connection and reader. 55 func (h *HijackedResponse) Close() { 56 h.Conn.Close() 57 } 58 59 // MediaType let client know if HijackedResponse hold a raw or multiplexed stream. 60 // returns false if HTTP Content-Type is not relevant, and container must be inspected 61 func (h *HijackedResponse) MediaType() (string, bool) { 62 if h.mediaType == "" { 63 return "", false 64 } 65 return h.mediaType, true 66 } 67 68 // CloseWriter is an interface that implements structs 69 // that close input streams to prevent from writing. 70 type CloseWriter interface { 71 CloseWrite() error 72 } 73 74 // CloseWrite closes a readWriter for writing. 75 func (h *HijackedResponse) CloseWrite() error { 76 if conn, ok := h.Conn.(CloseWriter); ok { 77 return conn.CloseWrite() 78 } 79 return nil 80 } 81 82 // ImageBuildOptions holds the information 83 // necessary to build images. 84 type ImageBuildOptions struct { 85 Tags []string 86 SuppressOutput bool 87 RemoteContext string 88 NoCache bool 89 Remove bool 90 ForceRemove bool 91 PullParent bool 92 Isolation container.Isolation 93 CPUSetCPUs string 94 CPUSetMems string 95 CPUShares int64 96 CPUQuota int64 97 CPUPeriod int64 98 Memory int64 99 MemorySwap int64 100 CgroupParent string 101 NetworkMode string 102 ShmSize int64 103 Dockerfile string 104 Ulimits []*units.Ulimit 105 // BuildArgs needs to be a *string instead of just a string so that 106 // we can tell the difference between "" (empty string) and no value 107 // at all (nil). See the parsing of buildArgs in 108 // api/server/router/build/build_routes.go for even more info. 109 BuildArgs map[string]*string 110 AuthConfigs map[string]registry.AuthConfig 111 Context io.Reader 112 Labels map[string]string 113 // squash the resulting image's layers to the parent 114 // preserves the original image and creates a new one from the parent with all 115 // the changes applied to a single layer 116 Squash bool 117 // CacheFrom specifies images that are used for matching cache. Images 118 // specified here do not need to have a valid parent chain to match cache. 119 CacheFrom []string 120 SecurityOpt []string 121 ExtraHosts []string // List of extra hosts 122 Target string 123 SessionID string 124 Platform string 125 // Version specifies the version of the unerlying builder to use 126 Version BuilderVersion 127 // BuildID is an optional identifier that can be passed together with the 128 // build request. The same identifier can be used to gracefully cancel the 129 // build with the cancel request. 130 BuildID string 131 // Outputs defines configurations for exporting build results. Only supported 132 // in BuildKit mode 133 Outputs []ImageBuildOutput 134 } 135 136 // ImageBuildOutput defines configuration for exporting a build result 137 type ImageBuildOutput struct { 138 Type string 139 Attrs map[string]string 140 } 141 142 // BuilderVersion sets the version of underlying builder to use 143 type BuilderVersion string 144 145 const ( 146 // BuilderV1 is the first generation builder in docker daemon 147 BuilderV1 BuilderVersion = "1" 148 // BuilderBuildKit is builder based on moby/buildkit project 149 BuilderBuildKit BuilderVersion = "2" 150 ) 151 152 // ImageBuildResponse holds information 153 // returned by a server after building 154 // an image. 155 type ImageBuildResponse struct { 156 Body io.ReadCloser 157 OSType string 158 } 159 160 // ImageCreateOptions holds information to create images. 161 type ImageCreateOptions struct { 162 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry. 163 Platform string // Platform is the target platform of the image if it needs to be pulled from the registry. 164 } 165 166 // ImageImportSource holds source information for ImageImport 167 type ImageImportSource struct { 168 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. 169 SourceName string // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute. 170 } 171 172 // ImageImportOptions holds information to import images from the client host. 173 type ImageImportOptions struct { 174 Tag string // Tag is the name to tag this image with. This attribute is deprecated. 175 Message string // Message is the message to tag the image with 176 Changes []string // Changes are the raw changes to apply to this image 177 Platform string // Platform is the target platform of the image 178 } 179 180 // ImageListOptions holds parameters to list images with. 181 type ImageListOptions struct { 182 // All controls whether all images in the graph are filtered, or just 183 // the heads. 184 All bool 185 186 // Filters is a JSON-encoded set of filter arguments. 187 Filters filters.Args 188 189 // SharedSize indicates whether the shared size of images should be computed. 190 SharedSize bool 191 192 // ContainerCount indicates whether container count should be computed. 193 ContainerCount bool 194 } 195 196 // ImageLoadResponse returns information to the client about a load process. 197 type ImageLoadResponse struct { 198 // Body must be closed to avoid a resource leak 199 Body io.ReadCloser 200 JSON bool 201 } 202 203 // ImagePullOptions holds information to pull images. 204 type ImagePullOptions struct { 205 All bool 206 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 207 PrivilegeFunc RequestPrivilegeFunc 208 Platform string 209 } 210 211 // RequestPrivilegeFunc is a function interface that 212 // clients can supply to retry operations after 213 // getting an authorization error. 214 // This function returns the registry authentication 215 // header value in base 64 format, or an error 216 // if the privilege request fails. 217 type RequestPrivilegeFunc func() (string, error) 218 219 // ImagePushOptions holds information to push images. 220 type ImagePushOptions ImagePullOptions 221 222 // ImageRemoveOptions holds parameters to remove images. 223 type ImageRemoveOptions struct { 224 Force bool 225 PruneChildren bool 226 } 227 228 // ImageSearchOptions holds parameters to search images with. 229 type ImageSearchOptions struct { 230 RegistryAuth string 231 PrivilegeFunc RequestPrivilegeFunc 232 Filters filters.Args 233 Limit int 234 } 235 236 // NodeListOptions holds parameters to list nodes with. 237 type NodeListOptions struct { 238 Filters filters.Args 239 } 240 241 // NodeRemoveOptions holds parameters to remove nodes with. 242 type NodeRemoveOptions struct { 243 Force bool 244 } 245 246 // ServiceCreateOptions contains the options to use when creating a service. 247 type ServiceCreateOptions struct { 248 // EncodedRegistryAuth is the encoded registry authorization credentials to 249 // use when updating the service. 250 // 251 // This field follows the format of the X-Registry-Auth header. 252 EncodedRegistryAuth string 253 254 // QueryRegistry indicates whether the service update requires 255 // contacting a registry. A registry may be contacted to retrieve 256 // the image digest and manifest, which in turn can be used to update 257 // platform or other information about the service. 258 QueryRegistry bool 259 } 260 261 // Values for RegistryAuthFrom in ServiceUpdateOptions 262 const ( 263 RegistryAuthFromSpec = "spec" 264 RegistryAuthFromPreviousSpec = "previous-spec" 265 ) 266 267 // ServiceUpdateOptions contains the options to be used for updating services. 268 type ServiceUpdateOptions struct { 269 // EncodedRegistryAuth is the encoded registry authorization credentials to 270 // use when updating the service. 271 // 272 // This field follows the format of the X-Registry-Auth header. 273 EncodedRegistryAuth string 274 275 // TODO(stevvooe): Consider moving the version parameter of ServiceUpdate 276 // into this field. While it does open API users up to racy writes, most 277 // users may not need that level of consistency in practice. 278 279 // RegistryAuthFrom specifies where to find the registry authorization 280 // credentials if they are not given in EncodedRegistryAuth. Valid 281 // values are "spec" and "previous-spec". 282 RegistryAuthFrom string 283 284 // Rollback indicates whether a server-side rollback should be 285 // performed. When this is set, the provided spec will be ignored. 286 // The valid values are "previous" and "none". An empty value is the 287 // same as "none". 288 Rollback string 289 290 // QueryRegistry indicates whether the service update requires 291 // contacting a registry. A registry may be contacted to retrieve 292 // the image digest and manifest, which in turn can be used to update 293 // platform or other information about the service. 294 QueryRegistry bool 295 } 296 297 // ServiceListOptions holds parameters to list services with. 298 type ServiceListOptions struct { 299 Filters filters.Args 300 301 // Status indicates whether the server should include the service task 302 // count of running and desired tasks. 303 Status bool 304 } 305 306 // ServiceInspectOptions holds parameters related to the "service inspect" 307 // operation. 308 type ServiceInspectOptions struct { 309 InsertDefaults bool 310 } 311 312 // TaskListOptions holds parameters to list tasks with. 313 type TaskListOptions struct { 314 Filters filters.Args 315 } 316 317 // PluginRemoveOptions holds parameters to remove plugins. 318 type PluginRemoveOptions struct { 319 Force bool 320 } 321 322 // PluginEnableOptions holds parameters to enable plugins. 323 type PluginEnableOptions struct { 324 Timeout int 325 } 326 327 // PluginDisableOptions holds parameters to disable plugins. 328 type PluginDisableOptions struct { 329 Force bool 330 } 331 332 // PluginInstallOptions holds parameters to install a plugin. 333 type PluginInstallOptions struct { 334 Disabled bool 335 AcceptAllPermissions bool 336 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 337 RemoteRef string // RemoteRef is the plugin name on the registry 338 PrivilegeFunc RequestPrivilegeFunc 339 AcceptPermissionsFunc func(PluginPrivileges) (bool, error) 340 Args []string 341 } 342 343 // SwarmUnlockKeyResponse contains the response for Engine API: 344 // GET /swarm/unlockkey 345 type SwarmUnlockKeyResponse struct { 346 // UnlockKey is the unlock key in ASCII-armored format. 347 UnlockKey string 348 } 349 350 // PluginCreateOptions hold all options to plugin create. 351 type PluginCreateOptions struct { 352 RepoName string 353 }