@nexusgpu/repterm-plugin-kubectl 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 +277 -0
- package/dist/index.d.ts +314 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +544 -0
- package/dist/matchers.d.ts +113 -0
- package/dist/matchers.d.ts.map +1 -0
- package/dist/matchers.js +527 -0
- package/dist/plugin-kubectl/examples/00-simple-demo.d.ts +10 -0
- package/dist/plugin-kubectl/examples/00-simple-demo.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/00-simple-demo.js +51 -0
- package/dist/plugin-kubectl/examples/01-basic-kubectl.d.ts +13 -0
- package/dist/plugin-kubectl/examples/01-basic-kubectl.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/01-basic-kubectl.js +86 -0
- package/dist/plugin-kubectl/examples/02-debugging.d.ts +13 -0
- package/dist/plugin-kubectl/examples/02-debugging.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/02-debugging.js +80 -0
- package/dist/plugin-kubectl/examples/03-resource-management.d.ts +13 -0
- package/dist/plugin-kubectl/examples/03-resource-management.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/03-resource-management.js +134 -0
- package/dist/plugin-kubectl/examples/04-rollout.d.ts +13 -0
- package/dist/plugin-kubectl/examples/04-rollout.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/04-rollout.js +122 -0
- package/dist/plugin-kubectl/examples/05-matchers.d.ts +15 -0
- package/dist/plugin-kubectl/examples/05-matchers.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/05-matchers.js +138 -0
- package/dist/plugin-kubectl/examples/06-advanced.d.ts +14 -0
- package/dist/plugin-kubectl/examples/06-advanced.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/06-advanced.js +140 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/00-prerequisites.d.ts +14 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/00-prerequisites.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/00-prerequisites.js +66 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/01-workload-allocation.d.ts +14 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/01-workload-allocation.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/01-workload-allocation.js +145 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/02-annotation-mode.d.ts +13 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/02-annotation-mode.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/02-annotation-mode.js +123 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/03-insufficient.d.ts +17 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/03-insufficient.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/03-insufficient.js +96 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/04-release.d.ts +13 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/04-release.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/04-release.js +117 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/05-multi-workload-shared-gpu.d.ts +14 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/05-multi-workload-shared-gpu.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/05-multi-workload-shared-gpu.js +145 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/06-workload-resource-resize.d.ts +14 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/06-workload-resource-resize.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/06-workload-resource-resize.js +235 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/07-workload-worker-pod-generation.d.ts +15 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/07-workload-worker-pod-generation.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/07-workload-worker-pod-generation.js +146 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/08-workload-replicas-scale.d.ts +13 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/08-workload-replicas-scale.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/08-workload-replicas-scale.js +141 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/09-gpu-remote-invocation.d.ts +15 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/09-gpu-remote-invocation.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/09-gpu-remote-invocation.js +256 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/_config.d.ts +71 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/_config.d.ts.map +1 -0
- package/dist/plugin-kubectl/examples/tensor-fusion/_config.js +159 -0
- package/dist/plugin-kubectl/src/index.d.ts +314 -0
- package/dist/plugin-kubectl/src/index.d.ts.map +1 -0
- package/dist/plugin-kubectl/src/index.js +545 -0
- package/dist/plugin-kubectl/src/matchers.d.ts +113 -0
- package/dist/plugin-kubectl/src/matchers.d.ts.map +1 -0
- package/dist/plugin-kubectl/src/matchers.js +527 -0
- package/dist/plugin-kubectl/src/result.d.ts +80 -0
- package/dist/plugin-kubectl/src/result.d.ts.map +1 -0
- package/dist/plugin-kubectl/src/result.js +134 -0
- package/dist/repterm/src/api/describe.d.ts +18 -0
- package/dist/repterm/src/api/describe.d.ts.map +1 -0
- package/dist/repterm/src/api/describe.js +32 -0
- package/dist/repterm/src/api/expect.d.ts +43 -0
- package/dist/repterm/src/api/expect.d.ts.map +1 -0
- package/dist/repterm/src/api/expect.js +166 -0
- package/dist/repterm/src/api/hooks.d.ts +178 -0
- package/dist/repterm/src/api/hooks.d.ts.map +1 -0
- package/dist/repterm/src/api/hooks.js +230 -0
- package/dist/repterm/src/api/steps.d.ts +45 -0
- package/dist/repterm/src/api/steps.d.ts.map +1 -0
- package/dist/repterm/src/api/steps.js +105 -0
- package/dist/repterm/src/api/test.d.ts +101 -0
- package/dist/repterm/src/api/test.d.ts.map +1 -0
- package/dist/repterm/src/api/test.js +206 -0
- package/dist/repterm/src/index.d.ts +15 -0
- package/dist/repterm/src/index.d.ts.map +1 -0
- package/dist/repterm/src/index.js +23 -0
- package/dist/repterm/src/plugin/index.d.ts +47 -0
- package/dist/repterm/src/plugin/index.d.ts.map +1 -0
- package/dist/repterm/src/plugin/index.js +85 -0
- package/dist/repterm/src/plugin/withPlugins.d.ts +71 -0
- package/dist/repterm/src/plugin/withPlugins.d.ts.map +1 -0
- package/dist/repterm/src/plugin/withPlugins.js +100 -0
- package/dist/repterm/src/runner/models.d.ts +261 -0
- package/dist/repterm/src/runner/models.d.ts.map +1 -0
- package/dist/repterm/src/runner/models.js +4 -0
- package/dist/result.d.ts +80 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +134 -0
- package/package.json +38 -0
package/dist/result.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kubectl Result Types
|
|
3
|
+
*
|
|
4
|
+
* Provides result classes for kubectl commands with intelligent success detection.
|
|
5
|
+
* Handles both normal mode (exitCode-based) and PTY/recording mode (output-based).
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Base class for kubectl command execution results.
|
|
11
|
+
* Provides unified success detection logic for both PTY and non-PTY modes.
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class KubectlResult {
|
|
14
|
+
/** Command output (stdout + stderr in PTY mode) */
|
|
15
|
+
readonly output: string;
|
|
16
|
+
/** The executed command */
|
|
17
|
+
readonly command: string;
|
|
18
|
+
/** Exit code (-1 in PTY mode where exit code is unavailable) */
|
|
19
|
+
readonly exitCode: number;
|
|
20
|
+
constructor(
|
|
21
|
+
/** Command output (stdout + stderr in PTY mode) */
|
|
22
|
+
output: string,
|
|
23
|
+
/** The executed command */
|
|
24
|
+
command: string,
|
|
25
|
+
/** Exit code (-1 in PTY mode where exit code is unavailable) */
|
|
26
|
+
exitCode: number);
|
|
27
|
+
/**
|
|
28
|
+
* Check if the command succeeded.
|
|
29
|
+
* - Non-PTY mode: Uses exitCode === 0
|
|
30
|
+
* - PTY mode (exitCode === -1): Delegates to subclass isOutputSuccessful()
|
|
31
|
+
*/
|
|
32
|
+
get successful(): boolean;
|
|
33
|
+
/** Subclass implementation: determine success based on output content */
|
|
34
|
+
protected abstract isOutputSuccessful(): boolean;
|
|
35
|
+
/** Common error detection helper */
|
|
36
|
+
protected hasError(): boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Result for kubectl apply command.
|
|
40
|
+
* Success indicators: "created", "configured", "unchanged"
|
|
41
|
+
*/
|
|
42
|
+
export declare class ApplyResult extends KubectlResult {
|
|
43
|
+
protected isOutputSuccessful(): boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Result for kubectl delete command.
|
|
47
|
+
* Success indicators: "deleted" or "not found" (with --ignore-not-found)
|
|
48
|
+
*/
|
|
49
|
+
export declare class DeleteResult extends KubectlResult {
|
|
50
|
+
protected isOutputSuccessful(): boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Result for kubectl patch command.
|
|
54
|
+
* Success indicators: "patched" or "(no change)"
|
|
55
|
+
*/
|
|
56
|
+
export declare class PatchResult extends KubectlResult {
|
|
57
|
+
protected isOutputSuccessful(): boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Result for kubectl scale command.
|
|
61
|
+
* Success indicators: "scaled"
|
|
62
|
+
*/
|
|
63
|
+
export declare class ScaleResult extends KubectlResult {
|
|
64
|
+
protected isOutputSuccessful(): boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Result for kubectl label/annotate commands.
|
|
68
|
+
* Success indicators: "labeled" or "annotated"
|
|
69
|
+
*/
|
|
70
|
+
export declare class LabelResult extends KubectlResult {
|
|
71
|
+
protected isOutputSuccessful(): boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Result for kubectl wait command.
|
|
75
|
+
* Success indicators: "condition met" or specific condition messages
|
|
76
|
+
*/
|
|
77
|
+
export declare class WaitResult extends KubectlResult {
|
|
78
|
+
protected isOutputSuccessful(): boolean;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;GAGG;AACH,8BAAsB,aAAa;IAE3B,mDAAmD;aACnC,MAAM,EAAE,MAAM;IAC9B,2BAA2B;aACX,OAAO,EAAE,MAAM;IAC/B,gEAAgE;aAChD,QAAQ,EAAE,MAAM;;IALhC,mDAAmD;IACnC,MAAM,EAAE,MAAM;IAC9B,2BAA2B;IACX,OAAO,EAAE,MAAM;IAC/B,gEAAgE;IAChD,QAAQ,EAAE,MAAM;IAGpC;;;;OAIG;IACH,IAAI,UAAU,IAAI,OAAO,CAOxB;IAED,yEAAyE;IACzE,SAAS,CAAC,QAAQ,CAAC,kBAAkB,IAAI,OAAO;IAEhD,oCAAoC;IACpC,SAAS,CAAC,QAAQ,IAAI,OAAO;CAUhC;AAED;;;GAGG;AACH,qBAAa,WAAY,SAAQ,aAAa;IAC1C,SAAS,CAAC,kBAAkB,IAAI,OAAO;CAM1C;AAED;;;GAGG;AACH,qBAAa,YAAa,SAAQ,aAAa;IAC3C,SAAS,CAAC,kBAAkB,IAAI,OAAO;CAU1C;AAED;;;GAGG;AACH,qBAAa,WAAY,SAAQ,aAAa;IAC1C,SAAS,CAAC,kBAAkB,IAAI,OAAO;CAM1C;AAED;;;GAGG;AACH,qBAAa,WAAY,SAAQ,aAAa;IAC1C,SAAS,CAAC,kBAAkB,IAAI,OAAO;CAM1C;AAED;;;GAGG;AACH,qBAAa,WAAY,SAAQ,aAAa;IAC1C,SAAS,CAAC,kBAAkB,IAAI,OAAO;CAM1C;AAED;;;GAGG;AACH,qBAAa,UAAW,SAAQ,aAAa;IACzC,SAAS,CAAC,kBAAkB,IAAI,OAAO;CAS1C"}
|
package/dist/result.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kubectl Result Types
|
|
3
|
+
*
|
|
4
|
+
* Provides result classes for kubectl commands with intelligent success detection.
|
|
5
|
+
* Handles both normal mode (exitCode-based) and PTY/recording mode (output-based).
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Base class for kubectl command execution results.
|
|
11
|
+
* Provides unified success detection logic for both PTY and non-PTY modes.
|
|
12
|
+
*/
|
|
13
|
+
export class KubectlResult {
|
|
14
|
+
output;
|
|
15
|
+
command;
|
|
16
|
+
exitCode;
|
|
17
|
+
constructor(
|
|
18
|
+
/** Command output (stdout + stderr in PTY mode) */
|
|
19
|
+
output,
|
|
20
|
+
/** The executed command */
|
|
21
|
+
command,
|
|
22
|
+
/** Exit code (-1 in PTY mode where exit code is unavailable) */
|
|
23
|
+
exitCode) {
|
|
24
|
+
this.output = output;
|
|
25
|
+
this.command = command;
|
|
26
|
+
this.exitCode = exitCode;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Check if the command succeeded.
|
|
30
|
+
* - Non-PTY mode: Uses exitCode === 0
|
|
31
|
+
* - PTY mode (exitCode === -1): Delegates to subclass isOutputSuccessful()
|
|
32
|
+
*/
|
|
33
|
+
get successful() {
|
|
34
|
+
// Non-PTY mode: exitCode is reliable
|
|
35
|
+
if (this.exitCode !== -1) {
|
|
36
|
+
return this.exitCode === 0;
|
|
37
|
+
}
|
|
38
|
+
// PTY mode: check output content (subclass implementation)
|
|
39
|
+
return this.isOutputSuccessful();
|
|
40
|
+
}
|
|
41
|
+
/** Common error detection helper */
|
|
42
|
+
hasError() {
|
|
43
|
+
const output = this.output.toLowerCase();
|
|
44
|
+
return (output.includes('error:') ||
|
|
45
|
+
output.includes('error from server') ||
|
|
46
|
+
output.includes('unable to') ||
|
|
47
|
+
output.includes('forbidden') ||
|
|
48
|
+
output.includes('not found') && output.includes('error'));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Result for kubectl apply command.
|
|
53
|
+
* Success indicators: "created", "configured", "unchanged"
|
|
54
|
+
*/
|
|
55
|
+
export class ApplyResult extends KubectlResult {
|
|
56
|
+
isOutputSuccessful() {
|
|
57
|
+
if (this.hasError())
|
|
58
|
+
return false;
|
|
59
|
+
const output = this.output.toLowerCase();
|
|
60
|
+
// apply success patterns: "created", "configured", "unchanged"
|
|
61
|
+
return /\b(created|configured|unchanged)\b/.test(output);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Result for kubectl delete command.
|
|
66
|
+
* Success indicators: "deleted" or "not found" (with --ignore-not-found)
|
|
67
|
+
*/
|
|
68
|
+
export class DeleteResult extends KubectlResult {
|
|
69
|
+
isOutputSuccessful() {
|
|
70
|
+
// For delete, "not found" with --ignore-not-found is actually success
|
|
71
|
+
const output = this.output.toLowerCase();
|
|
72
|
+
// Check for actual errors first
|
|
73
|
+
if (output.includes('error:') || output.includes('error from server') || output.includes('forbidden')) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
// delete success patterns: "deleted" or "not found" (idempotent delete)
|
|
77
|
+
return /\b(deleted|not found)\b/.test(output);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Result for kubectl patch command.
|
|
82
|
+
* Success indicators: "patched" or "(no change)"
|
|
83
|
+
*/
|
|
84
|
+
export class PatchResult extends KubectlResult {
|
|
85
|
+
isOutputSuccessful() {
|
|
86
|
+
if (this.hasError())
|
|
87
|
+
return false;
|
|
88
|
+
const output = this.output.toLowerCase();
|
|
89
|
+
// patch success patterns: "patched" or "(no change)"
|
|
90
|
+
return /\b(patched)\b|\(no change\)/.test(output);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Result for kubectl scale command.
|
|
95
|
+
* Success indicators: "scaled"
|
|
96
|
+
*/
|
|
97
|
+
export class ScaleResult extends KubectlResult {
|
|
98
|
+
isOutputSuccessful() {
|
|
99
|
+
if (this.hasError())
|
|
100
|
+
return false;
|
|
101
|
+
const output = this.output.toLowerCase();
|
|
102
|
+
// scale success pattern: "scaled"
|
|
103
|
+
return /\bscaled\b/.test(output);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Result for kubectl label/annotate commands.
|
|
108
|
+
* Success indicators: "labeled" or "annotated"
|
|
109
|
+
*/
|
|
110
|
+
export class LabelResult extends KubectlResult {
|
|
111
|
+
isOutputSuccessful() {
|
|
112
|
+
if (this.hasError())
|
|
113
|
+
return false;
|
|
114
|
+
const output = this.output.toLowerCase();
|
|
115
|
+
// label/annotate success patterns: "labeled" or "annotated"
|
|
116
|
+
return /\b(labeled|annotated)\b/.test(output);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Result for kubectl wait command.
|
|
121
|
+
* Success indicators: "condition met" or specific condition messages
|
|
122
|
+
*/
|
|
123
|
+
export class WaitResult extends KubectlResult {
|
|
124
|
+
isOutputSuccessful() {
|
|
125
|
+
if (this.hasError())
|
|
126
|
+
return false;
|
|
127
|
+
const output = this.output.toLowerCase();
|
|
128
|
+
// wait success patterns: "condition met" or specific resource/condition met
|
|
129
|
+
// kubectl wait outputs: "tensorfusionworkload.tensor-fusion.ai/test-workload condition met"
|
|
130
|
+
return /\bcondition met\b/.test(output) ||
|
|
131
|
+
// for --for=delete: resource disappears successfully
|
|
132
|
+
/\bdeleted\b/.test(output);
|
|
133
|
+
}
|
|
134
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nexusgpu/repterm-plugin-kubectl",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Kubernetes plugin for repterm - provides kubectl testing utilities",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"clean": "rm -rf dist"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"repterm",
|
|
23
|
+
"plugin",
|
|
24
|
+
"kubectl",
|
|
25
|
+
"kubernetes",
|
|
26
|
+
"testing"
|
|
27
|
+
],
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"repterm-api": "0.1.0"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"repterm": ">=0.1.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"typescript": "^5.3.0"
|
|
37
|
+
}
|
|
38
|
+
}
|