@otterdeploy/docker 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,12 +16,15 @@ import { Docker } from "@otterdeploy/docker";
16
16
  // Auto-detect from DOCKER_HOST, DOCKER_TLS_VERIFY, etc.
17
17
  const docker = Docker.fromEnv();
18
18
 
19
- // List containers
19
+ // List containers (check result)
20
20
  const result = await docker.containers.list({ all: true });
21
21
  if (result.isOk()) {
22
22
  console.log(result.value);
23
23
  }
24
24
 
25
+ // Or unwrap directly (throws on error)
26
+ const containers = (await docker.containers.list({ all: true })).unwrap();
27
+
25
28
  // Pull an image
26
29
  const stream = await docker.pull("nginx:latest");
27
30
 
@@ -41,14 +44,14 @@ Transports connect to the Docker daemon over different protocols.
41
44
  const docker = Docker.fromEnv();
42
45
  ```
43
46
 
44
- Reads `DOCKER_HOST`, `DOCKER_TLS_VERIFY`, `DOCKER_CERT_PATH`, and `DOCKER_CLIENT_TIMEOUT`.
47
+ Reads `DOCKER_HOST`, `DOCKER_TLS_VERIFY`, `DOCKER_CERT_PATH`, and `DOCKER_CLIENT_TIMEOUT`. Defaults to API version `v1.47`.
45
48
 
46
49
  ### Unix Socket (default)
47
50
 
48
51
  ```ts
49
52
  const docker = new Docker({
50
53
  transport: { type: "unix", socketPath: "/var/run/docker.sock" },
51
- apiVersion: "v1.53",
54
+ apiVersion: "v1.47",
52
55
  });
53
56
  ```
54
57
 
@@ -66,7 +69,7 @@ const docker = new Docker({
66
69
  key: fs.readFileSync("/certs/key.pem"),
67
70
  },
68
71
  },
69
- apiVersion: "v1.53",
72
+ apiVersion: "v1.47",
70
73
  });
71
74
  ```
72
75
 
@@ -81,7 +84,7 @@ const docker = new Docker({
81
84
  username: "deploy",
82
85
  privateKey: fs.readFileSync("~/.ssh/id_rsa", "utf8"),
83
86
  },
84
- apiVersion: "v1.53",
87
+ apiVersion: "v1.47",
85
88
  });
86
89
  ```
87
90
 
@@ -92,13 +95,13 @@ const docker = new Docker({
92
95
  ```ts
93
96
  const docker = new Docker({
94
97
  transport: { type: "npipe", path: "//./pipe/docker_engine" },
95
- apiVersion: "v1.53",
98
+ apiVersion: "v1.47",
96
99
  });
97
100
  ```
98
101
 
99
102
  ## API Reference
100
103
 
101
- All methods return `Result<T, DockerError>` from [better-result](https://github.com/niconiahi/better-result). Use `isOk()` / `isErr()` for type-safe error handling.
104
+ All methods return `Result<T, DockerError>` from [better-result](https://github.com/niconiahi/better-result). Use `isOk()` / `isErr()` for type-safe error handling, or `.unwrap()` to get the value directly (throws on error).
102
105
 
103
106
  ### Containers
104
107
 
@@ -226,8 +229,18 @@ await docker.system.pruneBuilder({ all: true });
226
229
  ```ts
227
230
  // Services
228
231
  const services = await docker.services.list();
229
- const service = await docker.services.create({ Name: "web", TaskTemplate: { /* ... */ } });
230
- await service.update({ version: 1, spec: { /* ... */ } });
232
+ const service = await docker.services.create({
233
+ Name: "web",
234
+ TaskTemplate: {
235
+ /* ... */
236
+ },
237
+ });
238
+ await service.update({
239
+ version: 1,
240
+ spec: {
241
+ /* ... */
242
+ },
243
+ });
231
244
  await service.logs({ stdout: true });
232
245
  await service.remove();
233
246
 
@@ -296,6 +309,12 @@ if (result.isErr()) {
296
309
  }
297
310
  ```
298
311
 
312
+ If you prefer exceptions, use `.unwrap()` to get the value directly or throw on error:
313
+
314
+ ```ts
315
+ const info = (await container.inspect()).unwrap(); // throws DockerError on failure
316
+ ```
317
+
299
318
  Error types: `DockerBadRequestError`, `DockerUnauthorizedError`, `DockerForbiddenError`, `DockerNotFoundError`, `DockerConflictError`, `DockerServerError`, `DockerServiceUnavailableError`, `DockerNetworkError`, `DockerTimeoutError`, `DockerAbortError`.
300
319
 
301
320
  ## BuildKit Sessions
@@ -305,22 +324,12 @@ For BuildKit v2 builds with registry authentication:
305
324
  ```ts
306
325
  import { withSession } from "@otterdeploy/docker";
307
326
 
308
- const session = await withSession(transport, "v1.53", {
327
+ const session = await withSession(transport, "v1.47", {
309
328
  username: "user",
310
329
  password: "pass",
311
330
  });
312
331
  ```
313
332
 
314
- ## Scripts
315
-
316
- ```bash
317
- bun run build # Build with tsdown
318
- bun test # Run tests
319
- bun run lint # Lint with oxlint
320
- bun run format # Format with oxfmt
321
- bun run typecheck # Type check
322
- ```
323
-
324
333
  ## License
325
334
 
326
335
  MIT
package/dist/index.d.mts CHANGED
@@ -2007,5 +2007,4 @@ type SessionResult = {
2007
2007
  */
2008
2008
  declare function withSession(transport: Transport, apiVersion: string, auth?: AuthConfig): Promise<Result<SessionResult, DockerError>>;
2009
2009
  //#endregion
2010
- export { type ArchiveInfo, type AuthConfig, type AuthResponse, type BuildOptions, type BuilderPruneOptions, type BuilderPruneResponse, type CheckpointCreateOptions, type Config, type ConfigCreateOptions, ConfigEntity, type ConfigListOptions, ConfigOperations, type ConfigSpec, type ConfigUpdateOptions, Container, type ContainerArchiveOptions, type ContainerAttachOptions, type ContainerChange, type ContainerCommitOptions, type ContainerConfig, type ContainerInspect, type ContainerKillOptions, type ContainerListOptions, ContainerOperations, type ContainerPruneOptions, type ContainerRemoveOptions, type ContainerResizeOptions, type ContainerRestartOptions, type ContainerState, type ContainerStats, type ContainerStatsOptions, type ContainerStopOptions, type ContainerSummary, type ContainerTopResponse, type ContainerUpdateOptions, type ContainerUpdateResponse, type ContainerWaitOptions, type CreateContainerOptions, type CreateContainerResponse, type CreateImageOptions, type CreateVolumeOptions, type DialOptions, type DialResponse, Docker, DockerAbortError, type DockerApiError, DockerBadRequestError, type DockerConfig, DockerConflictError, DockerDecodeError, type DockerError, DockerForbiddenError, type DockerInfo, DockerNetworkError, DockerNotFoundError, DockerServerError, DockerServiceUnavailableError, DockerStream, DockerTimeoutError, type DockerTransportError, DockerUnauthorizedError, DockerUnknownError, type DockerVersion, type EndpointIPAMConfig, type EndpointPortConfig, type EndpointSettings, type EndpointSpec, type EventActor, type EventMessage, type EventsOptions, Exec, type ExecCreateOptions, type ExecInspect, type ExecStartOptions, type ExecStartWithStdinOptions, type Filters, type HealthConfig, type HostConfig, HttpDuplex, type HttpMethod, type IPAM, type IdResponse, Image, type ImageConfig, type ImageDeleteResponseItem, type ImageHistory, type ImageImportOptions, type ImageInspect, type ImageListOptions, ImageOperations, type ImagePruneOptions, type ImagePushOptions, type ImageRemoveOptions, type ImageSearchOptions, type ImageSummary, type ImageTagOptions, type LogsOptions, type Mount, type MountPoint, NamedPipeTransport, type Network, type NetworkConnectOptions, type NetworkCreateOptions, type NetworkCreateResponse, type NetworkDisconnectOptions, NetworkEntity, type NetworkListOptions, NetworkOperations, type NetworkPruneOptions, type NetworkSettings, type NetworkingConfig, type Node, NodeEntity, type NodeListOptions, NodeOperations, type NodeRemoveOptions, type NodeSpec, type NodeUpdateOptions, type ObjectVersion, type Plugin, type PluginConfigureOptions, type PluginCreateOptions, type PluginDisableOptions, type PluginEnableOptions, PluginEntity, type PluginInstallOptions, type PluginListOptions, PluginOperations, type PluginPrivilege, type PluginPrivilegesOptions, type PluginRemoveOptions, type PluginUpgradeOptions, type Port, type PortBinding, type PruneResponse, type PullOptions, type RestartPolicy, type RunOptions, type RunResult, type SearchResult, type Secret, type SecretCreateOptions, SecretEntity, type SecretListOptions, SecretOperations, type SecretSpec, type SecretUpdateOptions, type Service, type ServiceCreateOptions, type ServiceCreateResponse, ServiceEntity, type ServiceListOptions, ServiceOperations, type ServiceSpec, type ServiceUpdateConfig, type ServiceUpdateOptions, type ServiceUpdateResponse, type SessionResult, type StatusCodeMap, type SwarmInitOptions, type SwarmJoinOptions, type SwarmLeaveOptions, type SwarmUpdateOptions, type SystemDf, SystemOperations, type Task, TaskEntity, type TaskListOptions, TaskOperations, type TlsConfig, type Transport, type TransportConfig, type Volume, VolumeEntity, type VolumeListOptions, type VolumeListResponse, VolumeOperations, type VolumePruneOptions, type VolumeRemoveOptions, type WaitResponse, createTransport, createTransportFromEnv, demuxStream, followProgress, statusCodeToError, withSession };
2011
- //# sourceMappingURL=index.d.mts.map
2010
+ export { type ArchiveInfo, type AuthConfig, type AuthResponse, type BuildOptions, type BuilderPruneOptions, type BuilderPruneResponse, type CheckpointCreateOptions, type Config, type ConfigCreateOptions, ConfigEntity, type ConfigListOptions, ConfigOperations, type ConfigSpec, type ConfigUpdateOptions, Container, type ContainerArchiveOptions, type ContainerAttachOptions, type ContainerChange, type ContainerCommitOptions, type ContainerConfig, type ContainerInspect, type ContainerKillOptions, type ContainerListOptions, ContainerOperations, type ContainerPruneOptions, type ContainerRemoveOptions, type ContainerResizeOptions, type ContainerRestartOptions, type ContainerState, type ContainerStats, type ContainerStatsOptions, type ContainerStopOptions, type ContainerSummary, type ContainerTopResponse, type ContainerUpdateOptions, type ContainerUpdateResponse, type ContainerWaitOptions, type CreateContainerOptions, type CreateContainerResponse, type CreateImageOptions, type CreateVolumeOptions, type DialOptions, type DialResponse, Docker, DockerAbortError, type DockerApiError, DockerBadRequestError, type DockerConfig, DockerConflictError, DockerDecodeError, type DockerError, DockerForbiddenError, type DockerInfo, DockerNetworkError, DockerNotFoundError, DockerServerError, DockerServiceUnavailableError, DockerStream, DockerTimeoutError, type DockerTransportError, DockerUnauthorizedError, DockerUnknownError, type DockerVersion, type EndpointIPAMConfig, type EndpointPortConfig, type EndpointSettings, type EndpointSpec, type EventActor, type EventMessage, type EventsOptions, Exec, type ExecCreateOptions, type ExecInspect, type ExecStartOptions, type ExecStartWithStdinOptions, type Filters, type HealthConfig, type HostConfig, HttpDuplex, type HttpMethod, type IPAM, type IdResponse, Image, type ImageConfig, type ImageDeleteResponseItem, type ImageHistory, type ImageImportOptions, type ImageInspect, type ImageListOptions, ImageOperations, type ImagePruneOptions, type ImagePushOptions, type ImageRemoveOptions, type ImageSearchOptions, type ImageSummary, type ImageTagOptions, type LogsOptions, type Mount, type MountPoint, NamedPipeTransport, type Network, type NetworkConnectOptions, type NetworkCreateOptions, type NetworkCreateResponse, type NetworkDisconnectOptions, NetworkEntity, type NetworkListOptions, NetworkOperations, type NetworkPruneOptions, type NetworkSettings, type NetworkingConfig, type Node, NodeEntity, type NodeListOptions, NodeOperations, type NodeRemoveOptions, type NodeSpec, type NodeUpdateOptions, type ObjectVersion, type Plugin, type PluginConfigureOptions, type PluginCreateOptions, type PluginDisableOptions, type PluginEnableOptions, PluginEntity, type PluginInstallOptions, type PluginListOptions, PluginOperations, type PluginPrivilege, type PluginPrivilegesOptions, type PluginRemoveOptions, type PluginUpgradeOptions, type Port, type PortBinding, type PruneResponse, type PullOptions, type RestartPolicy, type RunOptions, type RunResult, type SearchResult, type Secret, type SecretCreateOptions, SecretEntity, type SecretListOptions, SecretOperations, type SecretSpec, type SecretUpdateOptions, type Service, type ServiceCreateOptions, type ServiceCreateResponse, ServiceEntity, type ServiceListOptions, ServiceOperations, type ServiceSpec, type ServiceUpdateConfig, type ServiceUpdateOptions, type ServiceUpdateResponse, type SessionResult, type StatusCodeMap, type SwarmInitOptions, type SwarmJoinOptions, type SwarmLeaveOptions, type SwarmUpdateOptions, type SystemDf, SystemOperations, type Task, TaskEntity, type TaskListOptions, TaskOperations, type TlsConfig, type Transport, type TransportConfig, type Volume, VolumeEntity, type VolumeListOptions, type VolumeListResponse, VolumeOperations, type VolumePruneOptions, type VolumeRemoveOptions, type WaitResponse, createTransport, createTransportFromEnv, demuxStream, followProgress, statusCodeToError, withSession };