@dockstat/docker 0.1.0 → 0.1.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/dist/index.js +2 -0
- package/dist/types.d.ts +2442 -0
- package/package.json +10 -3
- package/src/docker.ts +0 -35
- package/src/environment.d.ts +0 -15
- package/src/index.ts +0 -9
- package/src/modules/_socket/index.ts +0 -106
- package/src/modules/base/index.ts +0 -30
- package/src/modules/base/types.ts +0 -17
- package/src/modules/container/index.ts +0 -384
- package/src/modules/container/types.ts +0 -673
- package/src/modules/distribution/index.ts +0 -14
- package/src/modules/distribution/types.ts +0 -24
- package/src/modules/exec/index.ts +0 -60
- package/src/modules/exec/types.ts +0 -64
- package/src/modules/images/index.ts +0 -220
- package/src/modules/images/types.ts +0 -686
- package/src/modules/networks/index.ts +0 -87
- package/src/modules/networks/types.ts +0 -258
- package/src/modules/nodes/index.ts +0 -48
- package/src/modules/nodes/types.ts +0 -69
- package/src/modules/plugins/index.ts +0 -128
- package/src/modules/plugins/types.ts +0 -114
- package/src/modules/secrets/index.ts +0 -5
- package/src/modules/secrets/types.ts +0 -0
- package/src/modules/volumes/index.ts +0 -65
- package/src/modules/volumes/types.ts +0 -197
- package/src/utils/env.ts +0 -48
- package/src/utils/error.ts +0 -23
- package/src/utils/request-options.ts +0 -68
- package/src/utils/response.ts +0 -31
- package/src/utils/url.ts +0 -48
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { BaseModule } from "../base"
|
|
2
|
-
import type {
|
|
3
|
-
ExecCreateOptions,
|
|
4
|
-
ExecCreateResponse,
|
|
5
|
-
ExecInspectResponse,
|
|
6
|
-
ExecStartOptions,
|
|
7
|
-
} from "./types"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Exec Module - handles all Docker exec operations
|
|
11
|
-
*/
|
|
12
|
-
export class ExecModule extends BaseModule {
|
|
13
|
-
/**
|
|
14
|
-
* Create an exec instance
|
|
15
|
-
* @param containerId - Container ID or name
|
|
16
|
-
* @param options - Exec configuration
|
|
17
|
-
* @returns Exec create response with ID
|
|
18
|
-
*/
|
|
19
|
-
async create(containerId: string, options: ExecCreateOptions): Promise<ExecCreateResponse> {
|
|
20
|
-
const path = `/containers/${containerId}/exec`
|
|
21
|
-
const res = await this.request(path, "POST", options)
|
|
22
|
-
return (await res.json()) as ExecCreateResponse
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Start an exec instance
|
|
27
|
-
* @param execId - Exec instance ID
|
|
28
|
-
* @param options - Start configuration
|
|
29
|
-
* @returns Response object (for streaming)
|
|
30
|
-
*/
|
|
31
|
-
async start(execId: string, options?: ExecStartOptions): Promise<Response> {
|
|
32
|
-
const path = `/exec/${execId}/start`
|
|
33
|
-
const res = await this.request(path, "POST", options)
|
|
34
|
-
return res
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Inspect an exec instance
|
|
39
|
-
* @param execId - Exec instance ID
|
|
40
|
-
* @returns Detailed exec instance information
|
|
41
|
-
*/
|
|
42
|
-
async inspect(execId: string): Promise<ExecInspectResponse> {
|
|
43
|
-
const path = `/exec/${execId}/json`
|
|
44
|
-
const res = await this.request(path, "GET")
|
|
45
|
-
return (await res.json()) as ExecInspectResponse
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Resize an exec instance TTY session
|
|
50
|
-
* @param execId - Exec instance ID
|
|
51
|
-
* @param height - Height of TTY session in characters
|
|
52
|
-
* @param width - Width of TTY session in characters
|
|
53
|
-
*/
|
|
54
|
-
async resize(execId: string, height: number, width: number): Promise<void> {
|
|
55
|
-
await this.request(`/exec/${execId}/resize`, "POST", undefined, undefined, {
|
|
56
|
-
h: height,
|
|
57
|
-
w: width,
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Exec Types
|
|
3
|
-
// ============================================================================
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Exec instance create options
|
|
7
|
-
*/
|
|
8
|
-
export interface ExecCreateOptions {
|
|
9
|
-
AttachStdin?: boolean
|
|
10
|
-
AttachStdout?: boolean
|
|
11
|
-
AttachStderr?: boolean
|
|
12
|
-
ConsoleSize?: [number, number] | null
|
|
13
|
-
DetachKeys?: string
|
|
14
|
-
Tty?: boolean
|
|
15
|
-
Env?: string[]
|
|
16
|
-
Cmd?: string[]
|
|
17
|
-
Privileged?: boolean
|
|
18
|
-
User?: string
|
|
19
|
-
WorkingDir?: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Exec create response
|
|
24
|
-
*/
|
|
25
|
-
export interface ExecCreateResponse {
|
|
26
|
-
Id: string
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Exec start options
|
|
31
|
-
*/
|
|
32
|
-
export interface ExecStartOptions {
|
|
33
|
-
Detach?: boolean
|
|
34
|
-
Tty?: boolean
|
|
35
|
-
ConsoleSize?: [number, number] | null
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Exec inspect response
|
|
40
|
-
*/
|
|
41
|
-
export interface ExecInspectResponse {
|
|
42
|
-
CanRemove: boolean
|
|
43
|
-
DetachKeys: string
|
|
44
|
-
ID: string
|
|
45
|
-
Running: boolean
|
|
46
|
-
ExitCode: number
|
|
47
|
-
ProcessConfig: ProcessConfig
|
|
48
|
-
OpenStdin: boolean
|
|
49
|
-
OpenStderr: boolean
|
|
50
|
-
OpenStdout: boolean
|
|
51
|
-
ContainerID: string
|
|
52
|
-
Pid: number
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Process configuration
|
|
57
|
-
*/
|
|
58
|
-
export interface ProcessConfig {
|
|
59
|
-
arguments: string[]
|
|
60
|
-
entrypoint: string
|
|
61
|
-
privileged: boolean
|
|
62
|
-
tty: boolean
|
|
63
|
-
user: string
|
|
64
|
-
}
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import type { HeadersInit } from "bun"
|
|
2
|
-
import { BaseModule } from "../base"
|
|
3
|
-
import type {
|
|
4
|
-
BuildCacheDiskUsage,
|
|
5
|
-
BuildImageOptions,
|
|
6
|
-
CommitBody,
|
|
7
|
-
CommitParams,
|
|
8
|
-
CreateImageInfo,
|
|
9
|
-
ExportAllImagesOptions,
|
|
10
|
-
ExportImageOptions,
|
|
11
|
-
HistoryImageOptions,
|
|
12
|
-
ImageDeleteResponseItem,
|
|
13
|
-
ImageHistoryResponseItem,
|
|
14
|
-
ImageID,
|
|
15
|
-
ImageInspect,
|
|
16
|
-
ImagePruneResponse,
|
|
17
|
-
ImageSearchResponseItem,
|
|
18
|
-
ImageSummary,
|
|
19
|
-
InspectImageOptions,
|
|
20
|
-
ListImagesOptions,
|
|
21
|
-
LoadImageOptions,
|
|
22
|
-
PruneBuildCacheOptions,
|
|
23
|
-
PruneImagesOptions,
|
|
24
|
-
PullImageOptions,
|
|
25
|
-
PushImageInfo,
|
|
26
|
-
PushImageOptions,
|
|
27
|
-
RemoveImageOptions,
|
|
28
|
-
SearchImagesOptions,
|
|
29
|
-
TagImageOptions,
|
|
30
|
-
} from "./types"
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Images Module - handles all Docker image operations
|
|
34
|
-
*/
|
|
35
|
-
export class ImagesModule extends BaseModule {
|
|
36
|
-
/**
|
|
37
|
-
* List images
|
|
38
|
-
* @param options - List options
|
|
39
|
-
* @returns Array of image summaries
|
|
40
|
-
*/
|
|
41
|
-
async list(options?: ListImagesOptions): Promise<ImageSummary[]> {
|
|
42
|
-
const res = await this.request(`/images/json`, "GET", undefined, undefined, options)
|
|
43
|
-
return (await res.json()) as ImageSummary[]
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Create (pull) an image
|
|
48
|
-
* @param options - Pull options
|
|
49
|
-
* @returns Image creation info
|
|
50
|
-
*/
|
|
51
|
-
async pull(options: PullImageOptions): Promise<CreateImageInfo[]> {
|
|
52
|
-
const headers: HeadersInit = {}
|
|
53
|
-
if (options.authHeader) {
|
|
54
|
-
headers["X-Registry-Auth"] = options.authHeader
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const res = await this.request(`/images/create`, "POST", options.inputImage, headers, options)
|
|
58
|
-
return (await res.json()) as CreateImageInfo[]
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Inspect an image
|
|
63
|
-
* @param name - Image name or ID
|
|
64
|
-
* @param options - Inspect options
|
|
65
|
-
* @returns Detailed image information
|
|
66
|
-
*/
|
|
67
|
-
async inspect(name: string, options?: InspectImageOptions): Promise<ImageInspect> {
|
|
68
|
-
const res = await this.request(`/images/${name}/json`, "GET", undefined, undefined, options)
|
|
69
|
-
return (await res.json()) as ImageInspect
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Get image history
|
|
74
|
-
* @param name - Image name or ID
|
|
75
|
-
* @param options - History options
|
|
76
|
-
* @returns Array of image history items
|
|
77
|
-
*/
|
|
78
|
-
async history(name: string, options?: HistoryImageOptions): Promise<ImageHistoryResponseItem[]> {
|
|
79
|
-
const res = await this.request(`/images/${name}/history`, "GET", undefined, undefined, options)
|
|
80
|
-
return (await res.json()) as ImageHistoryResponseItem[]
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Push an image
|
|
85
|
-
* @param name - Image name to push
|
|
86
|
-
* @param options - Push options
|
|
87
|
-
* @returns Push info
|
|
88
|
-
*/
|
|
89
|
-
async push(name: string, options: PushImageOptions): Promise<PushImageInfo[]> {
|
|
90
|
-
const headers: HeadersInit = {
|
|
91
|
-
"X-Registry-Auth": options.authHeader,
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const res = await this.request(`/images/${name}/push`, "POST", undefined, headers, options)
|
|
95
|
-
return (await res.json()) as PushImageInfo[]
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Tag an image
|
|
100
|
-
* @param name - Image name or ID to tag
|
|
101
|
-
* @param options - Tag options
|
|
102
|
-
*/
|
|
103
|
-
async tag(name: string, options: TagImageOptions): Promise<void> {
|
|
104
|
-
await this.request(`/images/${name}/tag`, "POST", undefined, undefined, options)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Remove an image
|
|
109
|
-
* @param name - Image name or ID
|
|
110
|
-
* @param options - Remove options
|
|
111
|
-
* @returns Array of delete response items
|
|
112
|
-
*/
|
|
113
|
-
async remove(name: string, options?: RemoveImageOptions): Promise<ImageDeleteResponseItem[]> {
|
|
114
|
-
const res = await this.request(`/images/${name}`, "DELETE", undefined, undefined, options)
|
|
115
|
-
return (await res.json()) as ImageDeleteResponseItem[]
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Search images
|
|
120
|
-
* @param options - Search options
|
|
121
|
-
* @returns Array of search results
|
|
122
|
-
*/
|
|
123
|
-
async search(options: SearchImagesOptions): Promise<ImageSearchResponseItem[]> {
|
|
124
|
-
const res = await this.request(`/images/search`, "GET", undefined, undefined, options)
|
|
125
|
-
return (await res.json()) as ImageSearchResponseItem[]
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Prune unused images
|
|
130
|
-
* @param options - Prune options
|
|
131
|
-
* @returns Prune response
|
|
132
|
-
*/
|
|
133
|
-
async prune(options?: PruneImagesOptions): Promise<ImagePruneResponse> {
|
|
134
|
-
const res = await this.request(`/images/prune`, "POST", undefined, undefined, options)
|
|
135
|
-
return (await res.json()) as ImagePruneResponse
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Export an image
|
|
140
|
-
* @param name - Image name or ID
|
|
141
|
-
* @param options - Export options
|
|
142
|
-
* @returns Response with tarball
|
|
143
|
-
*/
|
|
144
|
-
async get(name: string, options?: ExportImageOptions): Promise<Response> {
|
|
145
|
-
return await this.request(`/images/${name}/get`, "GET", undefined, undefined, options)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Export multiple images
|
|
150
|
-
* @param options - Export options
|
|
151
|
-
* @returns Response with tarball
|
|
152
|
-
*/
|
|
153
|
-
async getAll(options?: ExportAllImagesOptions): Promise<Response> {
|
|
154
|
-
return await this.request(`/images/get`, "GET", undefined, undefined, options)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Load images
|
|
159
|
-
* @param options - Load options
|
|
160
|
-
* @returns Load response
|
|
161
|
-
*/
|
|
162
|
-
async load(options: LoadImageOptions): Promise<unknown> {
|
|
163
|
-
const res = await this.request(
|
|
164
|
-
`/images/load`,
|
|
165
|
-
"POST",
|
|
166
|
-
options.imagesTarball,
|
|
167
|
-
undefined,
|
|
168
|
-
options
|
|
169
|
-
)
|
|
170
|
-
return await res.json()
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Build an image from a tar archive with a Dockerfile in it.
|
|
175
|
-
* The Dockerfile specifies how the image is built from the tar archive.
|
|
176
|
-
* It is typically in the archive's root,
|
|
177
|
-
* but can be at a different path or have a different name by specifying the dockerfile parameter.
|
|
178
|
-
* See the Dockerfile reference for more information.
|
|
179
|
-
*
|
|
180
|
-
* The Docker daemon performs a preliminary validation of the Dockerfile before starting the build,
|
|
181
|
-
* and returns an error if the syntax is incorrect.
|
|
182
|
-
* After that, each instruction is run one-by-one until the ID of the new image is output.
|
|
183
|
-
*
|
|
184
|
-
* The build is canceled if the client drops the connection by quitting or being killed.
|
|
185
|
-
* @param options - Build options
|
|
186
|
-
* @returns Build info
|
|
187
|
-
*/
|
|
188
|
-
async build(options: BuildImageOptions): Promise<boolean> {
|
|
189
|
-
const headers: HeadersInit = {
|
|
190
|
-
"Content-Type": "application/x-tar",
|
|
191
|
-
}
|
|
192
|
-
if (options.authConfig) {
|
|
193
|
-
headers["X-Registry-Config"] = options.authConfig
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
await this.request(`/build`, "POST", options.inputStream, headers, options)
|
|
197
|
-
return true
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Prune build cache
|
|
202
|
-
* @param options - Prune build cache options
|
|
203
|
-
* @returns Build cache disk usage
|
|
204
|
-
*/
|
|
205
|
-
async pruneBuild(options?: PruneBuildCacheOptions): Promise<BuildCacheDiskUsage> {
|
|
206
|
-
const res = await this.request(`/build/prune`, "POST", undefined, undefined, options)
|
|
207
|
-
return (await res.json()) as BuildCacheDiskUsage
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Commit a container as an image
|
|
212
|
-
* @param container - Container ID or name
|
|
213
|
-
* @param options - Commit options
|
|
214
|
-
* @returns Image ID
|
|
215
|
-
*/
|
|
216
|
-
async commit(containerConfig: CommitBody, options: CommitParams): Promise<ImageID> {
|
|
217
|
-
const res = await this.request(`/commit`, "POST", containerConfig, undefined, options)
|
|
218
|
-
return (await res.json()) as ImageID
|
|
219
|
-
}
|
|
220
|
-
}
|