the-moby-effect 1.43.0-alpha.0 → 1.43.0-alpha.2

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
@@ -2,28 +2,29 @@
2
2
 
3
3
  Moby API client built using [effect-ts](http://effect.website). If you want documentation, please consider reading [The Docker API documentation](https://docs.docker.com/engine/api/latest), it is very well written and there is nothing in this library that wouldn't be in there (plus I would just do a worse job if I tried to write my interpretation of their documentation here). If you are just looking for some examples to get your feet underneath you quickly with effect integration, then I do have some of those [here](./examples/).
4
4
 
5
- ## Goals
5
+ ## Goals :white_check_mark:
6
6
 
7
7
  - [x] - local unix socket connections
8
8
  - [x] - http and https connections
9
9
  - [x] - ssh connections
10
+ - [x] - `DOCKER_HOST` environment variable support
10
11
  - [x] - streaming (just like [dockerode](https://github.com/apocas/dockerode), streams are passed directly through to you)
11
12
  - [x] - tests, examples, and in-line JSDoc comments based on the moby api documentation
12
13
  - [x] - Strong focus on types and typescript support
13
14
  - [x] - Support multiple "engines" (docker, podman, ect). If its built on top of [moby](https://github.com/moby/moby) then it _should_ just work, however, __currently only docker is tested against__
14
15
 
15
- ## Non-Goals
16
+ ## Non-Goals :wastebasket:
16
17
 
17
18
  - Tighter schema: the moby api schema is pretty loose as it aims to be backwards compatible - almost nothing is explicitly marked as required and object properties are optional by default under the swagger2.0/openapi specification. I have no intention to try to tighten their schema in my project. If the moby schema doesn't explicitly mark it as a required field, then it will be optional.
18
19
 
19
20
  - Version negotiating: either install a specific version for the moby api that you are targeting or just keep your docker install somewhat up-to-date and you should have no problems
20
21
 
21
- ## Todo/Future
22
+ ## Todo/Future :bulb:
22
23
  - Add more examples
23
24
  - Maybe add tests against something else other than docker like podman?
24
- - Patch upstream @effect/platform-node to support just streaming responses, needed for session and container attach endpoints: [upstream pr](https://github.com/Effect-TS/platform/pull/375)
25
+ - Patch upstream @effect/platform-node to support just streaming responses, needed for session and container attach endpoints: [upstream pr](https://github.com/Effect-TS/effect/pull/1796)
25
26
 
26
- ## Compatibility
27
+ ## Compatibility :closed_lock_with_key:
27
28
 
28
29
  the-moby-effect targets the current stable version of the moby api, which is v1.43 at the time of writing. If you are curious what that translates to for docker versions then take a look at [this](https://docs.docker.com/engine/api/#api-version-matrix) api version matrix published by Docker. As stated in the api version matrix, only Docker v24.0 would be officially supported by the-moby-effect, however, we still test against docker v20, v23, v24, and the next release candidate which is v25 (there is no v21 or v22 btw). Here is another note from Docker:
29
30
 
@@ -33,10 +34,10 @@ the-moby-effect targets the current stable version of the moby api, which is v1.
33
34
 
34
35
  The only compatibility issue found so far is that when using the-moby-effect with docker v20 you can not filter or prune volumes using the `all` filter as it was not present at the time. Other than that all functionality appears to still work.
35
36
 
36
- ## Versioning
37
+ ## Versioning :rotating_light:
37
38
 
38
39
  This package does not follow semantic versioning, instead the major and minor part represents the version of the moby api. All bugfixes, breaking or otherwise, will be released under an incremented patch version.
39
40
 
40
- ## Contributing and getting help
41
+ ## Contributing and getting help :speech_balloon: :beers:
41
42
 
42
- Contributions, suggestions, and questions are welcome! I'll review prs and respond to issues/discussion here on GitHub but if you want more direct and probably quicker communication you can find me in the [effect discord](https://discord.gg/effect-ts) as @leonitous
43
+ Contributions, suggestions, and questions are welcome! I'll review prs and respond to issues/discussion here on GitHub but if you want more synchronous communication you can find me in the [effect discord](https://discord.gg/effect-ts) as @leonitous
@@ -9,20 +9,22 @@ import { Context, Effect, Layer, Scope } from "effect";
9
9
  export type MobyConnectionOptions = {
10
10
  connection: "unix";
11
11
  socketPath: string;
12
- } | {
13
- connection: "http";
14
- host: string;
15
- port: number;
16
12
  } | ({
17
13
  connection: "ssh";
18
14
  remoteSocketPath: string;
19
15
  } & ssh2.ConnectConfig) | {
16
+ connection: "http";
17
+ host: string;
18
+ port: number;
19
+ path?: string | undefined;
20
+ } | {
20
21
  connection: "https";
21
22
  host: string;
22
23
  port: number;
23
- cert: string;
24
- ca: string;
25
- key: string;
24
+ path?: string | undefined;
25
+ cert?: string | undefined;
26
+ ca?: string | undefined;
27
+ key?: string | undefined;
26
28
  passphrase?: string | undefined;
27
29
  };
28
30
  /**
@@ -78,7 +78,11 @@ export const getAgent = (connectionOptions) => Effect.map(Effect.acquireRelease(
78
78
  http: agent,
79
79
  https: agent,
80
80
  connectionOptions: connectionOptions,
81
- nodeRequestUrl: connectionOptions.connection === "https" ? "https://0.0.0.0" : "http://0.0.0.0",
81
+ nodeRequestUrl: connectionOptions.connection === "https"
82
+ ? `https://0.0.0.0${connectionOptions.path ?? ""}`
83
+ : connectionOptions.connection === "http"
84
+ ? `http://0.0.0.0${connectionOptions.path ?? ""}`
85
+ : "http://0.0.0.0",
82
86
  [NodeHttp.nodeClient.HttpAgentTypeId]: NodeHttp.nodeClient.HttpAgentTypeId,
83
87
  }));
84
88
  //# sourceMappingURL=agent-helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-helpers.js","sourceRoot":"","sources":["../../src/agent-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,KAAK,QAAQ,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAS,IAAI,EAAE,MAAM,QAAQ,CAAC;AA0CpE,wDAAwD;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAC5B,OAAO,CAAC,GAAG,CAAuB,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC,CAAC;AAE1F,MAAM,CAAC,MAAM,kBAAkB,GAC3B,QAAQ,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CACtC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAClF,CAAC;AAEN;;;;;;;;;;;;;;;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,CAAC,IAAI,IAAI,EAAE,EAAE;YACjD,CAAC,CAAC,gBAAgB;IAC5B,CAAC,QAAQ,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,eAAe;CAC7E,CAAC,CACL,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Effect, Layer, Scope } from "effect";
1
+ import { ConfigError, Effect, Layer, Scope } from "effect";
2
2
  import * as AgentHelpers from "./agent-helpers.js";
3
3
  import * as Configs from "./configs.js";
4
4
  import * as Containers from "./containers.js";
@@ -34,5 +34,35 @@ export * as System from "./system.js";
34
34
  export * as Tasks from "./tasks.js";
35
35
  export * as Volumes from "./volumes.js";
36
36
  export type MobyApi = Layer.Layer<never, never, Configs.Configs | Containers.Containers | Distributions.Distributions | Execs.Execs | Images.Images | Networks.Networks | Nodes.Nodes | Plugins.Plugins | Secrets.Secrets | Services.Services | Sessions.Sessions | Swarm.Swarms | System.Systems | Tasks.Tasks | Volumes.Volumes>;
37
+ /** Creates a MobyApi layer from the provided connection agent */
37
38
  export declare const fromAgent: (agent: Effect.Effect<Scope.Scope, never, AgentHelpers.IMobyConnectionAgent>) => MobyApi;
39
+ /** Creates a MobyApi layer from the provided connection options */
38
40
  export declare const fromConnectionOptions: (connectionOptions: AgentHelpers.MobyConnectionOptions) => MobyApi;
41
+ /**
42
+ * From
43
+ * https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-socket-option
44
+ *
45
+ * "The Docker client will honor the DOCKER_HOST environment variable to set the
46
+ * -H flag for the client"
47
+ *
48
+ * And then from
49
+ * https://docs.docker.com/engine/reference/commandline/dockerd/#bind-docker-to-another-hostport-or-a-unix-socket
50
+ *
51
+ * "-H accepts host and port assignment in the following format:
52
+ * `tcp://[host]:[port][path]` or `unix://path`
53
+ *
54
+ * For example:
55
+ *
56
+ * - `unix://path/to/socket` -> Unix socket located at path/to/socket
57
+ * - When -H is empty, it will default to the same value as when no -H was passed
58
+ * in
59
+ * - `http://host:port/path` -> HTTP connection on host:port and prepend path to
60
+ * all requests
61
+ * - `https://host:port/path` -> HTTPS connection on host:port and prepend path to
62
+ * all requests
63
+ * - `ssh://me@example.com:22/var/run/docker.sock` -> SSH connection to
64
+ * example.com on port 22
65
+ */
66
+ export declare const fromUrl: (dockerHost: string) => Layer.Layer<Layer.Layer.Context<MobyApi> | never, Layer.Layer.Error<MobyApi> | ConfigError.ConfigError, Layer.Layer.Success<MobyApi>>;
67
+ /** Creates a MobyApi layer from the DOCKER_HOST environment variable as a url */
68
+ export declare const fromDockerHostEnvironmentVariable: Layer.Layer<Layer.Layer.Context<MobyApi>, Layer.Layer.Error<MobyApi> | ConfigError.ConfigError, Layer.Layer.Success<MobyApi>>;
package/dist/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Layer } from "effect";
1
+ import { Config, ConfigError, Effect, Layer, Secret } from "effect";
2
2
  import * as AgentHelpers from "./agent-helpers.js";
3
3
  import * as Configs from "./configs.js";
4
4
  import * as Containers from "./containers.js";
@@ -33,6 +33,79 @@ export * as System from "./system.js";
33
33
  export * as Tasks from "./tasks.js";
34
34
  export * as Volumes from "./volumes.js";
35
35
  const layer = Layer.mergeAll(Configs.layer, Containers.layer, Distributions.layer, Execs.layer, Images.layer, Networks.layer, Nodes.layer, Plugins.layer, Secrets.layer, Services.layer, Sessions.layer, Swarm.layer, System.layer, Tasks.layer, Volumes.layer);
36
+ /** Creates a MobyApi layer from the provided connection agent */
36
37
  export const fromAgent = (agent) => layer.pipe(Layer.provide(Layer.scoped(AgentHelpers.MobyConnectionAgent, agent)));
38
+ /** Creates a MobyApi layer from the provided connection options */
37
39
  export const fromConnectionOptions = (connectionOptions) => fromAgent(AgentHelpers.getAgent(connectionOptions));
40
+ /**
41
+ * From
42
+ * https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-socket-option
43
+ *
44
+ * "The Docker client will honor the DOCKER_HOST environment variable to set the
45
+ * -H flag for the client"
46
+ *
47
+ * And then from
48
+ * https://docs.docker.com/engine/reference/commandline/dockerd/#bind-docker-to-another-hostport-or-a-unix-socket
49
+ *
50
+ * "-H accepts host and port assignment in the following format:
51
+ * `tcp://[host]:[port][path]` or `unix://path`
52
+ *
53
+ * For example:
54
+ *
55
+ * - `unix://path/to/socket` -> Unix socket located at path/to/socket
56
+ * - When -H is empty, it will default to the same value as when no -H was passed
57
+ * in
58
+ * - `http://host:port/path` -> HTTP connection on host:port and prepend path to
59
+ * all requests
60
+ * - `https://host:port/path` -> HTTPS connection on host:port and prepend path to
61
+ * all requests
62
+ * - `ssh://me@example.com:22/var/run/docker.sock` -> SSH connection to
63
+ * example.com on port 22
64
+ */
65
+ export const fromUrl = (dockerHost) => {
66
+ const url = new URL(dockerHost);
67
+ if (url.protocol === "unix") {
68
+ return fromConnectionOptions({ connection: "unix", socketPath: url.pathname });
69
+ }
70
+ if (url.protocol === "ssh") {
71
+ return fromConnectionOptions({
72
+ connection: "ssh",
73
+ host: url.hostname,
74
+ username: url.username,
75
+ password: url.password,
76
+ remoteSocketPath: url.pathname,
77
+ port: url.port ? Number.parseInt(url.port) : 22,
78
+ });
79
+ }
80
+ if (url.protocol === "http") {
81
+ return fromConnectionOptions({
82
+ connection: "http",
83
+ host: url.hostname ?? "127.0.0.1",
84
+ port: url.port ? Number.parseInt(url.port) : 2375,
85
+ path: url.pathname,
86
+ });
87
+ }
88
+ if (url.protocol === "https") {
89
+ return fromConnectionOptions({
90
+ connection: "https",
91
+ host: url.hostname ?? "127.0.0.1",
92
+ port: url.port ? Number.parseInt(url.port) : 2376,
93
+ path: url.pathname,
94
+ });
95
+ }
96
+ if (url.protocol === "tcp") {
97
+ const path = url.pathname;
98
+ const host = url.hostname ?? "127.0.0.0.1";
99
+ const port = url.port ? Number.parseInt(url.port) : 2375;
100
+ return fromConnectionOptions({ connection: port === 2376 ? "https" : "http", host, port, path });
101
+ }
102
+ // Any other protocols are not supported
103
+ return Layer.fail(ConfigError.InvalidData([""], `Unsupported protocol ${url.protocol}`));
104
+ };
105
+ /** Creates a MobyApi layer from the DOCKER_HOST environment variable as a url */
106
+ export const fromDockerHostEnvironmentVariable = Config.secret("DOCKER_HOST")
107
+ .pipe(Config.withDefault(Secret.fromString("unix:///var/run/docker.sock")))
108
+ .pipe(Config.map(Secret.value))
109
+ .pipe(Effect.map(fromUrl))
110
+ .pipe(Layer.unwrapEffect);
38
111
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAS,MAAM,QAAQ,CAAC;AAE9C,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,aAAa,MAAM,mBAAmB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,6 @@
1
1
  {
2
2
  "name": "the-moby-effect",
3
- "version": "1.43.0-alpha.0",
3
+ "version": "1.43.0-alpha.2",
4
4
  "description": "Docker daemon API client built using effect-ts",
5
5
  "keywords": [
6
6
  "moby",
@@ -22,7 +22,7 @@
22
22
  "ssh2": "^1.15.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@effect/experimental": "0.5.2",
25
+ "@effect/experimental": "0.5.3",
26
26
  "@effect/platform": "0.39.0",
27
27
  "@effect/platform-node": "0.39.0",
28
28
  "@effect/schema": "0.56.1",
@@ -43,19 +43,19 @@
43
43
  "fast-check": "3.15.0",
44
44
  "prettier": "3.1.1",
45
45
  "prettier-plugin-jsdoc": "1.3.0",
46
- "prettier-plugin-packagejson": "2.4.7",
46
+ "prettier-plugin-packagejson": "2.4.8",
47
47
  "tar-fs": "3.0.4",
48
48
  "tsx": "^4.7.0",
49
49
  "typescript": "5.3.3",
50
- "ws": "8.15.1"
50
+ "ws": "8.16.0"
51
51
  },
52
52
  "peerDependencies": {
53
- "@effect/experimental": "0.5.2",
53
+ "@effect/experimental": "0.5.3",
54
54
  "@effect/platform-node": "~0.39.0",
55
55
  "@effect/schema": "~0.56.1",
56
56
  "effect": "~2.0.0-next.62",
57
57
  "fast-check": "~3.15.0",
58
- "ws": "~8.15.1"
58
+ "ws": "~8.16.0"
59
59
  },
60
60
  "engines": {
61
61
  "node": ">=16"