@intentius/chant-lexicon-k8s 0.30.0 → 0.32.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/dist/api/classify.d.ts +65 -0
- package/dist/api/classify.d.ts.map +1 -0
- package/dist/api/connect.d.ts +58 -0
- package/dist/api/connect.d.ts.map +1 -0
- package/dist/api/fake-cluster.d.ts +55 -0
- package/dist/api/fake-cluster.d.ts.map +1 -0
- package/dist/api/operation-surface.d.ts +64 -0
- package/dist/api/operation-surface.d.ts.map +1 -0
- package/dist/api/owner-chain.d.ts +46 -0
- package/dist/api/owner-chain.d.ts.map +1 -0
- package/dist/api/sweep-types.d.ts +17 -0
- package/dist/api/sweep-types.d.ts.map +1 -0
- package/dist/codegen/generate-operations.d.ts +29 -0
- package/dist/codegen/generate-operations.d.ts.map +1 -0
- package/dist/codegen/generate.d.ts.map +1 -1
- package/dist/config.d.ts +17 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/crd/parser.d.ts.map +1 -1
- package/dist/crd/types.d.ts +7 -0
- package/dist/crd/types.d.ts.map +1 -1
- package/dist/deep-observe-hooks.d.ts +86 -0
- package/dist/deep-observe-hooks.d.ts.map +1 -0
- package/dist/deep-observe.d.ts +146 -0
- package/dist/deep-observe.d.ts.map +1 -0
- package/dist/describe-resources.d.ts +58 -26
- package/dist/describe-resources.d.ts.map +1 -1
- package/dist/export-resources.d.ts +31 -1
- package/dist/export-resources.d.ts.map +1 -1
- package/dist/integrity.json +2 -2
- package/dist/kube/apply.d.ts +26 -0
- package/dist/kube/apply.d.ts.map +1 -0
- package/dist/kube/connect.d.ts +30 -0
- package/dist/kube/connect.d.ts.map +1 -0
- package/dist/kube/delete.d.ts +27 -0
- package/dist/kube/delete.d.ts.map +1 -0
- package/dist/kube/describe.d.ts +19 -0
- package/dist/kube/describe.d.ts.map +1 -0
- package/dist/kube/events.d.ts +34 -0
- package/dist/kube/events.d.ts.map +1 -0
- package/dist/kube/flags.d.ts +40 -0
- package/dist/kube/flags.d.ts.map +1 -0
- package/dist/kube/get.d.ts +21 -0
- package/dist/kube/get.d.ts.map +1 -0
- package/dist/kube/group.d.ts +19 -0
- package/dist/kube/group.d.ts.map +1 -0
- package/dist/kube/logs.d.ts +16 -0
- package/dist/kube/logs.d.ts.map +1 -0
- package/dist/kube/project.d.ts +59 -0
- package/dist/kube/project.d.ts.map +1 -0
- package/dist/kube/render.d.ts +75 -0
- package/dist/kube/render.d.ts.map +1 -0
- package/dist/kube/source.d.ts +19 -0
- package/dist/kube/source.d.ts.map +1 -0
- package/dist/kube/target.d.ts +52 -0
- package/dist/kube/target.d.ts.map +1 -0
- package/dist/kube/testing.d.ts +21 -0
- package/dist/kube/testing.d.ts.map +1 -0
- package/dist/kube/top.d.ts +23 -0
- package/dist/kube/top.d.ts.map +1 -0
- package/dist/kube/verdict.d.ts +45 -0
- package/dist/kube/verdict.d.ts.map +1 -0
- package/dist/kube/wait.d.ts +23 -0
- package/dist/kube/wait.d.ts.map +1 -0
- package/dist/manifest.json +1 -1
- package/dist/op/activities/index.d.ts +7 -4
- package/dist/op/activities/index.d.ts.map +1 -1
- package/dist/op/activities/kubectl.d.ts +120 -2
- package/dist/op/activities/kubectl.d.ts.map +1 -1
- package/dist/op/activities/wait-for-ready.d.ts +30 -3
- package/dist/op/activities/wait-for-ready.d.ts.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/spec/parse.d.ts +42 -0
- package/dist/spec/parse.d.ts.map +1 -1
- package/package.json +5 -2
- package/src/api/classify.test.ts +133 -0
- package/src/api/classify.ts +144 -0
- package/src/api/connect.ts +104 -0
- package/src/api/fake-cluster.ts +218 -0
- package/src/api/operation-surface.test.ts +116 -0
- package/src/api/operation-surface.ts +129 -0
- package/src/api/owner-chain.test.ts +171 -0
- package/src/api/owner-chain.ts +144 -0
- package/src/api/sweep-types.ts +36 -0
- package/src/codegen/generate-operations.ts +56 -0
- package/src/codegen/generate.ts +9 -0
- package/src/config.ts +17 -0
- package/src/crd/parser.ts +8 -0
- package/src/crd/types.ts +7 -0
- package/src/deep-observe-hooks.ts +125 -0
- package/src/deep-observe.test.ts +668 -0
- package/src/deep-observe.ts +299 -0
- package/src/describe-resources.test.ts +619 -191
- package/src/describe-resources.ts +218 -117
- package/src/export-resources-io.test.ts +76 -51
- package/src/export-resources.ts +47 -35
- package/src/generated/operations.json +2156 -0
- package/src/kube/apply.test.ts +105 -0
- package/src/kube/apply.ts +101 -0
- package/src/kube/connect.ts +54 -0
- package/src/kube/delete.test.ts +123 -0
- package/src/kube/delete.ts +174 -0
- package/src/kube/describe.test.ts +106 -0
- package/src/kube/describe.ts +195 -0
- package/src/kube/events.test.ts +115 -0
- package/src/kube/events.ts +160 -0
- package/src/kube/flags.test.ts +65 -0
- package/src/kube/flags.ts +114 -0
- package/src/kube/get.test.ts +195 -0
- package/src/kube/get.ts +190 -0
- package/src/kube/group.test.ts +33 -0
- package/src/kube/group.ts +125 -0
- package/src/kube/logs.test.ts +126 -0
- package/src/kube/logs.ts +96 -0
- package/src/kube/project.test.ts +57 -0
- package/src/kube/project.ts +106 -0
- package/src/kube/render.test.ts +142 -0
- package/src/kube/render.ts +252 -0
- package/src/kube/source.test.ts +138 -0
- package/src/kube/source.ts +139 -0
- package/src/kube/target.test.ts +67 -0
- package/src/kube/target.ts +89 -0
- package/src/kube/testing.ts +42 -0
- package/src/kube/top.test.ts +149 -0
- package/src/kube/top.ts +120 -0
- package/src/kube/verdict.test.ts +48 -0
- package/src/kube/verdict.ts +77 -0
- package/src/kube/wait.test.ts +125 -0
- package/src/kube/wait.ts +160 -0
- package/src/lifecycle-integration.test.ts +132 -92
- package/src/op/activities/index.ts +7 -3
- package/src/op/activities/kubectl.test.ts +420 -0
- package/src/op/activities/kubectl.ts +379 -13
- package/src/op/activities/wait-for-ready.test.ts +94 -0
- package/src/op/activities/wait-for-ready.ts +66 -15
- package/src/plugin.test.ts +58 -1
- package/src/plugin.ts +29 -0
- package/src/spec/parse.ts +93 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort chant-project context for `chant kube` (chant #1079).
|
|
3
|
+
*
|
|
4
|
+
* `get`'s chant-verdict column and `source` both need to answer "does a
|
|
5
|
+
* declared entity in this project's source name this live object" — which
|
|
6
|
+
* needs the project built (chant.config.ts read, source discovered and
|
|
7
|
+
* resolved). `chant kube` is also usable against a bare cluster with no
|
|
8
|
+
* chant project in sight (a checkout of someone else's manifests, a
|
|
9
|
+
* throwaway directory) — the acceptance criterion is that reads still work
|
|
10
|
+
* there and only the chant-specific parts degrade, quietly, to
|
|
11
|
+
* "unavailable" rather than erroring. Every failure mode here — no
|
|
12
|
+
* `chant.config.ts`, a project with build errors, an unreadable directory —
|
|
13
|
+
* collapses to `undefined` for exactly that reason.
|
|
14
|
+
*
|
|
15
|
+
* Deliberately does not import anything client-shaped: this runs before a
|
|
16
|
+
* cluster is ever reached (`source`/`get` need it to compute a verdict for
|
|
17
|
+
* objects the client already read), and matching is pure once given a live
|
|
18
|
+
* object's coordinates.
|
|
19
|
+
*/
|
|
20
|
+
import { type ChantConfig } from "@intentius/chant/config";
|
|
21
|
+
import { type EntityProvenance } from "@intentius/chant/provenance";
|
|
22
|
+
import type { Declarable } from "@intentius/chant/declarable";
|
|
23
|
+
export interface KubeProjectContext {
|
|
24
|
+
cwd: string;
|
|
25
|
+
config: ChantConfig;
|
|
26
|
+
entities: Map<string, Declarable>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build the project rooted at `cwd` (or its configured `sourceDir`) with the
|
|
30
|
+
* k8s serializer, so `entities` carries resolved props (composites expanded,
|
|
31
|
+
* AttrRefs resolved) and build provenance (chant #1064's entity-level
|
|
32
|
+
* `sourceFile`/`composite`, stamped during discovery). Returns undefined —
|
|
33
|
+
* never throws — for anything that stops the project from resolving: no
|
|
34
|
+
* `chant.config.ts` here or above, a build with errors, an inaccessible
|
|
35
|
+
* directory. This IS the "outside a chant project" signal every caller
|
|
36
|
+
* checks for.
|
|
37
|
+
*/
|
|
38
|
+
export declare function loadKubeProjectContext(cwd?: string): Promise<KubeProjectContext | undefined>;
|
|
39
|
+
export interface DeclaredMatch {
|
|
40
|
+
entityName: string;
|
|
41
|
+
entity: Declarable;
|
|
42
|
+
props: Record<string, unknown> | undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Reverse-map a live object's coordinates (apiVersion/kind/name/namespace) to
|
|
46
|
+
* the declared k8s entity that names it, if this project declares one.
|
|
47
|
+
* `operationFor` is the same generated operation surface `describeResources`
|
|
48
|
+
* addresses entities with, so a match here is addressed exactly the way the
|
|
49
|
+
* live read that produced the object was — no separate naming convention.
|
|
50
|
+
*/
|
|
51
|
+
export declare function findDeclaredMatch(entities: Map<string, Declarable>, ref: {
|
|
52
|
+
apiVersion: string;
|
|
53
|
+
kind: string;
|
|
54
|
+
name: string;
|
|
55
|
+
namespace?: string;
|
|
56
|
+
}): DeclaredMatch | undefined;
|
|
57
|
+
/** Provenance for a matched entity, relative to the project root when possible. */
|
|
58
|
+
export declare function relativeProvenance(ctx: KubeProjectContext, entity: Declarable): EntityProvenance | undefined;
|
|
59
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/kube/project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAI9D,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACnC;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAkBjH;AAMD,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC5C;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACjC,GAAG,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1E,aAAa,GAAG,SAAS,CAY3B;AAED,mFAAmF;AACnF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,GAAG,gBAAgB,GAAG,SAAS,CAM5G"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output rendering for `chant kube get`/`describe` (chant #1079).
|
|
3
|
+
*
|
|
4
|
+
* kubectl's own `-o` vocabulary, minus the one form the issue says to drop
|
|
5
|
+
* openly rather than half-implement: `-o go-template[-file]` is Go template
|
|
6
|
+
* syntax, and chant does not carry a Go template engine — {@link parseOutput}
|
|
7
|
+
* refuses it by name rather than pretending a partial implementation covers
|
|
8
|
+
* it. `-o jsonpath` and `-o custom-columns` are "tractable" per the issue's
|
|
9
|
+
* own notes, and are implemented here as a deliberately small subset: dot
|
|
10
|
+
* paths, bracket indices, and a `[*]` wildcard — the paths kubectl one-liners
|
|
11
|
+
* actually use — not the full jsonpath grammar (filters, `range`/`end`
|
|
12
|
+
* templates). `-o chant` is chant's own addition: a live object rendered as
|
|
13
|
+
* the typed source that would declare it, reusing `./import/live-export.ts`
|
|
14
|
+
* and the lexicon's own `K8sGenerator` — the same machinery `chant import`
|
|
15
|
+
* uses, so every read is an adoption path, per the issue's framing.
|
|
16
|
+
*/
|
|
17
|
+
import type { K8sObject } from "@intentius/chant-k8s-client";
|
|
18
|
+
import type { KubeVerdict } from "./verdict.js";
|
|
19
|
+
export type OutputFormat = {
|
|
20
|
+
kind: "text";
|
|
21
|
+
} | {
|
|
22
|
+
kind: "wide";
|
|
23
|
+
} | {
|
|
24
|
+
kind: "json";
|
|
25
|
+
} | {
|
|
26
|
+
kind: "yaml";
|
|
27
|
+
} | {
|
|
28
|
+
kind: "name";
|
|
29
|
+
} | {
|
|
30
|
+
kind: "chant";
|
|
31
|
+
} | {
|
|
32
|
+
kind: "jsonpath";
|
|
33
|
+
expr: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "custom-columns";
|
|
36
|
+
spec: string;
|
|
37
|
+
};
|
|
38
|
+
/** Parse an `-o`/`--output` value. Throws on `go-template[-file]`. */
|
|
39
|
+
export declare function parseOutput(value: string | undefined): OutputFormat;
|
|
40
|
+
export interface KubeRow {
|
|
41
|
+
namespace?: string;
|
|
42
|
+
name: string;
|
|
43
|
+
kind: string;
|
|
44
|
+
status: string;
|
|
45
|
+
age?: string;
|
|
46
|
+
verdict?: KubeVerdict;
|
|
47
|
+
labels?: Record<string, string>;
|
|
48
|
+
object: K8sObject;
|
|
49
|
+
}
|
|
50
|
+
/** kubectl-style relative age, e.g. "45s", "12m", "3h", "5d". */
|
|
51
|
+
export declare function relativeAge(creationTimestamp: string | undefined, now?: number): string;
|
|
52
|
+
/** Render a fixed-width table. `columns` is header → per-row value. */
|
|
53
|
+
export declare function renderTable(headers: string[], rows: string[][]): string;
|
|
54
|
+
export declare function renderKubeTable(rows: KubeRow[], opts: {
|
|
55
|
+
allNamespaces: boolean;
|
|
56
|
+
wide: boolean;
|
|
57
|
+
showVerdict: boolean;
|
|
58
|
+
}): string;
|
|
59
|
+
export declare function renderJson(objects: readonly K8sObject[]): string;
|
|
60
|
+
export declare function renderYaml(objects: readonly K8sObject[]): string;
|
|
61
|
+
/** `kubectl get -o name`: `<lowercased-kind>.<group>/<name>` (`<lowercased-kind>/<name>` for the core group). */
|
|
62
|
+
export declare function renderName(objects: readonly K8sObject[]): string;
|
|
63
|
+
/** Render live objects as the typed chant source that would declare them. */
|
|
64
|
+
export declare function renderChantSource(objects: readonly K8sObject[]): string;
|
|
65
|
+
/**
|
|
66
|
+
* Evaluate a kubectl-style jsonpath template against one root value: literal
|
|
67
|
+
* text passes through, `{"..."}` is a quoted literal, `{.a.b[*].c}` extracts
|
|
68
|
+
* and space-joins matches. Multiple `{...}` blocks concatenate directly, as
|
|
69
|
+
* kubectl's own `-o jsonpath` does.
|
|
70
|
+
*/
|
|
71
|
+
export declare function evalJsonPath(template: string, root: unknown): string;
|
|
72
|
+
/** `-o jsonpath=`: kubectl runs the whole template once per top-level object printed. */
|
|
73
|
+
export declare function renderJsonPath(expr: string, objects: readonly K8sObject[]): string;
|
|
74
|
+
export declare function renderCustomColumns(spec: string, objects: readonly K8sObject[]): string;
|
|
75
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/kube/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAI7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,OAAO,CAAA;CAA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AA6E;AAC7E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,GAAG,MAAM,CAIvE;AA+CD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAkBpE;AAED,yFAAyF;AACzF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,SAAS,EAAE,GAAG,MAAM,CAGlF;AAmBD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,SAAS,EAAE,GAAG,MAAM,CAKvF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `chant kube source` (chant #1079) — resolve a live object back to the
|
|
3
|
+
* `.ts` file and composite that declared it, reusing the exact build
|
|
4
|
+
* provenance the gitlab/forgejo lexicons' own `:source` context tools already
|
|
5
|
+
* expose (`@intentius/chant/provenance`, stamped during discovery — chant
|
|
6
|
+
* #1064). That precedent is explicit that provenance here is **entity-level
|
|
7
|
+
* (file + composite), not a YAML-line source map** — chant does not carry
|
|
8
|
+
* one, for k8s or for anything else — so this verb reports the same two
|
|
9
|
+
* facts (never a fabricated line number) and says so plainly rather than
|
|
10
|
+
* silently coming up one field short of the issue's wording.
|
|
11
|
+
*/
|
|
12
|
+
import { type K8sConnector } from "../api/connect.js";
|
|
13
|
+
import { type KubeProjectContext } from "./project.js";
|
|
14
|
+
export interface SourceDeps {
|
|
15
|
+
connect?: K8sConnector;
|
|
16
|
+
loadProject?: (cwd?: string) => Promise<KubeProjectContext | undefined>;
|
|
17
|
+
}
|
|
18
|
+
export declare function runSource(rawArgs: string[], deps?: SourceDeps): Promise<number>;
|
|
19
|
+
//# sourceMappingURL=source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/kube/source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAIxE,OAAO,EAA8C,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGhG,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;CACzE;AAMD,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,UAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CA6GzF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolving `chant kube <verb> <target...>`'s positional arguments to an
|
|
3
|
+
* addressable resource (chant #1079).
|
|
4
|
+
*
|
|
5
|
+
* "Every verb resolves entity names through chant's own vocabulary where
|
|
6
|
+
* applicable ... while also accepting raw kind/name kubectl-style." Both
|
|
7
|
+
* forms share one positional shape, disambiguated by arity:
|
|
8
|
+
*
|
|
9
|
+
* - One token, and it names a declared entity in this project → chant's own
|
|
10
|
+
* vocabulary: the entity's `metadata.name`(/`namespace`) is looked up in
|
|
11
|
+
* its own source, not typed twice.
|
|
12
|
+
* - One or two tokens otherwise → kubectl's own shape, `<kind> [name]`; a
|
|
13
|
+
* bare kind with no name is a list, matching `kubectl get <kind>`.
|
|
14
|
+
*
|
|
15
|
+
* `<kind>` is never parsed here beyond splitting the `.group` suffix — that
|
|
16
|
+
* job belongs to the typed client's own `resolve()` (kubectl's own
|
|
17
|
+
* plural/singular/kind/short-name precedence, `packages/k8s-client/src/client.ts`),
|
|
18
|
+
* so a raw kind string reaches the cluster exactly as `kubectl get raycluster.ray.io`
|
|
19
|
+
* would.
|
|
20
|
+
*/
|
|
21
|
+
import type { ResourceSelector } from "@intentius/chant-k8s-client";
|
|
22
|
+
import { type DeclaredMatch, type KubeProjectContext } from "./project.js";
|
|
23
|
+
export interface KubeTarget {
|
|
24
|
+
selector: ResourceSelector;
|
|
25
|
+
/** Object name. Undefined means "list every object this selector addresses". */
|
|
26
|
+
name?: string;
|
|
27
|
+
namespace?: string;
|
|
28
|
+
/** Set when resolution went through chant's own vocabulary rather than a kubectl kind string. */
|
|
29
|
+
declaredMatch?: DeclaredMatch;
|
|
30
|
+
}
|
|
31
|
+
export interface KubeTargetError {
|
|
32
|
+
error: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function isTargetError(t: KubeTarget | KubeTargetError): t is KubeTargetError;
|
|
35
|
+
/**
|
|
36
|
+
* Resolve `positional` (whatever's left after flags) plus an explicit
|
|
37
|
+
* `-n/--namespace`, against `project`'s declared entities when available.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveKubeTarget(positional: readonly string[], namespaceFlag: string | undefined, project: KubeProjectContext | undefined): KubeTarget | KubeTargetError;
|
|
40
|
+
/**
|
|
41
|
+
* After a live read resolves an object's real `apiVersion`/`kind` (a kubectl
|
|
42
|
+
* kind string like `deploy` isn't one), reverse-map it against the project
|
|
43
|
+
* for the verdict column / `source` — reusing the exact match `resolveKubeTarget`
|
|
44
|
+
* would have made had the caller spelled out the entity name.
|
|
45
|
+
*/
|
|
46
|
+
export declare function matchLiveObject(project: KubeProjectContext | undefined, ref: {
|
|
47
|
+
apiVersion: string;
|
|
48
|
+
kind: string;
|
|
49
|
+
name: string;
|
|
50
|
+
namespace?: string;
|
|
51
|
+
}): DeclaredMatch | undefined;
|
|
52
|
+
//# sourceMappingURL=target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../src/kube/target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAqB,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAG3F,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iGAAiG;IACjG,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,UAAU,GAAG,eAAe,GAAG,CAAC,IAAI,eAAe,CAEnF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,OAAO,EAAE,kBAAkB,GAAG,SAAS,GACtC,UAAU,GAAG,eAAe,CAwB9B;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,kBAAkB,GAAG,SAAS,EACvC,GAAG,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1E,aAAa,GAAG,SAAS,CAG3B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test doubles for `chant kube` (chant #1079).
|
|
3
|
+
*
|
|
4
|
+
* `./project.ts`'s real `loadKubeProjectContext` builds an actual project
|
|
5
|
+
* (`chant.config.ts` read, source discovered, serialized) — every verb takes
|
|
6
|
+
* it as an injectable dependency for exactly this reason: a unit test builds
|
|
7
|
+
* a `KubeProjectContext` by hand instead, the same way `../api/fake-cluster.ts`
|
|
8
|
+
* lets a test build a client without a socket.
|
|
9
|
+
*/
|
|
10
|
+
import { type Declarable } from "@intentius/chant/declarable";
|
|
11
|
+
import { type EntityProvenance } from "@intentius/chant/provenance";
|
|
12
|
+
import type { ChantConfig } from "@intentius/chant/config";
|
|
13
|
+
import type { KubeProjectContext } from "./project.js";
|
|
14
|
+
export type FakeDeclarable = Declarable & {
|
|
15
|
+
props: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
/** A minimal `Declarable` carrying `props`, optionally stamped with build provenance. */
|
|
18
|
+
export declare function fakeDeclarable(entityType: string, props: Record<string, unknown>, provenance?: EntityProvenance): FakeDeclarable;
|
|
19
|
+
/** A `KubeProjectContext` built from a plain name → entity map, no disk I/O. */
|
|
20
|
+
export declare function fakeProjectContext(entities: Record<string, Declarable>, config?: ChantConfig, cwd?: string): KubeProjectContext;
|
|
21
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/kube/testing.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACjF,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC;AAE7E,yFAAyF;AACzF,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,UAAU,CAAC,EAAE,gBAAgB,GAC5B,cAAc,CAUhB;AAED,gFAAgF;AAChF,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACpC,MAAM,GAAE,WAAgB,EACxB,GAAG,SAAa,GACf,kBAAkB,CAEpB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `chant kube top pods|nodes` (chant #1079).
|
|
3
|
+
*
|
|
4
|
+
* `metrics.k8s.io` is not part of the standard Kubernetes OpenAPI schema chant's
|
|
5
|
+
* codegen ingests — it is an aggregated API a cluster may or may not be running
|
|
6
|
+
* (metrics-server). It needs no entry in the generated operation surface either
|
|
7
|
+
* way: the typed client's kubectl-style selector (`{ resource, group }`) resolves
|
|
8
|
+
* purely off the *cluster's own* discovery, the same path `waitForReady`'s `kind`
|
|
9
|
+
* argument already uses for CRDs — so this needs no client change, only the
|
|
10
|
+
* right selector.
|
|
11
|
+
*
|
|
12
|
+
* Kubectl's own `top` sums each Pod's per-container usage into one CPU/memory
|
|
13
|
+
* figure, which needs real quantity-unit arithmetic (`250m` + `100m`, `128Mi` +
|
|
14
|
+
* `64Mi`). That normalization is not implemented here — each container's raw
|
|
15
|
+
* usage string is shown as the API reported it, unsummed. Good enough for "is
|
|
16
|
+
* anything obviously starved", not a replacement for `kubectl top --containers`.
|
|
17
|
+
*/
|
|
18
|
+
import { type K8sConnector } from "../api/connect.js";
|
|
19
|
+
export interface TopDeps {
|
|
20
|
+
connect?: K8sConnector;
|
|
21
|
+
}
|
|
22
|
+
export declare function runTop(rawArgs: string[], deps?: TopDeps): Promise<number>;
|
|
23
|
+
//# sourceMappingURL=top.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"top.d.ts","sourceRoot":"","sources":["../../src/kube/top.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAMxE,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAWD,wBAAsB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,OAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAiFnF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chant verdict column `chant kube get` carries on every row (chant
|
|
3
|
+
* #1079's acceptance criterion: "get annotates each row with the declared /
|
|
4
|
+
* owned / drifted / foreign-owned verdict").
|
|
5
|
+
*
|
|
6
|
+
* Four states:
|
|
7
|
+
*
|
|
8
|
+
* - `declared` — this project's source names an entity at this exact
|
|
9
|
+
* apiVersion/kind/name(/namespace), and the live object agrees with it on
|
|
10
|
+
* every field the source declares.
|
|
11
|
+
* - `drifted` — same match, but the live object disagrees with the source on
|
|
12
|
+
* at least one declared field.
|
|
13
|
+
* - `owned` — no declared match, but the live object carries chant's
|
|
14
|
+
* ownership marker (`app.kubernetes.io/managed-by=chant`) — something
|
|
15
|
+
* chant applied that source no longer declares, or a stack/entity this
|
|
16
|
+
* project's build didn't resolve.
|
|
17
|
+
* - `foreign-owned` — no declared match and no marker: chant does not
|
|
18
|
+
* consider this object its own.
|
|
19
|
+
*
|
|
20
|
+
* `unavailable` is not a verdict about the object; it is what every row gets
|
|
21
|
+
* when the project context could not be loaded at all (chant #1079's
|
|
22
|
+
* "degrades gracefully outside a chant project" — `get` and `describe` still
|
|
23
|
+
* work, this column just has nothing to say).
|
|
24
|
+
*
|
|
25
|
+
* The drift check here is a fast, best-effort *declared-subset* comparison —
|
|
26
|
+
* every path the source sets must agree on the live object — not the
|
|
27
|
+
* managed-fields-precise diff `chant lifecycle diff --live --deep` computes
|
|
28
|
+
* (chant #1076). It exists for a table column that must render for dozens of
|
|
29
|
+
* rows in one `get` call; the deep, field-ownership-aware answer stays the
|
|
30
|
+
* lifecycle command's job. A live object can disagree with the source on a
|
|
31
|
+
* field a controller owns (Kubernetes rewriting `spec.replicas` under an
|
|
32
|
+
* HPA, say) and still show `drifted` here — reach for the deep diff before
|
|
33
|
+
* treating this column as a verdict rather than a hint.
|
|
34
|
+
*/
|
|
35
|
+
import type { K8sObject } from "@intentius/chant-k8s-client";
|
|
36
|
+
import type { DeclaredMatch } from "./project.js";
|
|
37
|
+
export type KubeVerdict = "declared" | "owned" | "drifted" | "foreign-owned" | "unavailable";
|
|
38
|
+
/**
|
|
39
|
+
* True when every path `declared` sets is present and equal on `live`.
|
|
40
|
+
* Extra fields on `live` (server defaults, status, anything the source never
|
|
41
|
+
* mentions) are not drift — chant never declared an opinion about them.
|
|
42
|
+
*/
|
|
43
|
+
export declare function declaredSubsetMatches(declared: unknown, live: unknown): boolean;
|
|
44
|
+
export declare function verdictFor(live: K8sObject, match: DeclaredMatch | undefined): KubeVerdict;
|
|
45
|
+
//# sourceMappingURL=verdict.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verdict.d.ts","sourceRoot":"","sources":["../../src/kube/verdict.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,eAAe,GAAG,aAAa,CAAC;AAM7F;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAU/E;AAWD,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,GAAG,SAAS,GAAG,WAAW,CAKzF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `chant kube wait` (chant #1079) — the issue names this one explicitly:
|
|
3
|
+
* "`wait` should use the existing readiness-spec registry in
|
|
4
|
+
* `op/activities/wait-for-ready.ts`, which already handles the Argo case
|
|
5
|
+
* where health and sync replace a `Ready` condition — something `kubectl
|
|
6
|
+
* wait --for` cannot express without jsonpath gymnastics." This verb is a
|
|
7
|
+
* thin CLI shell around that exact registry (`readinessFor`/`isReady`/
|
|
8
|
+
* `firstTerminal`/`waitForReady`) — not a second implementation of it.
|
|
9
|
+
*
|
|
10
|
+
* `--for=condition=<Type>[=<Status>]` overrides the registry with a single
|
|
11
|
+
* condition check, matching kubectl's own flag. `--for=delete` polls for
|
|
12
|
+
* absence instead. Neither given falls back to the registry: the generic
|
|
13
|
+
* `Ready` condition, or a resource-specific override (Argo's `Application`
|
|
14
|
+
* today).
|
|
15
|
+
*/
|
|
16
|
+
import { type K8sConnector } from "../api/connect.js";
|
|
17
|
+
import { type KubeProjectContext } from "./project.js";
|
|
18
|
+
export interface WaitDeps {
|
|
19
|
+
connect?: K8sConnector;
|
|
20
|
+
loadProject?: (cwd?: string) => Promise<KubeProjectContext | undefined>;
|
|
21
|
+
}
|
|
22
|
+
export declare function runWait(rawArgs: string[], deps?: WaitDeps): Promise<number>;
|
|
23
|
+
//# sourceMappingURL=wait.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait.d.ts","sourceRoot":"","sources":["../../src/kube/wait.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAWxE,OAAO,EAA0B,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAG5E,MAAM,WAAW,QAAQ;IACvB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;CACzE;AAkBD,wBAAsB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,QAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CA6FrF"}
|
package/dist/manifest.json
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* k8s Op activities — resolved by the core activity registry when a project's
|
|
3
3
|
* `chant.config.ts` lists the `k8s` lexicon. Relocated from the temporal lexicon
|
|
4
4
|
* (#809) so Kubernetes-facing imperative activities live with their product:
|
|
5
|
-
* - kubectlApply —
|
|
5
|
+
* - kubectlApply — server-side apply a rendered manifest (and, since chant
|
|
6
|
+
* #1075, prune chant-owned objects it no longer declares; `applyManifest`
|
|
7
|
+
* is the same work with a report of what it did, which is what the
|
|
8
|
+
* Temporal lexicon's `nativeApply` dispatcher calls for a kubectl target)
|
|
6
9
|
* - k3dUp / k3dDown — boot/tear down a local k3d cluster
|
|
7
10
|
* - waitForArgoSync — block until an Argo CD Application is Healthy && Synced
|
|
8
11
|
*
|
|
@@ -11,13 +14,13 @@
|
|
|
11
14
|
* dependency-light — it shells out to a CLI and does not import the k8s declarable
|
|
12
15
|
* surface — so a Temporal worker loads it cheaply.
|
|
13
16
|
*/
|
|
14
|
-
export { kubectlApply } from "./kubectl.js";
|
|
15
|
-
export type { KubectlApplyArgs } from "./kubectl.js";
|
|
17
|
+
export { kubectlApply, applyManifest, readManifestDocuments } from "./kubectl.js";
|
|
18
|
+
export type { KubectlApplyArgs, ApplyManifestResult, AppliedRef, ApplyDeleteMode } from "./kubectl.js";
|
|
16
19
|
export { k3dUp, k3dDown, k3dUpCommand, k3dDownCommand, k3dExistsCommand } from "./k3d.js";
|
|
17
20
|
export type { K3dUpArgs, K3dDownArgs } from "./k3d.js";
|
|
18
21
|
export { waitForArgoSync, defaultArgoStatusFetcher, ArgoSyncFailedError } from "./argo.js";
|
|
19
22
|
export type { WaitForArgoSyncArgs, ArgoAppStatus, ArgoStatusFetcher } from "./argo.js";
|
|
20
|
-
export { waitForReady, defaultResourceFetcher, ReadinessFailedError, readinessFor, isReady, firstTerminal, DEFAULT_READINESS, READINESS_OVERRIDES, } from "./wait-for-ready.js";
|
|
23
|
+
export { waitForReady, defaultResourceFetcher, apiResourceFetcher, ReadinessFailedError, readinessFor, isReady, firstTerminal, DEFAULT_READINESS, READINESS_OVERRIDES, } from "./wait-for-ready.js";
|
|
21
24
|
export type { WaitForReadyArgs, ResourceFetcher, ReadinessSpec, ReadinessMatch, ConditionMatch, PathMatch, } from "./wait-for-ready.js";
|
|
22
25
|
export { resolveClusterTarget, ClusterBindingMismatchError } from "@intentius/chant/kubectl-context";
|
|
23
26
|
export type { ResolvedClusterTarget, K8sClusterProfile, K8sConfigShape } from "@intentius/chant/kubectl-context";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/op/activities/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/op/activities/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAC/E,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEpG,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACvF,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AACxF,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEpF,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,EACZ,OAAO,EACP,aAAa,EACb,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,cAAc,EACd,cAAc,EACd,SAAS,GACV,MAAM,kBAAkB,CAAC;AAW1B,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AACrG,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -1,4 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `kubectlApply` — apply a rendered manifest to a cluster.
|
|
3
|
+
*
|
|
4
|
+
* chant #1074 moved this off `kubectl apply -f`. The activity contract is
|
|
5
|
+
* unchanged (a manifest path, an optional context, `Promise<void>`, the
|
|
6
|
+
* `longInfra` profile's 15s heartbeat) because Temporal workers register it by
|
|
7
|
+
* that signature; what changed is underneath. The name is kept for the same
|
|
8
|
+
* reason.
|
|
9
|
+
*
|
|
10
|
+
* chant #1075 finished the job on two axes:
|
|
11
|
+
*
|
|
12
|
+
* - **Identity.** The field manager is no longer the bare `chant` but
|
|
13
|
+
* `chant:<stack>`, derived from the project's `ownership.stack` — the same
|
|
14
|
+
* identity the ownership label already carries. See
|
|
15
|
+
* `@intentius/chant-k8s-client`'s `field-manager.ts`.
|
|
16
|
+
* - **Deletes.** `nativeApply`'s kubectl branch used to shell
|
|
17
|
+
* `kubectl apply --prune --selector <marker>`; that branch now routes here,
|
|
18
|
+
* so the prune had to come with it. {@link applyManifest} implements it
|
|
19
|
+
* against the typed client, scoped to the ownership marker exactly as the
|
|
20
|
+
* shelled prune was, and never touching an object that does not carry it.
|
|
21
|
+
*
|
|
22
|
+
* Consequences worth knowing:
|
|
23
|
+
*
|
|
24
|
+
* - **A worker image needs no `kubectl` binary.** That was the point.
|
|
25
|
+
* - **It is a server-side apply**, rather than the client-side three-way merge
|
|
26
|
+
* `kubectl apply` performs by default. A conflict with another field manager
|
|
27
|
+
* arrives as a `FieldManagerConflictError` naming the competing manager and
|
|
28
|
+
* the contested paths — never as a silent overwrite, and never force-resolved
|
|
29
|
+
* on chant's initiative.
|
|
30
|
+
* - **Documents apply in file order**, as `kubectl apply -f` does, and a
|
|
31
|
+
* directory's files are read in sorted order.
|
|
32
|
+
*/
|
|
33
|
+
import { type K8sConnector } from "../../api/connect.js";
|
|
34
|
+
/**
|
|
35
|
+
* How the apply treats chant-owned objects that are no longer declared. The
|
|
36
|
+
* same three values `nativeApply` has always taken; `gated` differs from
|
|
37
|
+
* `owned-only` only in that the workflow pauses for approval first, which is
|
|
38
|
+
* the composite's business, not this activity's.
|
|
39
|
+
*/
|
|
40
|
+
export type ApplyDeleteMode = "never" | "owned-only" | "gated";
|
|
1
41
|
export interface KubectlApplyArgs {
|
|
42
|
+
/** Path to a manifest file, or a directory of them. */
|
|
2
43
|
manifest: string;
|
|
3
44
|
/**
|
|
4
45
|
* kubectl context name. Uses the ambient context if omitted. To target the
|
|
@@ -7,10 +48,87 @@ export interface KubectlApplyArgs {
|
|
|
7
48
|
* `./index.ts` and pass `.context` through.
|
|
8
49
|
*/
|
|
9
50
|
context?: string;
|
|
51
|
+
/**
|
|
52
|
+
* chant environment, used to resolve `k8s.profiles.<env>.context` when no
|
|
53
|
+
* explicit `context` is given. Optional and additive: omitting both keeps
|
|
54
|
+
* the previous behavior of using whatever the kubeconfig selects.
|
|
55
|
+
*/
|
|
56
|
+
environment?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Field manager recorded on the applied fields. Omitted derives it from the
|
|
59
|
+
* project's `ownership.stack` (chant #1075) — `chant:<stack>`, or the bare
|
|
60
|
+
* `chant` when the project sets none.
|
|
61
|
+
*/
|
|
62
|
+
fieldManager?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Ownership stack, when the caller already knows it and would rather not
|
|
65
|
+
* have the project config read. Ignored if `fieldManager` is set.
|
|
66
|
+
*/
|
|
67
|
+
stack?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Take ownership of fields another manager owns instead of failing with a
|
|
70
|
+
* `FieldManagerConflictError`. **Never defaulted on** — see chant #1075.
|
|
71
|
+
*/
|
|
72
|
+
force?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Delete chant-owned objects that are no longer declared. Default `never`.
|
|
75
|
+
* Deletes are scoped to the ownership marker, so an object chant did not
|
|
76
|
+
* stamp is never a candidate.
|
|
77
|
+
*/
|
|
78
|
+
deleteMode?: ApplyDeleteMode;
|
|
79
|
+
/**
|
|
80
|
+
* Server-side dry run — every document is validated and would-be-applied,
|
|
81
|
+
* nothing is persisted, and pruning is skipped entirely (a prune candidate
|
|
82
|
+
* list computed from a state that was never written would be misleading).
|
|
83
|
+
* Optional and additive (chant #1079): `chant kube apply`'s confirmation
|
|
84
|
+
* gate uses this to preview an apply before anything mutates the cluster;
|
|
85
|
+
* Op callers keep the previous behavior by leaving it unset.
|
|
86
|
+
*/
|
|
87
|
+
dryRun?: boolean;
|
|
88
|
+
/** Project directory whose `chant.config.ts` carries `ownership`. Defaults to cwd. */
|
|
89
|
+
cwd?: string;
|
|
90
|
+
}
|
|
91
|
+
/** One object the apply touched. */
|
|
92
|
+
export interface AppliedRef {
|
|
93
|
+
apiVersion: string;
|
|
94
|
+
kind: string;
|
|
95
|
+
name: string;
|
|
96
|
+
namespace?: string;
|
|
10
97
|
}
|
|
98
|
+
/** What {@link applyManifest} did. */
|
|
99
|
+
export interface ApplyManifestResult {
|
|
100
|
+
/** The field manager every object was applied as. */
|
|
101
|
+
fieldManager: string;
|
|
102
|
+
applied: AppliedRef[];
|
|
103
|
+
/** Objects deleted because they carried chant's marker and are no longer declared. */
|
|
104
|
+
pruned: AppliedRef[];
|
|
105
|
+
}
|
|
106
|
+
/** Read a manifest path — one file, or every YAML/JSON file in a directory. */
|
|
107
|
+
export declare function readManifestDocuments(path: string): Record<string, unknown>[];
|
|
108
|
+
/**
|
|
109
|
+
* The field manager to apply as: an explicit one, else `chant:<stack>` from a
|
|
110
|
+
* caller-supplied stack, else `chant:<stack>` from the project's `ownership`
|
|
111
|
+
* config, else the bare `chant`.
|
|
112
|
+
*
|
|
113
|
+
* A project config that cannot be read falls back to the bare `chant` with a
|
|
114
|
+
* warning rather than failing the apply — an activity handed a manifest path
|
|
115
|
+
* and nothing else is a supported way to call this, and its cwd need not be a
|
|
116
|
+
* chant project at all. The warning is there because a *silent* downgrade
|
|
117
|
+
* would change which fields chant owns without saying so.
|
|
118
|
+
*/
|
|
119
|
+
export declare function resolveFieldManager(args: KubectlApplyArgs): Promise<string>;
|
|
120
|
+
/**
|
|
121
|
+
* Apply every document in `args.manifest`, then prune when asked.
|
|
122
|
+
*
|
|
123
|
+
* Returns what it did. `kubectlApply` is the registered activity and keeps its
|
|
124
|
+
* `Promise<void>` contract; this is the function `nativeApply` calls, because a
|
|
125
|
+
* dispatcher that reports "applied 12, pruned 2" is worth more than one that
|
|
126
|
+
* reports the shell command it ran.
|
|
127
|
+
*/
|
|
128
|
+
export declare function applyManifest(args: KubectlApplyArgs, signal?: AbortSignal, connect?: K8sConnector): Promise<ApplyManifestResult>;
|
|
11
129
|
/**
|
|
12
|
-
*
|
|
130
|
+
* Apply every document in `args.manifest`.
|
|
13
131
|
* Uses longInfra profile — 20m timeout, heartbeat every 15s.
|
|
14
132
|
*/
|
|
15
|
-
export declare function kubectlApply(args: KubectlApplyArgs, signal?: AbortSignal): Promise<void>;
|
|
133
|
+
export declare function kubectlApply(args: KubectlApplyArgs, signal?: AbortSignal, connect?: K8sConnector): Promise<void>;
|
|
16
134
|
//# sourceMappingURL=kubectl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kubectl.d.ts","sourceRoot":"","sources":["../../../src/op/activities/kubectl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kubectl.d.ts","sourceRoot":"","sources":["../../../src/op/activities/kubectl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAaH,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAI3E;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,YAAY,GAAG,OAAO,CAAC;AAE/D,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD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tB,MAAM,CAAC,EAAE,WAAW,EACpB,OAAO,GAAE,YAAkC,GAC1C,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type K8sConnector } from "../../api/connect.js";
|
|
1
2
|
/**
|
|
2
3
|
* waitForReady — block until any operator-backed Kubernetes resource reports
|
|
3
4
|
* ready, driven by a data-only **readiness spec** rather than per-CRD code.
|
|
@@ -5,9 +6,16 @@
|
|
|
5
6
|
* Like `waitForArgoSync`, this activity is intentionally **dependency-light**:
|
|
6
7
|
* its signature is primitives + a plain readiness spec, so a Temporal worker
|
|
7
8
|
* loads it without importing the generated CRD declarable surface. It reads the
|
|
8
|
-
* resource
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* resource and evaluates the spec's predicates. It generalizes the bespoke
|
|
10
|
+
* `waitForArgoSync` / `waitForStack` waits — see #365.
|
|
11
|
+
*
|
|
12
|
+
* chant #1074 moved the read from `kubectl get -o json` to the typed API
|
|
13
|
+
* client, so a worker image needs no `kubectl` binary. The signature is
|
|
14
|
+
* unchanged — `kind` is still whatever `kubectl get` accepts, because that is
|
|
15
|
+
* what every existing caller passes, and the client resolves it through the
|
|
16
|
+
* cluster's own API discovery exactly as kubectl does: plural, then singular,
|
|
17
|
+
* then kind, then short name, with anything after the first dot read as the
|
|
18
|
+
* API group.
|
|
11
19
|
*/
|
|
12
20
|
/** Match a Kubernetes-style `status.conditions[]` entry by `type`. */
|
|
13
21
|
export interface ConditionMatch {
|
|
@@ -72,6 +80,11 @@ export interface WaitForReadyArgs {
|
|
|
72
80
|
* `.context` through.
|
|
73
81
|
*/
|
|
74
82
|
context?: string;
|
|
83
|
+
/**
|
|
84
|
+
* chant environment, used to resolve `k8s.profiles.<env>.context` when no
|
|
85
|
+
* explicit `context` is given. Optional and additive.
|
|
86
|
+
*/
|
|
87
|
+
environment?: string;
|
|
75
88
|
/** API group, used to pick a readiness override when `spec` is not given. */
|
|
76
89
|
group?: string;
|
|
77
90
|
/** Explicit readiness spec — wins over the registry/default. */
|
|
@@ -81,6 +94,20 @@ export interface WaitForReadyArgs {
|
|
|
81
94
|
}
|
|
82
95
|
/** Pluggable resource reader — overridden in tests with a fake. */
|
|
83
96
|
export type ResourceFetcher = (args: WaitForReadyArgs, signal?: AbortSignal) => Promise<Record<string, unknown>>;
|
|
97
|
+
/**
|
|
98
|
+
* Read the resource through the typed API client.
|
|
99
|
+
*
|
|
100
|
+
* A client is built once per `waitForReady` call and reused for every poll, so
|
|
101
|
+
* a 20-minute wait does not re-parse the kubeconfig or re-invoke an exec
|
|
102
|
+
* credential plugin on each iteration — and neither does it re-run discovery,
|
|
103
|
+
* which the client caches per API version.
|
|
104
|
+
*/
|
|
105
|
+
export declare function apiResourceFetcher(connect?: K8sConnector): ResourceFetcher;
|
|
106
|
+
/**
|
|
107
|
+
* The production reader. Each call builds its own fetcher, so nothing is
|
|
108
|
+
* shared between two unrelated waits; a single `waitForReady` passes one
|
|
109
|
+
* fetcher through all of its polls, which is where the caching matters.
|
|
110
|
+
*/
|
|
84
111
|
export declare const defaultResourceFetcher: ResourceFetcher;
|
|
85
112
|
/**
|
|
86
113
|
* Poll until the resource satisfies its readiness spec. Throws
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait-for-ready.d.ts","sourceRoot":"","sources":["../../../src/op/activities/wait-for-ready.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wait-for-ready.d.ts","sourceRoot":"","sources":["../../../src/op/activities/wait-for-ready.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE3E;;;;;;;;;;;;;;;;;GAiBG;AAIH,sEAAsE;AACtE,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,2DAA2D;AAC3D,MAAM,WAAW,SAAS;IACxB,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;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,mEAAmE;AACnE,MAAM,MAAM,eAAe,GAAG,CAC5B,IAAI,EAAE,gBAAgB,EACtB,MAAM,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEtC;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,YAAkC,GAAG,eAAe,CAmC/F;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,eAAsE,CAAC;AAE5G;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,gBAAgB,EACtB,MAAM,CAAC,EAAE,WAAW,EACpB,OAAO,GAAE,eAAsC,GAC9C,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAuBlC"}
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAqC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAqC,MAAM,0BAA0B,CAAC;AAsBjG,eAAO,MAAM,SAAS,EAAE,aA2mBvB,CAAC"}
|