@alchemy.run/kubernetes 0.0.0 → 2.0.0-beta.84

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.
Files changed (94) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +41 -4
  3. package/lib/BuiltinAdapters.d.ts +23 -0
  4. package/lib/BuiltinAdapters.d.ts.map +1 -0
  5. package/lib/BuiltinAdapters.js +124 -0
  6. package/lib/BuiltinAdapters.js.map +1 -0
  7. package/lib/Client.d.ts +80 -0
  8. package/lib/Client.d.ts.map +1 -0
  9. package/lib/Client.js +296 -0
  10. package/lib/Client.js.map +1 -0
  11. package/lib/ClusterAdapter.d.ts +322 -0
  12. package/lib/ClusterAdapter.d.ts.map +1 -0
  13. package/lib/ClusterAdapter.js +65 -0
  14. package/lib/ClusterAdapter.js.map +1 -0
  15. package/lib/Connection.d.ts +210 -0
  16. package/lib/Connection.d.ts.map +1 -0
  17. package/lib/Connection.js +58 -0
  18. package/lib/Connection.js.map +1 -0
  19. package/lib/Deployment.d.ts +382 -0
  20. package/lib/Deployment.d.ts.map +1 -0
  21. package/lib/Deployment.js +533 -0
  22. package/lib/Deployment.js.map +1 -0
  23. package/lib/HelmChart.d.ts +147 -0
  24. package/lib/HelmChart.d.ts.map +1 -0
  25. package/lib/HelmChart.js +248 -0
  26. package/lib/HelmChart.js.map +1 -0
  27. package/lib/Job.d.ts +314 -0
  28. package/lib/Job.d.ts.map +1 -0
  29. package/lib/Job.js +426 -0
  30. package/lib/Job.js.map +1 -0
  31. package/lib/LocalCluster.d.ts +243 -0
  32. package/lib/LocalCluster.d.ts.map +1 -0
  33. package/lib/LocalCluster.js +359 -0
  34. package/lib/LocalCluster.js.map +1 -0
  35. package/lib/Manifest.d.ts +148 -0
  36. package/lib/Manifest.d.ts.map +1 -0
  37. package/lib/Manifest.js +200 -0
  38. package/lib/Manifest.js.map +1 -0
  39. package/lib/Objects.d.ts +60 -0
  40. package/lib/Objects.d.ts.map +1 -0
  41. package/lib/Objects.js +132 -0
  42. package/lib/Objects.js.map +1 -0
  43. package/lib/Providers.d.ts +24 -0
  44. package/lib/Providers.d.ts.map +1 -0
  45. package/lib/Providers.js +36 -0
  46. package/lib/Providers.js.map +1 -0
  47. package/lib/index.d.ts +10 -0
  48. package/lib/index.d.ts.map +1 -0
  49. package/lib/index.js +10 -0
  50. package/lib/index.js.map +1 -0
  51. package/lib/internal/declared.d.ts +19 -0
  52. package/lib/internal/declared.d.ts.map +1 -0
  53. package/lib/internal/declared.js +435 -0
  54. package/lib/internal/declared.js.map +1 -0
  55. package/lib/internal/helm.d.ts +65 -0
  56. package/lib/internal/helm.d.ts.map +1 -0
  57. package/lib/internal/helm.js +173 -0
  58. package/lib/internal/helm.js.map +1 -0
  59. package/lib/internal/kind.d.ts +17 -0
  60. package/lib/internal/kind.d.ts.map +1 -0
  61. package/lib/internal/kind.js +31 -0
  62. package/lib/internal/kind.js.map +1 -0
  63. package/lib/internal/kubeconfig.d.ts +79 -0
  64. package/lib/internal/kubeconfig.d.ts.map +1 -0
  65. package/lib/internal/kubeconfig.js +222 -0
  66. package/lib/internal/kubeconfig.js.map +1 -0
  67. package/lib/internal/registry.d.ts +44 -0
  68. package/lib/internal/registry.d.ts.map +1 -0
  69. package/lib/internal/registry.js +72 -0
  70. package/lib/internal/registry.js.map +1 -0
  71. package/lib/internal/workload.d.ts +127 -0
  72. package/lib/internal/workload.d.ts.map +1 -0
  73. package/lib/internal/workload.js +411 -0
  74. package/lib/internal/workload.js.map +1 -0
  75. package/package.json +55 -3
  76. package/src/BuiltinAdapters.ts +194 -0
  77. package/src/Client.ts +465 -0
  78. package/src/ClusterAdapter.ts +370 -0
  79. package/src/Connection.ts +234 -0
  80. package/src/Deployment.ts +851 -0
  81. package/src/HelmChart.ts +388 -0
  82. package/src/Job.ts +689 -0
  83. package/src/LocalCluster.ts +631 -0
  84. package/src/Manifest.ts +295 -0
  85. package/src/Objects.ts +213 -0
  86. package/src/Providers.ts +52 -0
  87. package/src/globals.d.ts +2 -0
  88. package/src/index.ts +9 -0
  89. package/src/internal/declared.ts +471 -0
  90. package/src/internal/helm.ts +245 -0
  91. package/src/internal/kind.ts +43 -0
  92. package/src/internal/kubeconfig.ts +364 -0
  93. package/src/internal/registry.ts +108 -0
  94. package/src/internal/workload.ts +503 -0
@@ -0,0 +1,173 @@
1
+ import { unwrapRedacted } from "alchemy/Util/data";
2
+ import { collectRedactedSecrets, redactJson } from "alchemy/Util/Redaction";
3
+ /**
4
+ * Internal Helm rendering for `Kubernetes.HelmChart`.
5
+ *
6
+ * Renders a chart to plain Kubernetes objects with the local `helm` CLI
7
+ * (`helm template` — pure local templating, no cluster connection, no
8
+ * in-cluster release records), so the rendered objects flow through the same
9
+ * server-side-apply machinery as `Kubernetes.Manifest` and the workload platforms.
10
+ * Mirrors the `Docker` service's local-CLI dependency: the `helm` binary
11
+ * must be installed on the deploying machine (`HELM_BIN` overrides the
12
+ * binary path).
13
+ */
14
+ import * as Config from "effect/Config";
15
+ import * as Data from "effect/Data";
16
+ import * as Effect from "effect/Effect";
17
+ import * as FileSystem from "effect/FileSystem";
18
+ import * as Path from "effect/Path";
19
+ import * as ChildProcess from "effect/process/ChildProcess";
20
+ import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
21
+ import * as Stream from "effect/Stream";
22
+ import * as YAML from "yaml";
23
+ /** A Helm invocation or render failure (bad chart ref, template error, …). */
24
+ export class HelmError extends Data.TaggedError("HelmError") {
25
+ }
26
+ const HelmBin = Config.String("HELM_BIN").pipe(Effect.orElseSucceed(() => "helm"));
27
+ /**
28
+ * Render a chart with `helm template --no-hooks` and parse the
29
+ * multi-document YAML output into object definitions. Every rendered object
30
+ * must carry `apiVersion`, `kind`, and `metadata.name` (server-side apply
31
+ * needs a name; `generateName`-only objects are rejected with a clear
32
+ * error). Helm lifecycle hooks are excluded from the result (see
33
+ * {@link isHelmHook}).
34
+ */
35
+ export const renderHelmChart = Effect.fn(function* (options) {
36
+ const fs = yield* FileSystem.FileSystem;
37
+ const path = yield* Path.Path;
38
+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
39
+ const bin = yield* HelmBin;
40
+ const secrets = yield* Effect.sync(() => options.values === undefined ? [] : collectRedactedSecrets(options.values));
41
+ // The values file holds unwrapped credentials. Close this scope when the
42
+ // render finishes, including on helm or parse failure, so the file is removed.
43
+ return yield* Effect.scoped(Effect.gen(function* () {
44
+ const args = [
45
+ "template",
46
+ options.releaseName,
47
+ options.chart,
48
+ "--namespace",
49
+ options.namespace,
50
+ // Helm lifecycle hooks (`helm.sh/hook`) only make sense under Helm's own
51
+ // release events; HelmChart server-side applies the render and does not
52
+ // implement hook timing/weights/delete policies, so a hook (e.g. a
53
+ // pre-delete uninstall Job) must never enter the managed-object graph.
54
+ "--no-hooks",
55
+ ];
56
+ if (options.repo !== undefined) {
57
+ args.push("--repo", options.repo);
58
+ }
59
+ if (options.version !== undefined) {
60
+ args.push("--version", options.version);
61
+ }
62
+ if (options.includeCrds ?? true) {
63
+ args.push("--include-crds");
64
+ }
65
+ if (options.values !== undefined && Object.keys(options.values).length > 0) {
66
+ // JSON is valid YAML, so the literal values object round-trips through
67
+ // a temp values file without a YAML serializer.
68
+ const dir = yield* fs.makeTempDirectoryScoped({
69
+ prefix: "alchemy-helm-",
70
+ });
71
+ const valuesFile = path.join(dir, "values.json");
72
+ // JSON.stringify(Redacted) emits the display placeholder. Unwrap at the
73
+ // values file; the chart props stay wrapped for plan and state.
74
+ const valuesJson = yield* Effect.sync(() => JSON.stringify(unwrapRedacted(options.values)));
75
+ yield* fs.writeFileString(valuesFile, valuesJson);
76
+ args.push("--values", valuesFile);
77
+ }
78
+ const result = yield* ChildProcess.make(bin, args, {
79
+ stdin: "ignore",
80
+ stdout: "pipe",
81
+ stderr: "pipe",
82
+ detached: false,
83
+ extendEnv: true,
84
+ }).pipe(spawner.spawn, Effect.flatMap((child) => Effect.all({
85
+ exitCode: child.exitCode,
86
+ stdout: child.stdout.pipe(Stream.decodeText, Stream.mkString),
87
+ stderr: child.stderr.pipe(Stream.decodeText, Stream.mkString),
88
+ }, { concurrency: "unbounded" })),
89
+ // Scope the child to this render so it isn't tied to (and killed by)
90
+ // an enclosing scope that closes before helm exits.
91
+ Effect.scoped,
92
+ // A spawn failure (almost always ENOENT) means the helm CLI itself is
93
+ // missing — a machine-setup problem, not a resource error.
94
+ Effect.catchCause((cause) => Effect.die(new Error(`Failed to run '${bin}': ${String(cause)}. Kubernetes.HelmChart renders charts with the local helm CLI; if it isn't installed, install it (https://helm.sh/docs/intro/install/) or point HELM_BIN at the binary.`))));
95
+ if (result.exitCode !== 0) {
96
+ const detail = `helm ${args.join(" ")} exited with code ${String(result.exitCode)}: ` +
97
+ result.stderr.trim();
98
+ return yield* Effect.failSync(() => new HelmError({ message: redactJson(detail, secrets) }));
99
+ }
100
+ return yield* parseRenderedManifests(options.chart, result.stdout, secrets);
101
+ }));
102
+ });
103
+ /**
104
+ * Whether a rendered object is a Helm lifecycle hook (`helm.sh/hook`
105
+ * annotation). Hooks are executed by Helm at release events (pre-install,
106
+ * pre-delete, test, …); HelmChart has no release and no hook lifecycle, so
107
+ * they are filtered out rather than applied as ordinary objects.
108
+ */
109
+ export const isHelmHook = (object) => typeof object.metadata.annotations?.["helm.sh/hook"] === "string";
110
+ const causeText = (cause) => cause instanceof Error ? cause.message : String(cause);
111
+ /**
112
+ * Parse `helm template` output (multi-document YAML) into definitions.
113
+ * Hook-annotated objects are dropped — `renderHelmChart` already passes
114
+ * `--no-hooks`, but the parser enforces the invariant independently of the
115
+ * helm CLI's behavior.
116
+ *
117
+ * `secrets` scrubs credentials out of parser and validation diagnostics.
118
+ * Parsed objects stay plain; callers pass the same list to the request
119
+ * scrubber.
120
+ */
121
+ export const parseRenderedManifests = (chart, rendered, secrets = []) => Effect.try({
122
+ try: () => parseRenderedManifestsSync(chart, rendered, secrets),
123
+ catch: (cause) => cause instanceof HelmError
124
+ ? cause
125
+ : new HelmError({
126
+ message: redactJson(`Failed to parse rendered manifests from chart '${chart}': ${causeText(cause)}`, secrets),
127
+ }),
128
+ });
129
+ const parseRenderedManifestsSync = (chart, rendered, secrets) => {
130
+ const fail = (message) => {
131
+ throw new HelmError({ message: redactJson(message, secrets) });
132
+ };
133
+ // Helm 4 writes OCI pull metadata to stdout before the rendered YAML.
134
+ // Strip only that exact leading preamble; chart output remains subject to
135
+ // the same strict Kubernetes object validation below.
136
+ const manifests = chart.startsWith("oci://")
137
+ ? rendered.replace(/^Pulled: [^\r\n]+\r?\nDigest: [^\r\n]+\r?\n(?=---(?:\r?\n|$))/, "")
138
+ : rendered;
139
+ const documents = YAML.parseAllDocuments(manifests);
140
+ const objects = [];
141
+ for (const document of documents) {
142
+ // parseAllDocuments records syntax errors on the document instead of
143
+ // throwing. toJS() can still throw (unresolved aliases, alias cycles).
144
+ if (document.errors.length > 0) {
145
+ const detail = document.errors.map((error) => error.message).join("\n");
146
+ fail(`Failed to parse rendered manifests from chart '${chart}': ${detail}`);
147
+ }
148
+ const value = document.toJS();
149
+ // helm renders empty documents for templates that produce no output
150
+ // (conditionals, whitespace) — skip them.
151
+ if (value === null || value === undefined)
152
+ continue;
153
+ if (typeof value !== "object" || Array.isArray(value)) {
154
+ fail(`Chart '${chart}' rendered a non-object YAML document: ${JSON.stringify(value)}`);
155
+ }
156
+ const object = value;
157
+ if (typeof object.apiVersion !== "string" || typeof object.kind !== "string") {
158
+ // Scrub the full JSON before truncating so a secret that crosses the
159
+ // 200-character boundary is removed entirely.
160
+ const snippet = redactJson(JSON.stringify(value), secrets).slice(0, 200);
161
+ fail(`Chart '${chart}' rendered an object without apiVersion/kind: ${snippet}`);
162
+ }
163
+ if (typeof object.metadata?.name !== "string") {
164
+ fail(`Chart '${chart}' rendered a ${object.apiVersion}/${object.kind} without metadata.name — server-side apply requires a concrete name (generateName is not supported)`);
165
+ }
166
+ const definition = object;
167
+ if (isHelmHook(definition))
168
+ continue;
169
+ objects.push(definition);
170
+ }
171
+ return objects;
172
+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1C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QACpD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACtD,IAAI,CAAC,UAAU,KAAK,0CAA0C,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzF,CAAC;QACD,MAAM,MAAM,GAAG,KAA4C,CAAC;QAC5D,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7E,qEAAqE;YACrE,8CAA8C;YAC9C,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YACzE,IAAI,CAAC,UAAU,KAAK,iDAAiD,OAAO,EAAE,CAAC,CAAC;QAClF,CAAC;QACD,IAAI,OAAO,MAAM,CAAC,QAAQ,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9C,IAAI,CACF,UAAU,KAAK,gBAAgB,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,qGAAqG,CACrK,CAAC;QACJ,CAAC;QACD,MAAM,UAAU,GAAG,MAAoC,CAAC;QACxD,IAAI,UAAU,CAAC,UAAU,CAAC;YAAE,SAAS;QACrC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { KindClusterConfig, LocalClusterProps } from "../LocalCluster.ts";
2
+ /**
3
+ * containerd patch enabling the per-registry `hosts.toml` directory that
4
+ * points `localhost:<registryPort>` at the local registry container. The
5
+ * default on kind v0.27+ node images; kept for older ones
6
+ * (https://kind.sigs.k8s.io/docs/user/local-registry/).
7
+ */
8
+ export declare const REGISTRY_CONTAINERD_PATCH = "[plugins.\"io.containerd.grpc.v1.cri\".registry]\n config_path = \"/etc/containerd/certs.d\"";
9
+ /** The kind config fields of a `LocalCluster`'s props. */
10
+ export declare const kindConfigOf: ({ nodes, networking, featureGates, runtimeConfig, kubeadmConfigPatches, kubeadmConfigPatchesJSON6902, containerdConfigPatches, containerdConfigPatchesJSON6902, }: Partial<LocalClusterProps>) => KindClusterConfig;
11
+ /**
12
+ * The kind cluster config `LocalCluster` passes to `kind create cluster`:
13
+ * the kind fields with the kind/apiVersion header and the registry
14
+ * containerd patch added. kind reads YAML, and JSON is valid YAML.
15
+ */
16
+ export declare const kindClusterConfig: (config: KindClusterConfig) => any;
17
+ //# sourceMappingURL=kind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kind.d.ts","sourceRoot":"","sources":["../../src/internal/kind.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE/E;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,kGACI,CAAC;AAE3C,0DAA0D;AAC1D,eAAO,MAAM,YAAY,sKAStB,OAAO,CAAC,iBAAiB,CAAC,KAAG,iBAS9B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,WAAY,iBAAiB,QAKzD,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * containerd patch enabling the per-registry `hosts.toml` directory that
3
+ * points `localhost:<registryPort>` at the local registry container. The
4
+ * default on kind v0.27+ node images; kept for older ones
5
+ * (https://kind.sigs.k8s.io/docs/user/local-registry/).
6
+ */
7
+ export const REGISTRY_CONTAINERD_PATCH = `[plugins."io.containerd.grpc.v1.cri".registry]
8
+ config_path = "/etc/containerd/certs.d"`;
9
+ /** The kind config fields of a `LocalCluster`'s props. */
10
+ export const kindConfigOf = ({ nodes, networking, featureGates, runtimeConfig, kubeadmConfigPatches, kubeadmConfigPatchesJSON6902, containerdConfigPatches, containerdConfigPatchesJSON6902, }) => ({
11
+ nodes,
12
+ networking,
13
+ featureGates,
14
+ runtimeConfig,
15
+ kubeadmConfigPatches,
16
+ kubeadmConfigPatchesJSON6902,
17
+ containerdConfigPatches,
18
+ containerdConfigPatchesJSON6902,
19
+ });
20
+ /**
21
+ * The kind cluster config `LocalCluster` passes to `kind create cluster`:
22
+ * the kind fields with the kind/apiVersion header and the registry
23
+ * containerd patch added. kind reads YAML, and JSON is valid YAML.
24
+ */
25
+ export const kindClusterConfig = (config) => ({
26
+ kind: "Cluster",
27
+ apiVersion: "kind.x-k8s.io/v1alpha4",
28
+ ...JSON.parse(JSON.stringify(config)),
29
+ containerdConfigPatches: [...(config.containerdConfigPatches ?? []), REGISTRY_CONTAINERD_PATCH],
30
+ });
31
+ //# sourceMappingURL=kind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kind.js","sourceRoot":"","sources":["../../src/internal/kind.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;0CACC,CAAC;AAE3C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAC3B,KAAK,EACL,UAAU,EACV,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,4BAA4B,EAC5B,uBAAuB,EACvB,+BAA+B,GACJ,EAAqB,EAAE,CAAC,CAAC;IACpD,KAAK;IACL,UAAU;IACV,YAAY;IACZ,aAAa;IACb,oBAAoB;IACpB,4BAA4B;IAC5B,uBAAuB;IACvB,+BAA+B;CAChC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAyB,EAAE,EAAE,CAAC,CAAC;IAC/D,IAAI,EAAE,SAAS;IACf,UAAU,EAAE,wBAAwB;IACpC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACrC,uBAAuB,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,uBAAuB,IAAI,EAAE,CAAC,EAAE,yBAAyB,CAAC;CAChG,CAAC,CAAC"}
@@ -0,0 +1,79 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as FileSystem from "effect/FileSystem";
3
+ import * as Path from "effect/Path";
4
+ import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
5
+ declare const KubeConfigError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
6
+ readonly _tag: "Kubernetes.KubeConfigError";
7
+ } & Readonly<A>;
8
+ /** A kubeconfig file could not be read, parsed, or resolved. */
9
+ export declare class KubeConfigError extends KubeConfigError_base<{
10
+ readonly message: string;
11
+ readonly cause?: unknown;
12
+ }> {
13
+ }
14
+ declare const ExecCredentialError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
15
+ readonly _tag: "Kubernetes.ExecCredentialError";
16
+ } & Readonly<A>;
17
+ /** An exec credential plugin invocation failed or answered malformed. */
18
+ export declare class ExecCredentialError extends ExecCredentialError_base<{
19
+ readonly message: string;
20
+ readonly cause?: unknown;
21
+ }> {
22
+ }
23
+ interface KubeConfigUser {
24
+ token?: string;
25
+ tokenFile?: string;
26
+ "client-certificate"?: string;
27
+ "client-certificate-data"?: string;
28
+ "client-key"?: string;
29
+ "client-key-data"?: string;
30
+ exec?: {
31
+ command?: string;
32
+ args?: string[];
33
+ env?: {
34
+ name?: string;
35
+ value?: string;
36
+ }[];
37
+ apiVersion?: string;
38
+ };
39
+ }
40
+ /** The resolved connection material for one kubeconfig context. */
41
+ export interface ResolvedKubeContext {
42
+ endpoint: string;
43
+ certificateAuthorityData?: string;
44
+ insecureSkipTlsVerify?: boolean;
45
+ user: KubeConfigUser;
46
+ }
47
+ /** Resolve the kubeconfig file path: explicit → `$KUBECONFIG` → default. */
48
+ export declare const resolveKubeConfigPath: (explicit: string | undefined) => Effect.Effect<string, KubeConfigError, Path.Path>;
49
+ /** Load a kubeconfig file and resolve one context to its cluster + user. */
50
+ export declare const resolveKubeContext: (options: {
51
+ path?: string;
52
+ context?: string;
53
+ }) => Effect.Effect<{
54
+ endpoint: string;
55
+ certificateAuthorityData: string | undefined;
56
+ insecureSkipTlsVerify: boolean | undefined;
57
+ user: KubeConfigUser;
58
+ }, KubeConfigError, FileSystem.FileSystem | Path.Path>;
59
+ /** Credentials minted by a user's auth stanza for one request. */
60
+ export interface MintedCredentials {
61
+ token?: string;
62
+ clientCert?: {
63
+ certificate: string;
64
+ key: string;
65
+ };
66
+ }
67
+ /**
68
+ * Run a kubeconfig-style exec credential plugin and parse its
69
+ * ExecCredential response.
70
+ */
71
+ export declare const runExecCredential: (options: {
72
+ command: string;
73
+ args?: string[] | undefined;
74
+ env?: Record<string, string> | undefined;
75
+ }) => Effect.Effect<MintedCredentials, ExecCredentialError, ChildProcessSpawner.ChildProcessSpawner>;
76
+ /** Mint request credentials from a kubeconfig user's auth stanza. */
77
+ export declare const mintUserCredentials: (user: KubeConfigUser) => Effect.Effect<MintedCredentials, ExecCredentialError | KubeConfigError, ChildProcessSpawner.ChildProcessSpawner | FileSystem.FileSystem | Path.Path>;
78
+ export {};
79
+ //# sourceMappingURL=kubeconfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kubeconfig.d.ts","sourceRoot":"","sources":["../../src/internal/kubeconfig.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,OAAO,KAAK,mBAAmB,MAAM,oCAAoC,CAAC;;;;AAI1E,gEAAgE;AAChE,qBAAa,eAAgB,SAAQ,qBAA+C;IAClF,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,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CACnD;AAOD;;;GAGG;AACH,eAAO,MAAM,iBAAiB;aACnB,MAAM;WACR,MAAM,EAAE,GAAG,SAAS;UACrB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS;oGAoFxC,CAAC;AAEH,qEAAqE;AACrE,eAAO,MAAM,mBAAmB,gLA+E9B,CAAC"}
@@ -0,0 +1,222 @@
1
+ /**
2
+ * Internal kubeconfig resolution for the built-in cluster adapters: parse a
3
+ * kubeconfig file, resolve a context to (cluster, user), and turn its auth
4
+ * stanza — static token, client certificate, or `exec` credential plugin —
5
+ * into a {@link ClusterTransport}. This is the "anything kubectl can reach"
6
+ * path: AKS/GKE/EKS CLI-managed contexts work through their exec plugins
7
+ * (`kubelogin`, `gke-gcloud-auth-plugin`, `aws eks get-token`).
8
+ */
9
+ import * as Config from "effect/Config";
10
+ import * as Data from "effect/Data";
11
+ import * as Effect from "effect/Effect";
12
+ import * as FileSystem from "effect/FileSystem";
13
+ import * as Path from "effect/Path";
14
+ import * as ChildProcess from "effect/process/ChildProcess";
15
+ import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
16
+ import * as Stream from "effect/Stream";
17
+ import * as YAML from "yaml";
18
+ /** A kubeconfig file could not be read, parsed, or resolved. */
19
+ export class KubeConfigError extends Data.TaggedError("Kubernetes.KubeConfigError") {
20
+ }
21
+ /** An exec credential plugin invocation failed or answered malformed. */
22
+ export class ExecCredentialError extends Data.TaggedError("Kubernetes.ExecCredentialError") {
23
+ }
24
+ const decodeBase64 = (value) => Buffer.from(value, "base64").toString("utf8");
25
+ const expandHome = Effect.fn(function* (input) {
26
+ if (!input.startsWith("~"))
27
+ return input;
28
+ const home = yield* Effect.sync(() => process.env.HOME ?? process.env.USERPROFILE);
29
+ if (!home) {
30
+ return yield* new KubeConfigError({
31
+ message: `Cannot expand '${input}': no HOME environment variable`,
32
+ });
33
+ }
34
+ const path = yield* Path.Path;
35
+ return path.join(home, input.slice(1));
36
+ });
37
+ /** Resolve the kubeconfig file path: explicit → `$KUBECONFIG` → default. */
38
+ export const resolveKubeConfigPath = Effect.fn(function* (explicit) {
39
+ if (explicit)
40
+ return yield* expandHome(explicit);
41
+ const fromEnv = yield* Config.String("KUBECONFIG").pipe(Effect.orElseSucceed(() => undefined));
42
+ // $KUBECONFIG may be a path list; use the first entry like kubectl's
43
+ // effective-config merge order.
44
+ const candidate = fromEnv?.split(":")[0];
45
+ if (candidate)
46
+ return yield* expandHome(candidate);
47
+ return yield* expandHome("~/.kube/config");
48
+ });
49
+ /** Load a kubeconfig file and resolve one context to its cluster + user. */
50
+ export const resolveKubeContext = Effect.fn(function* (options) {
51
+ const fs = yield* FileSystem.FileSystem;
52
+ const configPath = yield* resolveKubeConfigPath(options.path);
53
+ const raw = yield* fs.readFileString(configPath).pipe(Effect.mapError((cause) => new KubeConfigError({
54
+ message: `Failed to read kubeconfig at '${configPath}'`,
55
+ cause,
56
+ })));
57
+ const parsed = yield* Effect.try({
58
+ try: () => YAML.parse(raw),
59
+ catch: (cause) => new KubeConfigError({
60
+ message: `Failed to parse kubeconfig at '${configPath}'`,
61
+ cause,
62
+ }),
63
+ });
64
+ const contextName = options.context ?? parsed["current-context"];
65
+ if (!contextName) {
66
+ return yield* new KubeConfigError({
67
+ message: `Kubeconfig '${configPath}' has no current-context — pass an explicit context`,
68
+ });
69
+ }
70
+ const context = parsed.contexts?.find((entry) => entry.name === contextName)?.context;
71
+ if (!context?.cluster) {
72
+ return yield* new KubeConfigError({
73
+ message: `Context '${contextName}' not found in kubeconfig '${configPath}'`,
74
+ });
75
+ }
76
+ const cluster = parsed.clusters?.find((entry) => entry.name === context.cluster)?.cluster;
77
+ if (!cluster?.server) {
78
+ return yield* new KubeConfigError({
79
+ message: `Cluster '${context.cluster}' (context '${contextName}') has no server in kubeconfig '${configPath}'`,
80
+ });
81
+ }
82
+ const user = parsed.users?.find((entry) => entry.name === context.user)?.user ?? {};
83
+ let certificateAuthorityData = cluster["certificate-authority-data"];
84
+ if (!certificateAuthorityData && cluster["certificate-authority"]) {
85
+ const caPath = yield* expandHome(cluster["certificate-authority"]);
86
+ const pem = yield* fs.readFileString(caPath).pipe(Effect.mapError((cause) => new KubeConfigError({
87
+ message: `Failed to read certificate authority file '${caPath}'`,
88
+ cause,
89
+ })));
90
+ certificateAuthorityData = Buffer.from(pem, "utf8").toString("base64");
91
+ }
92
+ return {
93
+ endpoint: cluster.server,
94
+ certificateAuthorityData,
95
+ insecureSkipTlsVerify: cluster["insecure-skip-tls-verify"],
96
+ user,
97
+ };
98
+ });
99
+ // Exec plugin invocations are cached per (command, args) until their
100
+ // expirationTimestamp (or briefly, when the plugin doesn't declare one).
101
+ // Plain cached values, no finalizers — module scope is safe.
102
+ const execCache = new Map();
103
+ /**
104
+ * Run a kubeconfig-style exec credential plugin and parse its
105
+ * ExecCredential response.
106
+ */
107
+ export const runExecCredential = Effect.fn(function* (options) {
108
+ const cacheKey = JSON.stringify([options.command, options.args ?? [], options.env ?? {}]);
109
+ const cached = execCache.get(cacheKey);
110
+ const now = yield* Effect.sync(() => Date.now());
111
+ if (cached && cached.expiresAt > now) {
112
+ return cached.credentials;
113
+ }
114
+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
115
+ // The child process is scoped to this invocation: spawn, drain stdio,
116
+ // and close the scope when the plugin exits.
117
+ const result = yield* ChildProcess.make(options.command, options.args ?? [], {
118
+ stdin: "ignore",
119
+ stdout: "pipe",
120
+ stderr: "pipe",
121
+ detached: false,
122
+ extendEnv: true,
123
+ env: options.env,
124
+ }).pipe(spawner.spawn, Effect.flatMap((child) => Effect.all({
125
+ exitCode: child.exitCode,
126
+ stdout: child.stdout.pipe(Stream.decodeText, Stream.mkString),
127
+ stderr: child.stderr.pipe(Stream.decodeText, Stream.mkString),
128
+ }, { concurrency: "unbounded" })), Effect.scoped, Effect.catchCause((cause) => Effect.fail(new ExecCredentialError({
129
+ message: `Failed to run exec credential plugin '${options.command}': ${String(cause)}`,
130
+ }))));
131
+ if (result.exitCode !== 0) {
132
+ return yield* new ExecCredentialError({
133
+ message: `Exec credential plugin '${options.command} ${(options.args ?? []).join(" ")}' ` +
134
+ `exited with code ${String(result.exitCode)}: ${result.stderr.trim()}`,
135
+ });
136
+ }
137
+ const status = yield* Effect.try({
138
+ try: () => JSON.parse(result.stdout).status,
139
+ catch: (cause) => new ExecCredentialError({
140
+ message: `Exec credential plugin '${options.command}' answered malformed JSON`,
141
+ cause,
142
+ }),
143
+ });
144
+ if (!status || (!status.token && !(status.clientCertificateData && status.clientKeyData))) {
145
+ return yield* new ExecCredentialError({
146
+ message: `Exec credential plugin '${options.command}' returned no token or client certificate`,
147
+ });
148
+ }
149
+ const credentials = {
150
+ token: status.token,
151
+ clientCert: status.clientCertificateData && status.clientKeyData
152
+ ? {
153
+ certificate: status.clientCertificateData,
154
+ key: status.clientKeyData,
155
+ }
156
+ : undefined,
157
+ };
158
+ const expiresAt = status.expirationTimestamp
159
+ ? // Re-mint 30s before the declared expiry.
160
+ new Date(status.expirationTimestamp).getTime() - 30_000
161
+ : // No declared expiry: cache briefly so bursts of requests share one
162
+ // plugin invocation without holding a stale credential for long.
163
+ now + 60_000;
164
+ execCache.set(cacheKey, { credentials, expiresAt });
165
+ return credentials;
166
+ });
167
+ /** Mint request credentials from a kubeconfig user's auth stanza. */
168
+ export const mintUserCredentials = Effect.fn(function* (user) {
169
+ if (user.exec?.command) {
170
+ return yield* runExecCredential({
171
+ command: user.exec.command,
172
+ args: user.exec.args,
173
+ env: user.exec.env
174
+ ? Object.fromEntries(user.exec.env
175
+ .filter((entry) => typeof entry.name === "string" && typeof entry.value === "string")
176
+ .map((entry) => [entry.name, entry.value]))
177
+ : undefined,
178
+ });
179
+ }
180
+ if (user.token) {
181
+ return { token: user.token };
182
+ }
183
+ if (user.tokenFile) {
184
+ const fs = yield* FileSystem.FileSystem;
185
+ const tokenPath = yield* expandHome(user.tokenFile);
186
+ const token = yield* fs.readFileString(tokenPath).pipe(Effect.mapError((cause) => new KubeConfigError({
187
+ message: `Failed to read token file '${tokenPath}'`,
188
+ cause,
189
+ })));
190
+ return { token: token.trim() };
191
+ }
192
+ const certData = user["client-certificate-data"];
193
+ const keyData = user["client-key-data"];
194
+ if (certData && keyData) {
195
+ return {
196
+ clientCert: {
197
+ certificate: decodeBase64(certData),
198
+ key: decodeBase64(keyData),
199
+ },
200
+ };
201
+ }
202
+ const certPath = user["client-certificate"];
203
+ const keyPath = user["client-key"];
204
+ if (certPath && keyPath) {
205
+ const fs = yield* FileSystem.FileSystem;
206
+ const readPem = (file) => expandHome(file).pipe(Effect.flatMap((resolved) => fs.readFileString(resolved).pipe(Effect.mapError((cause) => new KubeConfigError({
207
+ message: `Failed to read credential file '${resolved}'`,
208
+ cause,
209
+ })))));
210
+ return {
211
+ clientCert: {
212
+ certificate: yield* readPem(certPath),
213
+ key: yield* readPem(keyPath),
214
+ },
215
+ };
216
+ }
217
+ return yield* new KubeConfigError({
218
+ message: "Kubeconfig user has no supported auth stanza (token, tokenFile, " +
219
+ "client certificate, or exec credential plugin)",
220
+ });
221
+ });
222
+ //# sourceMappingURL=kubeconfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kubeconfig.js","sourceRoot":"","sources":["../../src/internal/kubeconfig.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,YAAY,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,mBAAmB,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,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,CAAC,QAAQ,CAAC;gBACrC,GAAG,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;aAC7B;SAC0B,CAAC;IAChC,CAAC;IAED,OAAO,KAAK,CAAC,CAAC,IAAI,eAAe,CAAC;QAChC,OAAO,EACL,kEAAkE;YAClE,gDAAgD;KACnD,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Image publishing for connections that declare a
3
+ * {@link Connection.registry}: `main` programs and `context` Dockerfiles are
4
+ * built on the deploying machine and pushed to `<server>/<name>:<hash>`,
5
+ * where the cluster's nodes pull them. Used when the cluster's platform
6
+ * adapter has no managed registry of its own (EKS pushes to ECR instead).
7
+ */
8
+ import * as Effect from "effect/Effect";
9
+ import type { WorkloadImageSource } from "../ClusterAdapter.ts";
10
+ import type { ContainerRegistry } from "../Connection.ts";
11
+ export declare const makeConnectionRegistry: Effect.Effect<{
12
+ resolve: (options: {
13
+ id: string;
14
+ registry: ContainerRegistry;
15
+ source: WorkloadImageSource;
16
+ platform: string;
17
+ port?: number | undefined;
18
+ isExternal?: boolean | undefined;
19
+ bootstrap: (importPath: string) => string;
20
+ state: Record<string, unknown> | undefined;
21
+ session: {
22
+ note: (message: string) => Effect.Effect<void>;
23
+ };
24
+ }) => Effect.Effect<{
25
+ imageUri: string;
26
+ codeHash: string;
27
+ state: {
28
+ kind: "registry";
29
+ server: string;
30
+ repository: string;
31
+ };
32
+ }, any, import("effect/FileSystem").FileSystem | import("effect/Path").Path | import("alchemy/ResourceContext").ResourceContext | import("alchemy/Stack").Stack | import("alchemy/Stage").Stage>;
33
+ hash: (options: {
34
+ source: WorkloadImageSource;
35
+ platform: string;
36
+ port?: number | undefined;
37
+ isExternal?: boolean | undefined;
38
+ bootstrap: (importPath: string) => string;
39
+ }) => Effect.Effect<string | undefined, import("alchemy/Bundle/Bundle").BundleError | import("effect/PlatformError").PlatformError, import("effect/FileSystem").FileSystem | import("effect/Path").Path>;
40
+ }, never, import("alchemy/AlchemyContext").AlchemyContext | import("@alchemy.run/docker/Docker").Docker | import("effect/Path").Path>;
41
+ /** The publisher returned by {@link makeConnectionRegistry}. */
42
+ export interface ConnectionRegistry extends Effect.Success<typeof makeConnectionRegistry> {
43
+ }
44
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/internal/registry.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAiB,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAe1D,eAAO,MAAM,sBAAsB;;YAI3B,MAAM;kBACA,iBAAiB;gBACnB,mBAAmB;kBACjB,MAAM;eACT,MAAM,GAAG,SAAS;qBACZ,OAAO,GAAG,SAAS;mBACrB,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM;eAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;iBACjC;YAAE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;SAAE;;;;;kBAuCjD,UAAU;;;;;oBAOC;QACrB,MAAM,EAAE,mBAAmB,CAAC;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC1B,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QACjC,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;KAC3C;qIAUD,CAAC;AAEH,gEAAgE;AAChE,MAAM,WAAW,kBAAmB,SAAQ,MAAM,CAAC,OAAO,CAAC,OAAO,sBAAsB,CAAC;CAAG"}