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

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 +43 -0
  4. package/lib/BuiltinAdapters.d.ts.map +1 -0
  5. package/lib/BuiltinAdapters.js +129 -0
  6. package/lib/BuiltinAdapters.js.map +1 -0
  7. package/lib/Client.d.ts +97 -0
  8. package/lib/Client.d.ts.map +1 -0
  9. package/lib/Client.js +312 -0
  10. package/lib/Client.js.map +1 -0
  11. package/lib/ClusterAdapter.d.ts +324 -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 +401 -0
  20. package/lib/Deployment.d.ts.map +1 -0
  21. package/lib/Deployment.js +550 -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 +333 -0
  28. package/lib/Job.d.ts.map +1 -0
  29. package/lib/Job.js +443 -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 +157 -0
  36. package/lib/Manifest.d.ts.map +1 -0
  37. package/lib/Manifest.js +205 -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 +202 -0
  77. package/src/Client.ts +496 -0
  78. package/src/ClusterAdapter.ts +373 -0
  79. package/src/Connection.ts +234 -0
  80. package/src/Deployment.ts +872 -0
  81. package/src/HelmChart.ts +388 -0
  82. package/src/Job.ts +709 -0
  83. package/src/LocalCluster.ts +631 -0
  84. package/src/Manifest.ts +301 -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 +504 -0
@@ -0,0 +1,72 @@
1
+ import { makeContainerImageSource, } from "@alchemy.run/docker/ImageSource";
2
+ import { createPhysicalName } from "alchemy/PhysicalName";
3
+ /**
4
+ * Image publishing for connections that declare a
5
+ * {@link Connection.registry}: `main` programs and `context` Dockerfiles are
6
+ * built on the deploying machine and pushed to `<server>/<name>:<hash>`,
7
+ * where the cluster's nodes pull them. Used when the cluster's platform
8
+ * adapter has no managed registry of its own (EKS pushes to ECR instead).
9
+ */
10
+ import * as Effect from "effect/Effect";
11
+ /** Docker credentials for a registry, or `undefined` to use `docker login`. */
12
+ const credentialsOf = (registry) => registry.username !== undefined && registry.password !== undefined
13
+ ? {
14
+ // Docker keys credentials by host; `server` may carry a namespace.
15
+ server: registry.server.split("/")[0],
16
+ username: registry.username,
17
+ password: registry.password,
18
+ }
19
+ : undefined;
20
+ const trimServer = (server) => server.replace(/\/+$/, "");
21
+ export const makeConnectionRegistry = Effect.gen(function* () {
22
+ const images = yield* makeContainerImageSource;
23
+ const resolve = Effect.fn(function* (options) {
24
+ const server = trimServer(options.registry.server);
25
+ // Keep the repository stable across updates; a changed `server` starts
26
+ // a new one.
27
+ const repository = options.state?.kind === "registry" &&
28
+ options.state.server === server &&
29
+ typeof options.state.repository === "string"
30
+ ? options.state.repository
31
+ : `${server}/${yield* createPhysicalName({
32
+ id: options.id,
33
+ maxLength: 96,
34
+ lowercase: true,
35
+ })}`;
36
+ const target = {
37
+ repositoryUri: Effect.succeed(repository),
38
+ // Generic registries have no cheap existence probe; resolve only runs
39
+ // when the workload changes, and the local build cache makes a
40
+ // rebuild of unchanged content fast.
41
+ hasTag: () => Effect.succeed(false),
42
+ credentials: Effect.succeed(credentialsOf(options.registry)),
43
+ };
44
+ const resolved = yield* images.resolve({
45
+ id: options.id,
46
+ source: options.source,
47
+ platform: options.platform,
48
+ port: options.port,
49
+ isExternal: options.isExternal,
50
+ bootstrap: options.bootstrap,
51
+ session: options.session,
52
+ }, target);
53
+ return {
54
+ imageUri: resolved.imageUri,
55
+ codeHash: resolved.codeHash,
56
+ state: {
57
+ kind: "registry",
58
+ server,
59
+ repository,
60
+ },
61
+ };
62
+ });
63
+ const hash = (options) => images.hash({
64
+ source: options.source,
65
+ platform: options.platform,
66
+ port: options.port,
67
+ isExternal: options.isExternal,
68
+ bootstrap: options.bootstrap,
69
+ });
70
+ return { resolve, hash };
71
+ });
72
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/internal/registry.ts"],"names":[],"mappings":"AACA,OAAO,EACL,wBAAwB,GAEzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,+EAA+E;AAC/E,MAAM,aAAa,GAAG,CAAC,QAA2B,EAAmC,EAAE,CACrF,QAAQ,CAAC,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,QAAQ,KAAK,SAAS;IAChE,CAAC,CAAC;QACE,mEAAmE;QACnE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE;QACtC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;KAC5B;IACH,CAAC,CAAC,SAAS,CAAC;AAEhB,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAElE,MAAM,CAAC,MAAM,sBAAsB,GAAG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,OAAO,CAAC,SAAS;YAC5B,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,EACD,MAAM,CACP,CAAC;QACF,OAAO;YACL,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,KAAK,EAAE;gBACL,IAAI,EAAE,UAAmB;gBACzB,MAAM;gBACN,UAAU;aACa;SAC1B,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,CAAC,OAMb,EAAE,EAAE,CACH,MAAM,CAAC,IAAI,CAAC;QACV,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAC;IAEL,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC,CAAC,CAAC"}
@@ -0,0 +1,127 @@
1
+ import type { ResourceBinding } from "alchemy/Resource";
2
+ /**
3
+ * Internal helpers shared by the Kubernetes workload platforms
4
+ * (`Kubernetes.Deployment`, `Kubernetes.Job`): image-source dispatch
5
+ * through the cluster adapter, binding-env collection, connection
6
+ * identity, and the platform-neutral generated container entries.
7
+ */
8
+ import * as Effect from "effect/Effect";
9
+ import * as FileSystem from "effect/FileSystem";
10
+ import * as Path from "effect/Path";
11
+ import * as Redacted from "effect/Redacted";
12
+ import type { ClusterAdapterService, IdentityState, WorkloadBindingContract, WorkloadImageSource } from "../ClusterAdapter.ts";
13
+ import type { ClusterLike, Connection } from "../Connection.ts";
14
+ import type { ConnectionRegistry } from "./registry.ts";
15
+ /**
16
+ * Structural deep merge: objects merge recursively; arrays and primitives
17
+ * from `override` replace the base value wholesale. Powers escape hatches
18
+ * like `Kubernetes.Deployment.podTemplate`.
19
+ */
20
+ export declare const deepMerge: <T>(base: T, override: unknown) => T;
21
+ /**
22
+ * The image build platform of a workload: its own `architecture`, else the
23
+ * connection's node architecture, else `linux/amd64`.
24
+ */
25
+ export declare const imagePlatformOf: (architecture: "amd64" | "arm64" | undefined, connection?: Connection) => string;
26
+ /**
27
+ * Best-effort {@link Connection} of a `cluster` prop value — `undefined`
28
+ * instead of throwing, for plan-time diffs where the referenced resource
29
+ * may resolve to stables-only (or `{}`).
30
+ */
31
+ export declare const tryConnectionOf: (cluster: ClusterLike | undefined) => Connection | undefined;
32
+ /**
33
+ * A stable identity string for a connection's *target cluster* — the auth
34
+ * descriptor (which names the cluster for managed clouds and the
35
+ * kubeconfig context otherwise). Changing it means the workload moves
36
+ * clusters, which is a replacement. Deliberately excludes `endpoint` /
37
+ * CA: managed clusters can rotate those in place.
38
+ */
39
+ export declare const connectionIdentity: (connection: Connection | undefined) => string | undefined;
40
+ /**
41
+ * The persisted connection of a workload's attributes, tolerating legacy
42
+ * pre-rename rows (`AWS.EKS.*` attributes carried a flat `clusterName`
43
+ * instead of a `connection`) by synthesizing an `aws-eks` connection —
44
+ * the only platform those legacy types could target.
45
+ */
46
+ export declare const connectionOfOutput: (output: Record<string, unknown>) => Connection | undefined;
47
+ /**
48
+ * Collect environment variables from a host's active bindings and report
49
+ * which cloud-grant channels (any binding-data key besides `env`, e.g.
50
+ * AWS `policyStatements`) are in play — the caller fails when grants
51
+ * exist but the cluster has no identity adapter to materialize them.
52
+ */
53
+ export declare const collectBindingEnv: (bindings: ResourceBinding<WorkloadBindingContract>[]) => {
54
+ env: Record<string, any>;
55
+ grantKeys: string[];
56
+ };
57
+ /**
58
+ * Kubernetes env values are strings. A {@link Redacted} string stays wrapped
59
+ * so the request serializer unwraps it. Any other value that holds a secret
60
+ * is JSON, still wrapped, so a failed apply can scrub the inner strings.
61
+ */
62
+ export declare const containerEnvValue: (value: unknown) => string | Redacted.Redacted<string>;
63
+ export type ImageSourceKind = "main" | "context" | "image";
64
+ /** Which image source a props bag declares (`main` always wins). */
65
+ export declare const imageSourceKind: (source: WorkloadImageSource) => ImageSourceKind | undefined;
66
+ /**
67
+ * Content hash for image sources whose identity is computable without a
68
+ * bundler: `image` (the ref + platform) and `context` (the build-context
69
+ * directory + Dockerfile content + platform). `main` returns `undefined`
70
+ * — its hash comes from the bundle output inside the registry adapter.
71
+ */
72
+ export declare const computeStaticWorkloadImageHash: (source: WorkloadImageSource, platform: string) => Effect.Effect<string | undefined, import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path>;
73
+ export interface ResolveWorkloadImageOptions {
74
+ adapter: ClusterAdapterService;
75
+ /** The target connection — its `registry`, if any, receives builds. */
76
+ connection: Connection;
77
+ /** Publisher for connection-level registries. */
78
+ connectionRegistry: ConnectionRegistry;
79
+ id: string;
80
+ source: WorkloadImageSource;
81
+ platform: string;
82
+ port?: number | undefined;
83
+ isExternal?: boolean | undefined;
84
+ bootstrap: (importPath: string) => string;
85
+ tags: Record<string, string>;
86
+ /** Persisted registry state hints (legacy-shape tolerant). */
87
+ state: Record<string, unknown> | undefined;
88
+ session: {
89
+ note: (message: string) => Effect.Effect<void>;
90
+ };
91
+ }
92
+ /**
93
+ * Resolve the container image for a workload: through the cluster
94
+ * adapter's managed registry when it has one (build/mirror + push). Other
95
+ * clusters run a pre-built `image` reference verbatim and build `main` /
96
+ * `context` sources into the connection's `registry`, which those sources
97
+ * require.
98
+ */
99
+ export declare const resolveWorkloadImage: (options: ResolveWorkloadImageOptions) => Effect.Effect<import("../ClusterAdapter.ts").ImageRegistryResult, any, FileSystem.FileSystem | Path.Path | import("../ClusterAdapter.ts").AdapterLifecycleServices>;
100
+ /** Plan-time content hash for `diff` — adapter-aware. */
101
+ export declare const workloadImageHash: (options: {
102
+ adapter: ClusterAdapterService;
103
+ connection: Connection;
104
+ connectionRegistry: ConnectionRegistry;
105
+ source: WorkloadImageSource;
106
+ platform: string;
107
+ port?: number | undefined;
108
+ isExternal?: boolean | undefined;
109
+ bootstrap: (importPath: string) => string;
110
+ }) => Effect.Effect<string | undefined, any, FileSystem.FileSystem | Path.Path | import("../ClusterAdapter.ts").AdapterLifecycleServices>;
111
+ /** The identity-adapter state persisted on workload attributes. */
112
+ export type PersistedIdentityState = IdentityState | undefined;
113
+ /**
114
+ * Platform-neutral generated container entry for an Effect-native server
115
+ * workload: resolves the program's registered runners and serves the
116
+ * returned `{ fetch }` handler on `PORT`. Cloud adapters override this
117
+ * through {@link ClusterAdapterService.bootstrap} to wire their runtime
118
+ * credential chains (e.g. EKS Pod Identity).
119
+ */
120
+ export declare const makeServerBootstrap: (handler: string) => (importPath: string) => string;
121
+ /**
122
+ * Platform-neutral generated container entry for an Effect-native one-shot
123
+ * Job: resolves the program's `run` effect, executes it to completion, and
124
+ * exits.
125
+ */
126
+ export declare const makeJobBootstrap: (handler: string) => (importPath: string) => string;
127
+ //# sourceMappingURL=workload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workload.d.ts","sourceRoot":"","sources":["../../src/internal/workload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKxD;;;;;GAKG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EACV,qBAAqB,EACrB,aAAa,EACb,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAkB,MAAM,kBAAkB,CAAC;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,QAAQ,CAAC,YAAY,OAAO,KAAG,CAoBzD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,i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G,SAAS,CAAC;IACjC,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC3C,OAAO,EAAE;QAAE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC;CAC7D;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,+MA+C/B,CAAC;AAEH,yDAAyD;AACzD,eAAO,MAAM,iBAAiB;aACnB,qBAAqB;gBAClB,UAAU;wBACF,kBAAkB;YAC9B,mBAAmB;cACjB,MAAM;WACT,MAAM,GAAG,SAAS;iBACZ,OAAO,GAAG,SAAS;eACrB,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM;yIAqBzC,CAAC;AAEH,mEAAmE;AAEnE,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG,SAAS,CAAC;AAE/D;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,YACpB,MAAM,kBACH,MAAM,KAAG,MAkFvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,YACjB,MAAM,kBACH,MAAM,KAAG,MA8EvB,CAAC"}
@@ -0,0 +1,411 @@
1
+ import { isInlineDockerfile } from "@alchemy.run/docker/Dockerfile";
2
+ import { hashDirectory } from "alchemy/Command/Memo";
3
+ import { Self } from "alchemy/Self";
4
+ import { unwrapRedacted } from "alchemy/Util/data";
5
+ import { collectRedactedSecrets } from "alchemy/Util/Redaction";
6
+ import { sha256Object } from "alchemy/Util/sha256";
7
+ /**
8
+ * Internal helpers shared by the Kubernetes workload platforms
9
+ * (`Kubernetes.Deployment`, `Kubernetes.Job`): image-source dispatch
10
+ * through the cluster adapter, binding-env collection, connection
11
+ * identity, and the platform-neutral generated container entries.
12
+ */
13
+ import * as Effect from "effect/Effect";
14
+ import * as FileSystem from "effect/FileSystem";
15
+ import * as Path from "effect/Path";
16
+ import * as Redacted from "effect/Redacted";
17
+ /**
18
+ * Structural deep merge: objects merge recursively; arrays and primitives
19
+ * from `override` replace the base value wholesale. Powers escape hatches
20
+ * like `Kubernetes.Deployment.podTemplate`.
21
+ */
22
+ export const deepMerge = (base, override) => {
23
+ if (override === undefined)
24
+ return base;
25
+ if (base === null ||
26
+ override === null ||
27
+ typeof base !== "object" ||
28
+ typeof override !== "object" ||
29
+ Array.isArray(base) ||
30
+ Array.isArray(override)) {
31
+ return override;
32
+ }
33
+ const out = { ...base };
34
+ for (const [key, value] of Object.entries(override)) {
35
+ out[key] =
36
+ key in base
37
+ ? deepMerge(base[key], value)
38
+ : value;
39
+ }
40
+ return out;
41
+ };
42
+ /**
43
+ * The image build platform of a workload: its own `architecture`, else the
44
+ * connection's node architecture, else `linux/amd64`.
45
+ */
46
+ export const imagePlatformOf = (architecture, connection) => (architecture ?? connection?.architecture) === "arm64" ? "linux/arm64" : "linux/amd64";
47
+ /**
48
+ * Best-effort {@link Connection} of a `cluster` prop value — `undefined`
49
+ * instead of throwing, for plan-time diffs where the referenced resource
50
+ * may resolve to stables-only (or `{}`).
51
+ */
52
+ export const tryConnectionOf = (cluster) => {
53
+ if (cluster === undefined)
54
+ return undefined;
55
+ if ("auth" in cluster && cluster.auth !== undefined)
56
+ return cluster;
57
+ if ("connection" in cluster && cluster.connection !== undefined) {
58
+ return cluster.connection;
59
+ }
60
+ return undefined;
61
+ };
62
+ const sortKeysDeep = (value) => {
63
+ if (Array.isArray(value))
64
+ return value.map(sortKeysDeep);
65
+ if (value === null || typeof value !== "object")
66
+ return value;
67
+ return Object.fromEntries(Object.entries(value)
68
+ .filter(([, entry]) => entry !== undefined)
69
+ .sort(([a], [b]) => a.localeCompare(b))
70
+ .map(([key, entry]) => [key, sortKeysDeep(entry)]));
71
+ };
72
+ /**
73
+ * A stable identity string for a connection's *target cluster* — the auth
74
+ * descriptor (which names the cluster for managed clouds and the
75
+ * kubeconfig context otherwise). Changing it means the workload moves
76
+ * clusters, which is a replacement. Deliberately excludes `endpoint` /
77
+ * CA: managed clusters can rotate those in place.
78
+ */
79
+ export const connectionIdentity = (connection) => connection === undefined ? undefined : JSON.stringify(sortKeysDeep(connection.auth));
80
+ /**
81
+ * The persisted connection of a workload's attributes, tolerating legacy
82
+ * pre-rename rows (`AWS.EKS.*` attributes carried a flat `clusterName`
83
+ * instead of a `connection`) by synthesizing an `aws-eks` connection —
84
+ * the only platform those legacy types could target.
85
+ */
86
+ export const connectionOfOutput = (output) => {
87
+ const connection = output.connection;
88
+ if (connection?.auth !== undefined)
89
+ return connection;
90
+ if (typeof output.clusterName === "string") {
91
+ return {
92
+ auth: { kind: "aws-eks", clusterName: output.clusterName },
93
+ };
94
+ }
95
+ return undefined;
96
+ };
97
+ /**
98
+ * Collect environment variables from a host's active bindings and report
99
+ * which cloud-grant channels (any binding-data key besides `env`, e.g.
100
+ * AWS `policyStatements`) are in play — the caller fails when grants
101
+ * exist but the cluster has no identity adapter to materialize them.
102
+ */
103
+ export const collectBindingEnv = (bindings) => {
104
+ const activeBindings = bindings.filter((binding) => binding.action !== "delete");
105
+ const env = activeBindings
106
+ .map((binding) => binding?.data?.env)
107
+ .reduce((acc, value) => ({ ...acc, ...value }), {});
108
+ const grantKeys = [
109
+ ...new Set(activeBindings.flatMap((binding) => Object.keys(binding?.data ?? {}).filter((key) => key !== "env" && binding.data[key] !== undefined))),
110
+ ];
111
+ return { env, grantKeys };
112
+ };
113
+ /**
114
+ * Kubernetes env values are strings. A {@link Redacted} string stays wrapped
115
+ * so the request serializer unwraps it. Any other value that holds a secret
116
+ * is JSON, still wrapped, so a failed apply can scrub the inner strings.
117
+ */
118
+ export const containerEnvValue = (value) => {
119
+ if (typeof value === "string")
120
+ return value;
121
+ if (Redacted.isRedacted(value)) {
122
+ const inner = Redacted.value(value);
123
+ if (typeof inner === "string")
124
+ return Redacted.make(inner);
125
+ }
126
+ const json = JSON.stringify(unwrapRedacted(value));
127
+ return collectRedactedSecrets(value).length > 0 ? Redacted.make(json) : json;
128
+ };
129
+ /** Which image source a props bag declares (`main` always wins). */
130
+ export const imageSourceKind = (source) => source.main !== undefined
131
+ ? "main"
132
+ : source.image !== undefined
133
+ ? "image"
134
+ : source.context !== undefined || source.dockerfile !== undefined
135
+ ? "context"
136
+ : undefined;
137
+ /**
138
+ * Content hash for image sources whose identity is computable without a
139
+ * bundler: `image` (the ref + platform) and `context` (the build-context
140
+ * directory + Dockerfile content + platform). `main` returns `undefined`
141
+ * — its hash comes from the bundle output inside the registry adapter.
142
+ */
143
+ export const computeStaticWorkloadImageHash = Effect.fn(function* (source, platform) {
144
+ const kind = imageSourceKind(source);
145
+ if (kind === "image") {
146
+ return (yield* sha256Object({ image: source.image, platform })).slice(0, 16);
147
+ }
148
+ if (kind === "context") {
149
+ if (source.dockerfile !== undefined && isInlineDockerfile(source.dockerfile)) {
150
+ if (typeof source.dockerfile.content !== "string")
151
+ return undefined;
152
+ return (yield* sha256Object({ dockerfile: source.dockerfile.content, platform })).slice(0, 16);
153
+ }
154
+ const fs = yield* FileSystem.FileSystem;
155
+ const path = yield* Path.Path;
156
+ const context = path.resolve(source.context ?? ".");
157
+ const dockerfile = typeof source.dockerfile === "string"
158
+ ? path.resolve(source.dockerfile)
159
+ : path.join(context, "Dockerfile");
160
+ if (!(yield* fs.exists(context)) || !(yield* fs.exists(dockerfile))) {
161
+ return undefined;
162
+ }
163
+ const contextHash = yield* hashDirectory({ cwd: context });
164
+ const dockerfileContent = yield* fs.readFileString(dockerfile);
165
+ return (yield* sha256Object({ contextHash, dockerfile: dockerfileContent, platform })).slice(0, 16);
166
+ }
167
+ return undefined;
168
+ });
169
+ /**
170
+ * Resolve the container image for a workload: through the cluster
171
+ * adapter's managed registry when it has one (build/mirror + push). Other
172
+ * clusters run a pre-built `image` reference verbatim and build `main` /
173
+ * `context` sources into the connection's `registry`, which those sources
174
+ * require.
175
+ */
176
+ export const resolveWorkloadImage = Effect.fn(function* (options) {
177
+ const { adapter, source } = options;
178
+ if (adapter.registry !== undefined) {
179
+ return yield* adapter.registry.resolve({
180
+ id: options.id,
181
+ source,
182
+ platform: options.platform,
183
+ port: options.port,
184
+ isExternal: options.isExternal,
185
+ bootstrap: options.bootstrap,
186
+ tags: options.tags,
187
+ state: options.state,
188
+ session: options.session,
189
+ });
190
+ }
191
+ const kind = imageSourceKind(source);
192
+ if (kind === "image") {
193
+ const codeHash = (yield* computeStaticWorkloadImageHash(source, options.platform));
194
+ return { imageUri: source.image, codeHash, state: undefined };
195
+ }
196
+ const registry = options.connection.registry;
197
+ if (registry !== undefined) {
198
+ return yield* options.connectionRegistry.resolve({
199
+ id: options.id,
200
+ registry,
201
+ source,
202
+ platform: options.platform,
203
+ port: options.port,
204
+ isExternal: options.isExternal,
205
+ bootstrap: options.bootstrap,
206
+ state: options.state,
207
+ session: options.session,
208
+ });
209
+ }
210
+ return yield* Effect.die(new Error(`'${options.id}': 'main' and 'context' image sources are built and ` +
211
+ "pushed to a container registry, and this cluster connection has " +
212
+ "none. Add a `registry` to the connection (e.g. " +
213
+ '`Kubernetes.KubeConfig({ context, registry: { server: "ghcr.io/acme" } })`), ' +
214
+ "use `Kubernetes.LocalCluster`, which includes one, or run a " +
215
+ "pre-built `image` reference the cluster can pull."));
216
+ });
217
+ /** Plan-time content hash for `diff` — adapter-aware. */
218
+ export const workloadImageHash = Effect.fn(function* (options) {
219
+ if (options.adapter.registry !== undefined) {
220
+ return yield* options.adapter.registry.hash({
221
+ source: options.source,
222
+ platform: options.platform,
223
+ port: options.port,
224
+ isExternal: options.isExternal,
225
+ bootstrap: options.bootstrap,
226
+ });
227
+ }
228
+ if (options.connection.registry !== undefined && imageSourceKind(options.source) === "main") {
229
+ return yield* options.connectionRegistry.hash({
230
+ source: options.source,
231
+ platform: options.platform,
232
+ port: options.port,
233
+ isExternal: options.isExternal,
234
+ bootstrap: options.bootstrap,
235
+ });
236
+ }
237
+ return yield* computeStaticWorkloadImageHash(options.source, options.platform);
238
+ });
239
+ /**
240
+ * Platform-neutral generated container entry for an Effect-native server
241
+ * workload: resolves the program's registered runners and serves the
242
+ * returned `{ fetch }` handler on `PORT`. Cloud adapters override this
243
+ * through {@link ClusterAdapterService.bootstrap} to wire their runtime
244
+ * credential chains (e.g. EKS Pod Identity).
245
+ */
246
+ export const makeServerBootstrap = (handler) => (importPath) => `
247
+ import { BunServices } from "@effect/platform-bun";
248
+ import { BunHttpServer } from "alchemy/Http";
249
+ import { Stack } from "alchemy/Stack";
250
+ import { Stage } from "alchemy/Stage";
251
+ import { makeEntrypointLayer, reifyBoundConfigProvider } from "alchemy/Runtime";
252
+ import { provideProcessTelemetry } from "alchemy/Telemetry";
253
+ import * as Context from "effect/Context";
254
+ import * as Config from "effect/Config";
255
+ import * as ConfigProvider from "effect/ConfigProvider";
256
+ import * as Effect from "effect/Effect";
257
+ import * as FetchHttpClient from "effect/http/FetchHttpClient";
258
+ import * as Layer from "effect/Layer";
259
+ import * as Logger from "effect/Logger";
260
+
261
+ import { ${handler} as entrypoint } from ${JSON.stringify(importPath)};
262
+
263
+ // Normalize the entrypoint export: an inline-effect class default export is
264
+ // an Effect resolving the platform instance, while the tagged form
265
+ // (X.make(props, impl)) exports a Layer providing the Self tag. Both fold
266
+ // into a Layer via makeEntrypointLayer (same pattern as the ECS/Lambda/
267
+ // Cloudflare Container bridges).
268
+ const tag = Context.Service("${Self.key}");
269
+ const layer = makeEntrypointLayer(tag, entrypoint);
270
+
271
+ const platform = Layer.mergeAll(
272
+ BunServices.layer,
273
+ FetchHttpClient.layer,
274
+ Logger.layer([Logger.consolePretty()]),
275
+ );
276
+
277
+ // Resolve the bundled program (the runners registered via host.run / serve)
278
+ // and run it with a Bun HTTP server bound to PORT, so a returned { fetch }
279
+ // handler is served and host.run loops stay alive.
280
+ const program = tag.pipe(
281
+ // Process-lifetime telemetry: built once into the root scope; exporters
282
+ // batch on their intervals and flush when the scope closes on graceful
283
+ // shutdown.
284
+ Effect.flatMap((host) =>
285
+ host.RuntimeContext.exports.pipe(
286
+ Effect.flatMap((exports) => exports.program),
287
+ provideProcessTelemetry(host.RuntimeContext),
288
+ ),
289
+ ),
290
+ Effect.provide(
291
+ layer.pipe(Layer.provideMerge(Layer.mergeAll(
292
+ Layer.effect(
293
+ Stack,
294
+ Effect.all([
295
+ Config.String("ALCHEMY_STACK_NAME"),
296
+ Config.String("ALCHEMY_STAGE")
297
+ ]).pipe(
298
+ Effect.map(([name, stage]) => ({
299
+ name,
300
+ stage,
301
+ bindings: {},
302
+ resources: {}
303
+ }))
304
+ )
305
+ ),
306
+ // Module-scope declarations shared with the Stack may read the stage.
307
+ Layer.effect(Stage, Config.String("ALCHEMY_STAGE")),
308
+ )),
309
+ Layer.provideMerge(BunHttpServer()),
310
+ Layer.provideMerge(platform),
311
+ Layer.provideMerge(
312
+ Layer.succeed(
313
+ ConfigProvider.ConfigProvider,
314
+ reifyBoundConfigProvider(ConfigProvider.fromEnv(), process.env)
315
+ )
316
+ ),
317
+ )
318
+ ),
319
+ Effect.scoped
320
+ );
321
+
322
+ console.log(\`Kubernetes Deployment bootstrap starting on port \${process.env.PORT ?? 3000}...\`);
323
+ await Effect.runPromise(program).catch((err) => {
324
+ console.error("Kubernetes Deployment bootstrap failed:", err);
325
+ process.exit(1);
326
+ });
327
+ `;
328
+ /**
329
+ * Platform-neutral generated container entry for an Effect-native one-shot
330
+ * Job: resolves the program's `run` effect, executes it to completion, and
331
+ * exits.
332
+ */
333
+ export const makeJobBootstrap = (handler) => (importPath) => `
334
+ import { BunServices } from "@effect/platform-bun";
335
+ import { Stack } from "alchemy/Stack";
336
+ import { Stage } from "alchemy/Stage";
337
+ import { makeEntrypointLayer, reifyBoundConfigProvider } from "alchemy/Runtime";
338
+ import { provideProcessTelemetry } from "alchemy/Telemetry";
339
+ import * as Context from "effect/Context";
340
+ import * as Config from "effect/Config";
341
+ import * as ConfigProvider from "effect/ConfigProvider";
342
+ import * as Effect from "effect/Effect";
343
+ import * as FetchHttpClient from "effect/http/FetchHttpClient";
344
+ import * as Layer from "effect/Layer";
345
+ import * as Logger from "effect/Logger";
346
+
347
+ import { ${handler} as entrypoint } from ${JSON.stringify(importPath)};
348
+
349
+ // Normalize the entrypoint export (see the server bootstrap).
350
+ const tag = Context.Service("${Self.key}");
351
+ const layer = makeEntrypointLayer(tag, entrypoint);
352
+
353
+ const platform = Layer.mergeAll(
354
+ BunServices.layer,
355
+ FetchHttpClient.layer,
356
+ Logger.layer([Logger.consolePretty()]),
357
+ );
358
+
359
+ // Resolve the bundled program's registered one-shot runners (the shape's
360
+ // \`run\` effect and any host.run work) and execute them to completion.
361
+ const program = tag.pipe(
362
+ // Process-lifetime telemetry: built once into the root scope; exporters
363
+ // batch on their intervals and flush when the scope closes as the
364
+ // one-shot program completes.
365
+ Effect.flatMap((host) =>
366
+ host.RuntimeContext.exports.pipe(
367
+ Effect.flatMap((exports) => exports.program),
368
+ provideProcessTelemetry(host.RuntimeContext),
369
+ ),
370
+ ),
371
+ Effect.provide(
372
+ layer.pipe(Layer.provideMerge(Layer.mergeAll(
373
+ Layer.effect(
374
+ Stack,
375
+ Effect.all([
376
+ Config.String("ALCHEMY_STACK_NAME"),
377
+ Config.String("ALCHEMY_STAGE")
378
+ ]).pipe(
379
+ Effect.map(([name, stage]) => ({
380
+ name,
381
+ stage,
382
+ bindings: {},
383
+ resources: {}
384
+ }))
385
+ )
386
+ ),
387
+ // Module-scope declarations shared with the Stack may read the stage.
388
+ Layer.effect(Stage, Config.String("ALCHEMY_STAGE")),
389
+ )),
390
+ Layer.provideMerge(platform),
391
+ Layer.provideMerge(
392
+ Layer.succeed(
393
+ ConfigProvider.ConfigProvider,
394
+ reifyBoundConfigProvider(ConfigProvider.fromEnv(), process.env)
395
+ )
396
+ ),
397
+ )
398
+ ),
399
+ Effect.scoped
400
+ );
401
+
402
+ console.log("Kubernetes Job bootstrap starting...");
403
+ await Effect.runPromise(program).catch((err) => {
404
+ console.error("Kubernetes Job bootstrap failed:", err);
405
+ process.exit(1);
406
+ });
407
+ // Run-to-completion semantics: exit 0 explicitly so lingering handles
408
+ // (sockets, timers) never keep the pod alive after the work is done.
409
+ process.exit(0);
410
+ `;
411
+ //# sourceMappingURL=workload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workload.js","sourceRoot":"","sources":["../../src/internal/workload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD;;;;;GAKG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAU5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,IAAO,EAAE,QAAiB,EAAK,EAAE;IAC5D,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACxC,IACE,IAAI,KAAK,IAAI;QACb,QAAQ,KAAK,IAAI;QACjB,OAAO,IAAI,KAAK,QAAQ;QACxB,OAAO,QAAQ,KAAK,QAAQ;QAC5B,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACnB,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EACvB,CAAC;QACD,OAAO,QAAa,CAAC;IACvB,CAAC;IACD,MAAM,GAAG,GAA4B,EAAE,GAAI,IAA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