@ostanin/podman 0.1.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 +432 -0
- package/esm/_dnt.polyfills.d.ts +7 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +1 -0
- package/esm/api/artifacts.d.ts +25 -0
- package/esm/api/artifacts.d.ts.map +1 -0
- package/esm/api/artifacts.js +89 -0
- package/esm/api/containers.d.ts +71 -0
- package/esm/api/containers.d.ts.map +1 -0
- package/esm/api/containers.js +234 -0
- package/esm/api/exec.d.ts +15 -0
- package/esm/api/exec.d.ts.map +1 -0
- package/esm/api/exec.js +45 -0
- package/esm/api/generate.d.ts +11 -0
- package/esm/api/generate.d.ts.map +1 -0
- package/esm/api/generate.js +24 -0
- package/esm/api/images.d.ts +55 -0
- package/esm/api/images.d.ts.map +1 -0
- package/esm/api/images.js +212 -0
- package/esm/api/kube.d.ts +13 -0
- package/esm/api/kube.d.ts.map +1 -0
- package/esm/api/kube.js +38 -0
- package/esm/api/manifests.d.ts +19 -0
- package/esm/api/manifests.d.ts.map +1 -0
- package/esm/api/manifests.js +60 -0
- package/esm/api/networks.d.ts +25 -0
- package/esm/api/networks.d.ts.map +1 -0
- package/esm/api/networks.js +95 -0
- package/esm/api/pods.d.ts +35 -0
- package/esm/api/pods.d.ts.map +1 -0
- package/esm/api/pods.js +120 -0
- package/esm/api/quadlets.d.ts +23 -0
- package/esm/api/quadlets.d.ts.map +1 -0
- package/esm/api/quadlets.js +56 -0
- package/esm/api/secrets.d.ts +17 -0
- package/esm/api/secrets.d.ts.map +1 -0
- package/esm/api/secrets.js +49 -0
- package/esm/api/system.d.ts +23 -0
- package/esm/api/system.d.ts.map +1 -0
- package/esm/api/system.js +98 -0
- package/esm/api/volumes.d.ts +23 -0
- package/esm/api/volumes.d.ts.map +1 -0
- package/esm/api/volumes.js +69 -0
- package/esm/client.d.ts +56 -0
- package/esm/client.d.ts.map +1 -0
- package/esm/client.js +63 -0
- package/esm/internal/query.d.ts +2 -0
- package/esm/internal/query.d.ts.map +1 -0
- package/esm/internal/query.js +24 -0
- package/esm/mod.d.ts +22 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +18 -0
- package/esm/package.json +3 -0
- package/esm/ssh_transport.d.ts +14 -0
- package/esm/ssh_transport.d.ts.map +1 -0
- package/esm/ssh_transport.js +85 -0
- package/esm/transport.d.ts +23 -0
- package/esm/transport.d.ts.map +1 -0
- package/esm/transport.js +112 -0
- package/esm/transport_core.d.ts +31 -0
- package/esm/transport_core.d.ts.map +1 -0
- package/esm/transport_core.js +75 -0
- package/esm/types/api.d.ts +61 -0
- package/esm/types/api.d.ts.map +1 -0
- package/esm/types/api.js +5 -0
- package/esm/types/errors.d.ts +21 -0
- package/esm/types/errors.d.ts.map +1 -0
- package/esm/types/errors.js +47 -0
- package/esm/types/openapi.d.ts +19552 -0
- package/esm/types/openapi.d.ts.map +1 -0
- package/esm/types/openapi.js +5 -0
- package/package.json +36 -0
- package/script/_dnt.polyfills.d.ts +7 -0
- package/script/_dnt.polyfills.d.ts.map +1 -0
- package/script/_dnt.polyfills.js +2 -0
- package/script/api/artifacts.d.ts +25 -0
- package/script/api/artifacts.d.ts.map +1 -0
- package/script/api/artifacts.js +93 -0
- package/script/api/containers.d.ts +71 -0
- package/script/api/containers.d.ts.map +1 -0
- package/script/api/containers.js +238 -0
- package/script/api/exec.d.ts +15 -0
- package/script/api/exec.d.ts.map +1 -0
- package/script/api/exec.js +49 -0
- package/script/api/generate.d.ts +11 -0
- package/script/api/generate.d.ts.map +1 -0
- package/script/api/generate.js +28 -0
- package/script/api/images.d.ts +55 -0
- package/script/api/images.d.ts.map +1 -0
- package/script/api/images.js +216 -0
- package/script/api/kube.d.ts +13 -0
- package/script/api/kube.d.ts.map +1 -0
- package/script/api/kube.js +42 -0
- package/script/api/manifests.d.ts +19 -0
- package/script/api/manifests.d.ts.map +1 -0
- package/script/api/manifests.js +64 -0
- package/script/api/networks.d.ts +25 -0
- package/script/api/networks.d.ts.map +1 -0
- package/script/api/networks.js +99 -0
- package/script/api/pods.d.ts +35 -0
- package/script/api/pods.d.ts.map +1 -0
- package/script/api/pods.js +124 -0
- package/script/api/quadlets.d.ts +23 -0
- package/script/api/quadlets.d.ts.map +1 -0
- package/script/api/quadlets.js +60 -0
- package/script/api/secrets.d.ts +17 -0
- package/script/api/secrets.d.ts.map +1 -0
- package/script/api/secrets.js +53 -0
- package/script/api/system.d.ts +23 -0
- package/script/api/system.d.ts.map +1 -0
- package/script/api/system.js +102 -0
- package/script/api/volumes.d.ts +23 -0
- package/script/api/volumes.d.ts.map +1 -0
- package/script/api/volumes.js +73 -0
- package/script/client.d.ts +56 -0
- package/script/client.d.ts.map +1 -0
- package/script/client.js +67 -0
- package/script/internal/query.d.ts +2 -0
- package/script/internal/query.d.ts.map +1 -0
- package/script/internal/query.js +27 -0
- package/script/mod.d.ts +22 -0
- package/script/mod.d.ts.map +1 -0
- package/script/mod.js +42 -0
- package/script/package.json +3 -0
- package/script/ssh_transport.d.ts +14 -0
- package/script/ssh_transport.d.ts.map +1 -0
- package/script/ssh_transport.js +121 -0
- package/script/transport.d.ts +23 -0
- package/script/transport.d.ts.map +1 -0
- package/script/transport.js +149 -0
- package/script/transport_core.d.ts +31 -0
- package/script/transport_core.d.ts.map +1 -0
- package/script/transport_core.js +78 -0
- package/script/types/api.d.ts +61 -0
- package/script/types/api.d.ts.map +1 -0
- package/script/types/api.js +6 -0
- package/script/types/errors.d.ts +21 -0
- package/script/types/errors.d.ts.map +1 -0
- package/script/types/errors.js +54 -0
- package/script/types/openapi.d.ts +19552 -0
- package/script/types/openapi.d.ts.map +1 -0
- package/script/types/openapi.js +6 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { createPodmanError, throwRawError } from "../types/errors.js";
|
|
2
|
+
import { buildQuery } from "../internal/query.js";
|
|
3
|
+
export class ContainersApi {
|
|
4
|
+
#t;
|
|
5
|
+
constructor(transport) {
|
|
6
|
+
this.#t = transport;
|
|
7
|
+
}
|
|
8
|
+
/** Create a new container from the given spec. */
|
|
9
|
+
async create(spec) {
|
|
10
|
+
const path = "/containers/create";
|
|
11
|
+
const { status, json } = await this.#t.request("POST", path, spec);
|
|
12
|
+
if (status !== 201)
|
|
13
|
+
throw createPodmanError(status, json, "POST", path);
|
|
14
|
+
return json;
|
|
15
|
+
}
|
|
16
|
+
/** Inspect a container. Returns `null` if the container is not found. */
|
|
17
|
+
async inspect(nameOrId) {
|
|
18
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/json`;
|
|
19
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
20
|
+
if (status === 404)
|
|
21
|
+
return null;
|
|
22
|
+
if (status !== 200)
|
|
23
|
+
throw createPodmanError(status, json, "GET", path);
|
|
24
|
+
return json;
|
|
25
|
+
}
|
|
26
|
+
/** List containers, optionally filtered by the given query. */
|
|
27
|
+
async list(query) {
|
|
28
|
+
const path = `/containers/json${buildQuery(query)}`;
|
|
29
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
30
|
+
if (status !== 200)
|
|
31
|
+
throw createPodmanError(status, json, "GET", path);
|
|
32
|
+
return (json ?? []);
|
|
33
|
+
}
|
|
34
|
+
/** Start a container. */
|
|
35
|
+
async start(nameOrId) {
|
|
36
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/start`;
|
|
37
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
38
|
+
if (status !== 204 && status !== 304)
|
|
39
|
+
throw createPodmanError(status, json, "POST", path);
|
|
40
|
+
}
|
|
41
|
+
/** Stop a container with an optional timeout. */
|
|
42
|
+
async stop(nameOrId, query) {
|
|
43
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/stop${buildQuery(query)}`;
|
|
44
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
45
|
+
if (status !== 204 && status !== 304)
|
|
46
|
+
throw createPodmanError(status, json, "POST", path);
|
|
47
|
+
}
|
|
48
|
+
/** Restart a container with an optional timeout. */
|
|
49
|
+
async restart(nameOrId, query) {
|
|
50
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/restart${buildQuery(query)}`;
|
|
51
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
52
|
+
if (status !== 204)
|
|
53
|
+
throw createPodmanError(status, json, "POST", path);
|
|
54
|
+
}
|
|
55
|
+
/** Send a signal to a container (default SIGTERM). */
|
|
56
|
+
async kill(nameOrId, query) {
|
|
57
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/kill${buildQuery(query)}`;
|
|
58
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
59
|
+
if (status !== 204)
|
|
60
|
+
throw createPodmanError(status, json, "POST", path);
|
|
61
|
+
}
|
|
62
|
+
/** Pause all processes in a container. */
|
|
63
|
+
async pause(nameOrId) {
|
|
64
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/pause`;
|
|
65
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
66
|
+
if (status !== 204)
|
|
67
|
+
throw createPodmanError(status, json, "POST", path);
|
|
68
|
+
}
|
|
69
|
+
/** Unpause all processes in a container. */
|
|
70
|
+
async unpause(nameOrId) {
|
|
71
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/unpause`;
|
|
72
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
73
|
+
if (status !== 204)
|
|
74
|
+
throw createPodmanError(status, json, "POST", path);
|
|
75
|
+
}
|
|
76
|
+
/** Remove a container. Use query options to force-remove or remove volumes. */
|
|
77
|
+
async remove(nameOrId, query) {
|
|
78
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}${buildQuery(query)}`;
|
|
79
|
+
const { status, json } = await this.#t.request("DELETE", path);
|
|
80
|
+
if (status !== 200 && status !== 204) {
|
|
81
|
+
throw createPodmanError(status, json, "DELETE", path);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** Stream container logs as raw bytes. */
|
|
85
|
+
async logs(nameOrId, query) {
|
|
86
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/logs${buildQuery(query)}`;
|
|
87
|
+
return await this.#t.requestStream("GET", path);
|
|
88
|
+
}
|
|
89
|
+
/** List processes running inside a container. */
|
|
90
|
+
async top(nameOrId, query) {
|
|
91
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/top${buildQuery(query)}`;
|
|
92
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
93
|
+
if (status !== 200)
|
|
94
|
+
throw createPodmanError(status, json, "GET", path);
|
|
95
|
+
return json;
|
|
96
|
+
}
|
|
97
|
+
/** Wait for a container to meet a given condition. Returns the exit code. */
|
|
98
|
+
async wait(nameOrId, query) {
|
|
99
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/wait${buildQuery(query)}`;
|
|
100
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
101
|
+
if (status !== 200)
|
|
102
|
+
throw createPodmanError(status, json, "POST", path);
|
|
103
|
+
return json;
|
|
104
|
+
}
|
|
105
|
+
/** Rename a container. */
|
|
106
|
+
async rename(nameOrId, newName) {
|
|
107
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/rename${buildQuery({ name: newName })}`;
|
|
108
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
109
|
+
if (status !== 204)
|
|
110
|
+
throw createPodmanError(status, json, "POST", path);
|
|
111
|
+
}
|
|
112
|
+
/** Resize a container's TTY dimensions. */
|
|
113
|
+
async resize(nameOrId, query) {
|
|
114
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/resize${buildQuery(query)}`;
|
|
115
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
116
|
+
if (status !== 200)
|
|
117
|
+
throw createPodmanError(status, json, "POST", path);
|
|
118
|
+
}
|
|
119
|
+
/** Export a container's filesystem as a tar stream. */
|
|
120
|
+
async export(nameOrId) {
|
|
121
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/export`;
|
|
122
|
+
return await this.#t.requestStream("GET", path);
|
|
123
|
+
}
|
|
124
|
+
/** Checkpoint a running container using CRIU. */
|
|
125
|
+
async checkpoint(nameOrId, query) {
|
|
126
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/checkpoint${buildQuery(query)}`;
|
|
127
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
128
|
+
if (status !== 200)
|
|
129
|
+
throw createPodmanError(status, json, "POST", path);
|
|
130
|
+
}
|
|
131
|
+
/** Restore a previously checkpointed container. */
|
|
132
|
+
async restore(nameOrId, query) {
|
|
133
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/restore${buildQuery(query)}`;
|
|
134
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
135
|
+
if (status !== 200)
|
|
136
|
+
throw createPodmanError(status, json, "POST", path);
|
|
137
|
+
}
|
|
138
|
+
/** Check if a container exists. Returns `true` on 204, `false` otherwise. */
|
|
139
|
+
async exists(nameOrId) {
|
|
140
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/exists`;
|
|
141
|
+
const { status } = await this.#t.request("GET", path);
|
|
142
|
+
return status === 204;
|
|
143
|
+
}
|
|
144
|
+
/** Remove stopped containers. Returns a list of pruned containers. */
|
|
145
|
+
async prune(query) {
|
|
146
|
+
const path = `/containers/prune${buildQuery(query)}`;
|
|
147
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
148
|
+
if (status !== 200)
|
|
149
|
+
throw createPodmanError(status, json, "POST", path);
|
|
150
|
+
return (json ?? []);
|
|
151
|
+
}
|
|
152
|
+
/** Stream resource usage statistics for a container. */
|
|
153
|
+
async stats(nameOrId, query) {
|
|
154
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/stats${buildQuery(query)}`;
|
|
155
|
+
return await this.#t.requestStream("GET", path);
|
|
156
|
+
}
|
|
157
|
+
/** Attach to a container and stream its output. */
|
|
158
|
+
async attach(nameOrId, query) {
|
|
159
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/attach${buildQuery(query)}`;
|
|
160
|
+
return await this.#t.requestStream("POST", path);
|
|
161
|
+
}
|
|
162
|
+
/** Download a file or directory from a container as a tar archive stream. */
|
|
163
|
+
async getArchive(nameOrId, query) {
|
|
164
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/archive${buildQuery(query)}`;
|
|
165
|
+
return await this.#t.requestStream("GET", path);
|
|
166
|
+
}
|
|
167
|
+
/** Upload a tar archive stream into a container at the specified path. */
|
|
168
|
+
async putArchive(nameOrId, body, query) {
|
|
169
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/archive${buildQuery(query)}`;
|
|
170
|
+
const res = await this.#t.requestRaw("PUT", path, body, {
|
|
171
|
+
"Content-Type": "application/x-tar",
|
|
172
|
+
});
|
|
173
|
+
if (res.status !== 200)
|
|
174
|
+
await throwRawError(res, "PUT", path);
|
|
175
|
+
}
|
|
176
|
+
/** Run a container health check and return the results. */
|
|
177
|
+
async healthcheck(nameOrId) {
|
|
178
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/healthcheck`;
|
|
179
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
180
|
+
if (status !== 200)
|
|
181
|
+
throw createPodmanError(status, json, "GET", path);
|
|
182
|
+
return json;
|
|
183
|
+
}
|
|
184
|
+
/** Initialize a container, preparing it to be started. */
|
|
185
|
+
async init(nameOrId) {
|
|
186
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/init`;
|
|
187
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
188
|
+
if (status !== 204 && status !== 304)
|
|
189
|
+
throw createPodmanError(status, json, "POST", path);
|
|
190
|
+
}
|
|
191
|
+
/** Update a container's resource limits. */
|
|
192
|
+
async update(nameOrId, resources, query) {
|
|
193
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/update${buildQuery(query)}`;
|
|
194
|
+
const { status, json } = await this.#t.request("POST", path, resources);
|
|
195
|
+
if (status !== 201)
|
|
196
|
+
throw createPodmanError(status, json, "POST", path);
|
|
197
|
+
}
|
|
198
|
+
/** List filesystem changes made inside a container. */
|
|
199
|
+
async changes(nameOrId, query) {
|
|
200
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/changes${buildQuery(query)}`;
|
|
201
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
202
|
+
if (status !== 200)
|
|
203
|
+
throw createPodmanError(status, json, "GET", path);
|
|
204
|
+
return (json ?? []);
|
|
205
|
+
}
|
|
206
|
+
/** Mount a container's filesystem. Returns the mount path. */
|
|
207
|
+
async mount(nameOrId) {
|
|
208
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/mount`;
|
|
209
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
210
|
+
if (status !== 200)
|
|
211
|
+
throw createPodmanError(status, json, "POST", path);
|
|
212
|
+
return json;
|
|
213
|
+
}
|
|
214
|
+
/** Unmount a container's filesystem. */
|
|
215
|
+
async unmount(nameOrId) {
|
|
216
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/unmount`;
|
|
217
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
218
|
+
if (status !== 204)
|
|
219
|
+
throw createPodmanError(status, json, "POST", path);
|
|
220
|
+
}
|
|
221
|
+
/** List all mounted containers and their mount points. */
|
|
222
|
+
async showMounted() {
|
|
223
|
+
const path = "/containers/showmounted";
|
|
224
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
225
|
+
if (status !== 200)
|
|
226
|
+
throw createPodmanError(status, json, "GET", path);
|
|
227
|
+
return json;
|
|
228
|
+
}
|
|
229
|
+
/** Stream resource usage statistics for all containers. */
|
|
230
|
+
async statsAll(query) {
|
|
231
|
+
const path = `/containers/stats${buildQuery(query)}`;
|
|
232
|
+
return await this.#t.requestStream("GET", path);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { ExecCreateConfig, ExecResizeQuery, ExecStartConfig, InspectExecSession } from "../types/api.js";
|
|
3
|
+
export declare class ExecApi {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(transport: Transport);
|
|
6
|
+
/** Create an exec session inside a container. Returns the exec session ID. */
|
|
7
|
+
create(nameOrId: string, config: ExecCreateConfig): Promise<string>;
|
|
8
|
+
/** Start an exec session and stream its output. */
|
|
9
|
+
start(id: string, config?: ExecStartConfig): Promise<ReadableStream<Uint8Array>>;
|
|
10
|
+
/** Inspect an exec session. */
|
|
11
|
+
inspect(id: string): Promise<InspectExecSession>;
|
|
12
|
+
/** Resize an exec session's TTY dimensions. */
|
|
13
|
+
resize(id: string, query: ExecResizeQuery): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=exec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/api/exec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAEzB,qBAAa,OAAO;;gBAEN,SAAS,EAAE,SAAS;IAIhC,8EAA8E;IACxE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAUzE,mDAAmD;IAC7C,KAAK,CACT,EAAE,EAAE,MAAM,EACV,MAAM,CAAC,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAetC,+BAA+B;IACzB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAOtD,+CAA+C;IACzC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAMhE"}
|
package/esm/api/exec.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createPodmanError, throwRawError } from "../types/errors.js";
|
|
2
|
+
import { buildQuery } from "../internal/query.js";
|
|
3
|
+
export class ExecApi {
|
|
4
|
+
#t;
|
|
5
|
+
constructor(transport) {
|
|
6
|
+
this.#t = transport;
|
|
7
|
+
}
|
|
8
|
+
/** Create an exec session inside a container. Returns the exec session ID. */
|
|
9
|
+
async create(nameOrId, config) {
|
|
10
|
+
const path = `/containers/${encodeURIComponent(nameOrId)}/exec`;
|
|
11
|
+
const res = await this.#t.requestRaw("POST", path, JSON.stringify(config), {
|
|
12
|
+
"Content-Type": "application/json",
|
|
13
|
+
});
|
|
14
|
+
if (res.status !== 201)
|
|
15
|
+
await throwRawError(res, "POST", path);
|
|
16
|
+
const result = await res.json();
|
|
17
|
+
return result.Id;
|
|
18
|
+
}
|
|
19
|
+
/** Start an exec session and stream its output. */
|
|
20
|
+
async start(id, config) {
|
|
21
|
+
const path = `/exec/${encodeURIComponent(id)}/start`;
|
|
22
|
+
const res = await this.#t.requestRaw("POST", path, JSON.stringify(config ?? {}), { "Content-Type": "application/json" });
|
|
23
|
+
if (res.status >= 400)
|
|
24
|
+
await throwRawError(res, "POST", path);
|
|
25
|
+
if (!res.body) {
|
|
26
|
+
throw new Error(`No response body for POST ${path}`);
|
|
27
|
+
}
|
|
28
|
+
return res.body;
|
|
29
|
+
}
|
|
30
|
+
/** Inspect an exec session. */
|
|
31
|
+
async inspect(id) {
|
|
32
|
+
const path = `/exec/${encodeURIComponent(id)}/json`;
|
|
33
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
34
|
+
if (status !== 200)
|
|
35
|
+
throw createPodmanError(status, json, "GET", path);
|
|
36
|
+
return json;
|
|
37
|
+
}
|
|
38
|
+
/** Resize an exec session's TTY dimensions. */
|
|
39
|
+
async resize(id, query) {
|
|
40
|
+
const path = `/exec/${encodeURIComponent(id)}/resize${buildQuery(query)}`;
|
|
41
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
42
|
+
if (status !== 201)
|
|
43
|
+
throw createPodmanError(status, json, "POST", path);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { GenerateKubeQuery, GenerateSystemdQuery } from "../types/api.js";
|
|
3
|
+
export declare class GenerateApi {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(transport: Transport);
|
|
6
|
+
/** Generate systemd unit files for a container or pod. Returns a map of unit name to content. */
|
|
7
|
+
systemd(nameOrId: string, query?: GenerateSystemdQuery): Promise<Record<string, string>>;
|
|
8
|
+
/** Generate a Kubernetes YAML manifest for a container or pod. */
|
|
9
|
+
kube(query: GenerateKubeQuery): Promise<string>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/api/generate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAEzB,qBAAa,WAAW;;gBAEV,SAAS,EAAE,SAAS;IAIhC,iGAAiG;IAC3F,OAAO,CACX,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,oBAAoB,GAC3B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAQlC,kEAAkE;IAC5D,IAAI,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;CAMtD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createPodmanError, throwRawError } from "../types/errors.js";
|
|
2
|
+
import { buildQuery } from "../internal/query.js";
|
|
3
|
+
export class GenerateApi {
|
|
4
|
+
#t;
|
|
5
|
+
constructor(transport) {
|
|
6
|
+
this.#t = transport;
|
|
7
|
+
}
|
|
8
|
+
/** Generate systemd unit files for a container or pod. Returns a map of unit name to content. */
|
|
9
|
+
async systemd(nameOrId, query) {
|
|
10
|
+
const path = `/generate/${encodeURIComponent(nameOrId)}/systemd${buildQuery(query)}`;
|
|
11
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
12
|
+
if (status !== 200)
|
|
13
|
+
throw createPodmanError(status, json, "GET", path);
|
|
14
|
+
return json;
|
|
15
|
+
}
|
|
16
|
+
/** Generate a Kubernetes YAML manifest for a container or pod. */
|
|
17
|
+
async kube(query) {
|
|
18
|
+
const path = `/generate/kube${buildQuery(query)}`;
|
|
19
|
+
const res = await this.#t.requestRaw("GET", path);
|
|
20
|
+
if (res.status >= 400)
|
|
21
|
+
await throwRawError(res, "GET", path);
|
|
22
|
+
return await res.text();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { ContainerChange, ImageBuildQuery, ImageRemoveAllQuery, ImageCommitQuery, ImageChangesQuery, ImageExportQuery, ImageHistory, ImageImportQuery, ImageInspect, ImageListQuery, ImageLoadReport, ImagePruneQuery, ImagePruneReport, ImagePullQuery, ImagePushQuery, ImageRemoveQuery, ImageRemoveReport, ImageScpQuery, ImageSearchQuery, ImageSearchResult, ImageSummary, ImageTreeQuery, ScpReport, ImageTreeReport, LibpodImagesPullReport, LocalBuildQuery, LocalImagesQuery } from "../types/api.js";
|
|
3
|
+
export declare class ImagesApi {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(transport: Transport);
|
|
6
|
+
/** List images, optionally filtered by the given query. */
|
|
7
|
+
list(query?: ImageListQuery): Promise<ImageSummary[]>;
|
|
8
|
+
/** Inspect an image. Returns `null` if the image is not found. */
|
|
9
|
+
inspect(nameOrId: string): Promise<ImageInspect | null>;
|
|
10
|
+
/** Pull an image from a registry. */
|
|
11
|
+
pull(query: ImagePullQuery): Promise<LibpodImagesPullReport>;
|
|
12
|
+
/** Remove an image. Returns a report of untagged and deleted layers. */
|
|
13
|
+
remove(nameOrId: string, query?: ImageRemoveQuery): Promise<ImageRemoveReport>;
|
|
14
|
+
/** Add a repository tag to an image. */
|
|
15
|
+
tag(nameOrId: string, repo: string, tag?: string): Promise<void>;
|
|
16
|
+
/** Remove a repository tag from an image. */
|
|
17
|
+
untag(nameOrId: string, repo: string, tag?: string): Promise<void>;
|
|
18
|
+
/** Search registries for images matching the given query. */
|
|
19
|
+
search(query: ImageSearchQuery): Promise<ImageSearchResult[]>;
|
|
20
|
+
/** Return the history of an image's layers. */
|
|
21
|
+
history(nameOrId: string): Promise<ImageHistory[]>;
|
|
22
|
+
/** Push an image to a registry. */
|
|
23
|
+
push(nameOrId: string, query?: ImagePushQuery): Promise<void>;
|
|
24
|
+
/** Import an image from a tar archive stream. Returns the new image ID. */
|
|
25
|
+
import(body: ReadableStream<Uint8Array>, query?: ImageImportQuery): Promise<string>;
|
|
26
|
+
/** Export an image as a tar archive stream. */
|
|
27
|
+
export(nameOrId: string): Promise<ReadableStream<Uint8Array>>;
|
|
28
|
+
/** Remove unused images. Returns a list of pruned images. */
|
|
29
|
+
prune(query?: ImagePruneQuery): Promise<ImagePruneReport[]>;
|
|
30
|
+
/** Build an image from a build context tar stream. Returns the build output stream. */
|
|
31
|
+
build(body: ReadableStream<Uint8Array>, query?: ImageBuildQuery): Promise<ReadableStream<Uint8Array>>;
|
|
32
|
+
/** Check if an image exists. Returns `true` on 204, `false` otherwise. */
|
|
33
|
+
exists(nameOrId: string): Promise<boolean>;
|
|
34
|
+
/** Create a new image from a container's changes. */
|
|
35
|
+
commit(query: ImageCommitQuery): Promise<void>;
|
|
36
|
+
/** Load images from a tar archive. */
|
|
37
|
+
load(body: ReadableStream<Uint8Array>): Promise<ImageLoadReport>;
|
|
38
|
+
/** Get a tree representation of an image's layers. */
|
|
39
|
+
tree(nameOrId: string, query?: ImageTreeQuery): Promise<ImageTreeReport>;
|
|
40
|
+
/** List filesystem changes in an image. */
|
|
41
|
+
changes(nameOrId: string, query?: ImageChangesQuery): Promise<ContainerChange[]>;
|
|
42
|
+
/** Resolve a short image name to a full reference. */
|
|
43
|
+
resolve(nameOrId: string): Promise<string>;
|
|
44
|
+
/** Export multiple images as a single tar archive stream. */
|
|
45
|
+
exportMultiple(query?: ImageExportQuery): Promise<ReadableStream<Uint8Array>>;
|
|
46
|
+
/** Remove one or more images. */
|
|
47
|
+
removeAll(query?: ImageRemoveAllQuery): Promise<ImageRemoveReport>;
|
|
48
|
+
/** Copy an image between hosts via SCP. */
|
|
49
|
+
scp(nameOrId: string, query?: ImageScpQuery): Promise<ScpReport>;
|
|
50
|
+
/** Load an image from a file path on the Podman server's filesystem. */
|
|
51
|
+
loadLocal(query: LocalImagesQuery): Promise<ImageLoadReport>;
|
|
52
|
+
/** Build an image from a local directory on the Podman server's filesystem. Returns the build output stream. */
|
|
53
|
+
buildLocal(query: LocalBuildQuery): Promise<ReadableStream<Uint8Array>>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=images.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../src/api/images.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { createPodmanError, throwRawError } from "../types/errors.js";
|
|
2
|
+
import { buildQuery } from "../internal/query.js";
|
|
3
|
+
export class ImagesApi {
|
|
4
|
+
#t;
|
|
5
|
+
constructor(transport) {
|
|
6
|
+
this.#t = transport;
|
|
7
|
+
}
|
|
8
|
+
/** List images, optionally filtered by the given query. */
|
|
9
|
+
async list(query) {
|
|
10
|
+
const path = `/images/json${buildQuery(query)}`;
|
|
11
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
12
|
+
if (status !== 200)
|
|
13
|
+
throw createPodmanError(status, json, "GET", path);
|
|
14
|
+
return (json ?? []);
|
|
15
|
+
}
|
|
16
|
+
/** Inspect an image. Returns `null` if the image is not found. */
|
|
17
|
+
async inspect(nameOrId) {
|
|
18
|
+
const path = `/images/${encodeURIComponent(nameOrId)}/json`;
|
|
19
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
20
|
+
if (status === 404)
|
|
21
|
+
return null;
|
|
22
|
+
if (status !== 200)
|
|
23
|
+
throw createPodmanError(status, json, "GET", path);
|
|
24
|
+
return json;
|
|
25
|
+
}
|
|
26
|
+
/** Pull an image from a registry. */
|
|
27
|
+
async pull(query) {
|
|
28
|
+
const path = `/images/pull${buildQuery(query)}`;
|
|
29
|
+
const headers = {};
|
|
30
|
+
const authHeader = this.#t.getAuthHeader();
|
|
31
|
+
if (authHeader)
|
|
32
|
+
headers["X-Registry-Auth"] = authHeader;
|
|
33
|
+
const res = await this.#t.requestRaw("POST", path, undefined, headers);
|
|
34
|
+
if (res.status !== 200)
|
|
35
|
+
await throwRawError(res, "POST", path);
|
|
36
|
+
return (await res.json());
|
|
37
|
+
}
|
|
38
|
+
/** Remove an image. Returns a report of untagged and deleted layers. */
|
|
39
|
+
async remove(nameOrId, query) {
|
|
40
|
+
const path = `/images/${encodeURIComponent(nameOrId)}${buildQuery(query)}`;
|
|
41
|
+
const { status, json } = await this.#t.request("DELETE", path);
|
|
42
|
+
if (status !== 200)
|
|
43
|
+
throw createPodmanError(status, json, "DELETE", path);
|
|
44
|
+
return json;
|
|
45
|
+
}
|
|
46
|
+
/** Add a repository tag to an image. */
|
|
47
|
+
async tag(nameOrId, repo, tag) {
|
|
48
|
+
const path = `/images/${encodeURIComponent(nameOrId)}/tag${buildQuery({ repo, tag })}`;
|
|
49
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
50
|
+
if (status !== 201)
|
|
51
|
+
throw createPodmanError(status, json, "POST", path);
|
|
52
|
+
}
|
|
53
|
+
/** Remove a repository tag from an image. */
|
|
54
|
+
async untag(nameOrId, repo, tag) {
|
|
55
|
+
const path = `/images/${encodeURIComponent(nameOrId)}/untag${buildQuery({ repo, tag })}`;
|
|
56
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
57
|
+
if (status !== 201)
|
|
58
|
+
throw createPodmanError(status, json, "POST", path);
|
|
59
|
+
}
|
|
60
|
+
/** Search registries for images matching the given query. */
|
|
61
|
+
async search(query) {
|
|
62
|
+
const path = `/images/search${buildQuery(query)}`;
|
|
63
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
64
|
+
if (status !== 200)
|
|
65
|
+
throw createPodmanError(status, json, "GET", path);
|
|
66
|
+
return (json ?? []);
|
|
67
|
+
}
|
|
68
|
+
/** Return the history of an image's layers. */
|
|
69
|
+
async history(nameOrId) {
|
|
70
|
+
const path = `/images/${encodeURIComponent(nameOrId)}/history`;
|
|
71
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
72
|
+
if (status !== 200)
|
|
73
|
+
throw createPodmanError(status, json, "GET", path);
|
|
74
|
+
return (json ?? []);
|
|
75
|
+
}
|
|
76
|
+
/** Push an image to a registry. */
|
|
77
|
+
async push(nameOrId, query) {
|
|
78
|
+
const path = `/images/${encodeURIComponent(nameOrId)}/push${buildQuery(query)}`;
|
|
79
|
+
const headers = {};
|
|
80
|
+
const authHeader = this.#t.getAuthHeader();
|
|
81
|
+
if (authHeader)
|
|
82
|
+
headers["X-Registry-Auth"] = authHeader;
|
|
83
|
+
const res = await this.#t.requestRaw("POST", path, undefined, headers);
|
|
84
|
+
if (res.status !== 200)
|
|
85
|
+
await throwRawError(res, "POST", path);
|
|
86
|
+
await res.body?.cancel();
|
|
87
|
+
}
|
|
88
|
+
/** Import an image from a tar archive stream. Returns the new image ID. */
|
|
89
|
+
async import(body, query) {
|
|
90
|
+
const path = `/images/import${buildQuery(query)}`;
|
|
91
|
+
const res = await this.#t.requestRaw("POST", path, body, {
|
|
92
|
+
"Content-Type": "application/x-tar",
|
|
93
|
+
});
|
|
94
|
+
if (res.status !== 200)
|
|
95
|
+
await throwRawError(res, "POST", path);
|
|
96
|
+
const result = await res.json();
|
|
97
|
+
return result.Id;
|
|
98
|
+
}
|
|
99
|
+
/** Export an image as a tar archive stream. */
|
|
100
|
+
async export(nameOrId) {
|
|
101
|
+
const path = `/images/${encodeURIComponent(nameOrId)}/get`;
|
|
102
|
+
return await this.#t.requestStream("GET", path);
|
|
103
|
+
}
|
|
104
|
+
/** Remove unused images. Returns a list of pruned images. */
|
|
105
|
+
async prune(query) {
|
|
106
|
+
const path = `/images/prune${buildQuery(query)}`;
|
|
107
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
108
|
+
if (status !== 200)
|
|
109
|
+
throw createPodmanError(status, json, "POST", path);
|
|
110
|
+
return (json ?? []);
|
|
111
|
+
}
|
|
112
|
+
/** Build an image from a build context tar stream. Returns the build output stream. */
|
|
113
|
+
async build(body, query) {
|
|
114
|
+
const path = `/build${buildQuery(query)}`;
|
|
115
|
+
const res = await this.#t.requestRaw("POST", path, body, {
|
|
116
|
+
"Content-Type": "application/x-tar",
|
|
117
|
+
});
|
|
118
|
+
if (res.status >= 400)
|
|
119
|
+
await throwRawError(res, "POST", path);
|
|
120
|
+
if (!res.body) {
|
|
121
|
+
throw new Error("No response body for build");
|
|
122
|
+
}
|
|
123
|
+
return res.body;
|
|
124
|
+
}
|
|
125
|
+
/** Check if an image exists. Returns `true` on 204, `false` otherwise. */
|
|
126
|
+
async exists(nameOrId) {
|
|
127
|
+
const path = `/images/${encodeURIComponent(nameOrId)}/exists`;
|
|
128
|
+
const { status } = await this.#t.request("GET", path);
|
|
129
|
+
return status === 204;
|
|
130
|
+
}
|
|
131
|
+
/** Create a new image from a container's changes. */
|
|
132
|
+
async commit(query) {
|
|
133
|
+
const path = `/commit${buildQuery(query)}`;
|
|
134
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
135
|
+
if (status !== 201)
|
|
136
|
+
throw createPodmanError(status, json, "POST", path);
|
|
137
|
+
}
|
|
138
|
+
/** Load images from a tar archive. */
|
|
139
|
+
async load(body) {
|
|
140
|
+
const path = "/images/load";
|
|
141
|
+
const res = await this.#t.requestRaw("POST", path, body, {
|
|
142
|
+
"Content-Type": "application/x-tar",
|
|
143
|
+
});
|
|
144
|
+
if (res.status !== 200)
|
|
145
|
+
await throwRawError(res, "POST", path);
|
|
146
|
+
return (await res.json());
|
|
147
|
+
}
|
|
148
|
+
/** Get a tree representation of an image's layers. */
|
|
149
|
+
async tree(nameOrId, query) {
|
|
150
|
+
const path = `/images/${encodeURIComponent(nameOrId)}/tree${buildQuery(query)}`;
|
|
151
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
152
|
+
if (status !== 200)
|
|
153
|
+
throw createPodmanError(status, json, "GET", path);
|
|
154
|
+
return json;
|
|
155
|
+
}
|
|
156
|
+
/** List filesystem changes in an image. */
|
|
157
|
+
async changes(nameOrId, query) {
|
|
158
|
+
const path = `/images/${encodeURIComponent(nameOrId)}/changes${buildQuery(query)}`;
|
|
159
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
160
|
+
if (status !== 200)
|
|
161
|
+
throw createPodmanError(status, json, "GET", path);
|
|
162
|
+
return (json ?? []);
|
|
163
|
+
}
|
|
164
|
+
/** Resolve a short image name to a full reference. */
|
|
165
|
+
async resolve(nameOrId) {
|
|
166
|
+
const path = `/images/${encodeURIComponent(nameOrId)}/resolve`;
|
|
167
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
168
|
+
if (status !== 200)
|
|
169
|
+
throw createPodmanError(status, json, "GET", path);
|
|
170
|
+
return json;
|
|
171
|
+
}
|
|
172
|
+
/** Export multiple images as a single tar archive stream. */
|
|
173
|
+
async exportMultiple(query) {
|
|
174
|
+
const path = `/images/export${buildQuery(query)}`;
|
|
175
|
+
return await this.#t.requestStream("GET", path);
|
|
176
|
+
}
|
|
177
|
+
/** Remove one or more images. */
|
|
178
|
+
async removeAll(query) {
|
|
179
|
+
const path = `/images${buildQuery(query)}`;
|
|
180
|
+
const { status, json } = await this.#t.request("DELETE", path);
|
|
181
|
+
if (status !== 200)
|
|
182
|
+
throw createPodmanError(status, json, "DELETE", path);
|
|
183
|
+
return json;
|
|
184
|
+
}
|
|
185
|
+
/** Copy an image between hosts via SCP. */
|
|
186
|
+
async scp(nameOrId, query) {
|
|
187
|
+
const path = `/images/scp/${encodeURIComponent(nameOrId)}${buildQuery(query)}`;
|
|
188
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
189
|
+
if (status !== 200)
|
|
190
|
+
throw createPodmanError(status, json, "POST", path);
|
|
191
|
+
return json;
|
|
192
|
+
}
|
|
193
|
+
/** Load an image from a file path on the Podman server's filesystem. */
|
|
194
|
+
async loadLocal(query) {
|
|
195
|
+
const path = `/local/images/load${buildQuery(query)}`;
|
|
196
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
197
|
+
if (status !== 200)
|
|
198
|
+
throw createPodmanError(status, json, "POST", path);
|
|
199
|
+
return json;
|
|
200
|
+
}
|
|
201
|
+
/** Build an image from a local directory on the Podman server's filesystem. Returns the build output stream. */
|
|
202
|
+
async buildLocal(query) {
|
|
203
|
+
const path = `/local/build${buildQuery(query)}`;
|
|
204
|
+
const res = await this.#t.requestRaw("POST", path);
|
|
205
|
+
if (res.status >= 400)
|
|
206
|
+
await throwRawError(res, "POST", path);
|
|
207
|
+
if (!res.body) {
|
|
208
|
+
throw new Error("No response body for build");
|
|
209
|
+
}
|
|
210
|
+
return res.body;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { KubeApplyQuery, PlayKubeDownQuery, PlayKubeQuery, PlayKubeReport } from "../types/api.js";
|
|
3
|
+
export declare class KubeApi {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(transport: Transport);
|
|
6
|
+
/** Play a Kubernetes YAML file. Body can be YAML string or tar stream. */
|
|
7
|
+
play(body: ReadableStream<Uint8Array> | string, query?: PlayKubeQuery): Promise<PlayKubeReport>;
|
|
8
|
+
/** Tear down pods/resources created by play kube. */
|
|
9
|
+
down(query?: PlayKubeDownQuery): Promise<PlayKubeReport>;
|
|
10
|
+
/** Apply Kubernetes YAML to the Podman system. */
|
|
11
|
+
apply(body: ReadableStream<Uint8Array> | string, query?: KubeApplyQuery): Promise<string>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=kube.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kube.d.ts","sourceRoot":"","sources":["../../src/api/kube.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,cAAc,EACf,MAAM,iBAAiB,CAAC;AAEzB,qBAAa,OAAO;;gBAEN,SAAS,EAAE,SAAS;IAIhC,0EAA0E;IACpE,IAAI,CACR,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,EACzC,KAAK,CAAC,EAAE,aAAa,GACpB,OAAO,CAAC,cAAc,CAAC;IAW1B,qDAAqD;IAC/C,IAAI,CAAC,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC;IAO9D,kDAAkD;IAC5C,KAAK,CACT,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,EACzC,KAAK,CAAC,EAAE,cAAc,GACrB,OAAO,CAAC,MAAM,CAAC;CAUnB"}
|