@appthrust/kest 0.1.0 → 0.1.1
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/package.json +1 -1
- package/ts/actions/apply.ts +3 -1
- package/ts/kubectl/index.ts +18 -5
package/package.json
CHANGED
package/ts/actions/apply.ts
CHANGED
|
@@ -17,7 +17,9 @@ export const apply = {
|
|
|
17
17
|
await kubectl.apply(result.value);
|
|
18
18
|
return {
|
|
19
19
|
async revert() {
|
|
20
|
-
await kubectl.delete(result.value.kind, result.value.metadata.name
|
|
20
|
+
await kubectl.delete(result.value.kind, result.value.metadata.name, {
|
|
21
|
+
ignoreNotFound: true,
|
|
22
|
+
});
|
|
21
23
|
},
|
|
22
24
|
output: undefined,
|
|
23
25
|
};
|
package/ts/kubectl/index.ts
CHANGED
|
@@ -126,17 +126,26 @@ export interface Kubectl {
|
|
|
126
126
|
*
|
|
127
127
|
* @param resource - The resource type (e.g., "configmap", "namespace")
|
|
128
128
|
* @param name - The name of the resource to delete
|
|
129
|
-
* @param
|
|
129
|
+
* @param options - Optional delete options (ignoreNotFound, context)
|
|
130
130
|
* @returns The trimmed stdout from kubectl (e.g., "configmap \"my-config\" deleted")
|
|
131
131
|
* @throws Error if kubectl exits with non-zero code
|
|
132
132
|
*/
|
|
133
133
|
delete(
|
|
134
134
|
resource: string,
|
|
135
135
|
name: string,
|
|
136
|
-
|
|
136
|
+
options?: KubectlDeleteOptions
|
|
137
137
|
): Promise<string>;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
export interface KubectlDeleteOptions {
|
|
141
|
+
/**
|
|
142
|
+
* If true, adds `--ignore-not-found` so that deleting a resource
|
|
143
|
+
* that does not exist succeeds silently instead of failing.
|
|
144
|
+
*/
|
|
145
|
+
readonly ignoreNotFound?: undefined | boolean;
|
|
146
|
+
readonly context?: undefined | KubectlContext;
|
|
147
|
+
}
|
|
148
|
+
|
|
140
149
|
export class RealKubectl implements Kubectl {
|
|
141
150
|
private readonly recorder: Recorder;
|
|
142
151
|
private readonly cwd: undefined | string;
|
|
@@ -260,13 +269,17 @@ export class RealKubectl implements Kubectl {
|
|
|
260
269
|
async delete(
|
|
261
270
|
resource: string,
|
|
262
271
|
name: string,
|
|
263
|
-
|
|
272
|
+
options?: KubectlDeleteOptions
|
|
264
273
|
): Promise<string> {
|
|
274
|
+
const args: [string, ...Array<string>] = ["delete", `${resource}/${name}`];
|
|
275
|
+
if (options?.ignoreNotFound) {
|
|
276
|
+
args.push("--ignore-not-found");
|
|
277
|
+
}
|
|
265
278
|
return await this.runKubectl({
|
|
266
|
-
args
|
|
279
|
+
args,
|
|
267
280
|
stdoutLanguage: "text",
|
|
268
281
|
stderrLanguage: "text",
|
|
269
|
-
overrideContext: context,
|
|
282
|
+
overrideContext: options?.context,
|
|
270
283
|
});
|
|
271
284
|
}
|
|
272
285
|
|