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

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 (57) hide show
  1. package/lib/BuiltinAdapters.d.ts.map +1 -1
  2. package/lib/BuiltinAdapters.js.map +1 -1
  3. package/lib/Client.d.ts +7 -7
  4. package/lib/Client.d.ts.map +1 -1
  5. package/lib/Client.js.map +1 -1
  6. package/lib/ClusterAdapter.d.ts +3 -2
  7. package/lib/ClusterAdapter.d.ts.map +1 -1
  8. package/lib/ClusterAdapter.js.map +1 -1
  9. package/lib/Connection.d.ts.map +1 -1
  10. package/lib/Connection.js.map +1 -1
  11. package/lib/Deployment.d.ts +55 -2
  12. package/lib/Deployment.d.ts.map +1 -1
  13. package/lib/Deployment.js +45 -0
  14. package/lib/Deployment.js.map +1 -1
  15. package/lib/HelmChart.d.ts.map +1 -1
  16. package/lib/HelmChart.js.map +1 -1
  17. package/lib/Job.d.ts +42 -2
  18. package/lib/Job.d.ts.map +1 -1
  19. package/lib/Job.js +33 -0
  20. package/lib/Job.js.map +1 -1
  21. package/lib/LocalCluster.d.ts +22 -1
  22. package/lib/LocalCluster.d.ts.map +1 -1
  23. package/lib/LocalCluster.js +22 -0
  24. package/lib/LocalCluster.js.map +1 -1
  25. package/lib/Manifest.d.ts +33 -1
  26. package/lib/Manifest.d.ts.map +1 -1
  27. package/lib/Manifest.js +26 -0
  28. package/lib/Manifest.js.map +1 -1
  29. package/lib/Objects.d.ts.map +1 -1
  30. package/lib/Objects.js.map +1 -1
  31. package/lib/Providers.d.ts.map +1 -1
  32. package/lib/Providers.js.map +1 -1
  33. package/lib/index.d.ts.map +1 -1
  34. package/lib/index.js.map +1 -1
  35. package/lib/internal/declared.d.ts.map +1 -1
  36. package/lib/internal/declared.js.map +1 -1
  37. package/lib/internal/helm.d.ts.map +1 -1
  38. package/lib/internal/helm.js.map +1 -1
  39. package/lib/internal/kind.d.ts.map +1 -1
  40. package/lib/internal/kind.js.map +1 -1
  41. package/lib/internal/kubeconfig.d.ts.map +1 -1
  42. package/lib/internal/kubeconfig.js +16 -7
  43. package/lib/internal/kubeconfig.js.map +1 -1
  44. package/lib/internal/registry.d.ts +1 -1
  45. package/lib/internal/registry.d.ts.map +1 -1
  46. package/lib/internal/registry.js.map +1 -1
  47. package/lib/internal/workload.d.ts.map +1 -1
  48. package/lib/internal/workload.js +4 -0
  49. package/lib/internal/workload.js.map +1 -1
  50. package/package.json +9 -9
  51. package/src/ClusterAdapter.ts +3 -2
  52. package/src/Deployment.ts +56 -2
  53. package/src/Job.ts +44 -2
  54. package/src/LocalCluster.ts +35 -1
  55. package/src/Manifest.ts +48 -2
  56. package/src/internal/kubeconfig.ts +16 -7
  57. package/src/internal/workload.ts +4 -0
@@ -6,10 +6,13 @@
6
6
  * path: AKS/GKE/EKS CLI-managed contexts work through their exec plugins
7
7
  * (`kubelogin`, `gke-gcloud-auth-plugin`, `aws eks get-token`).
8
8
  */
9
+ import * as Clock from "effect/Clock";
9
10
  import * as Config from "effect/Config";
10
11
  import * as Data from "effect/Data";
12
+ import * as DateTime from "effect/DateTime";
11
13
  import * as Effect from "effect/Effect";
12
14
  import * as FileSystem from "effect/FileSystem";
15
+ import * as Option from "effect/Option";
13
16
  import * as Path from "effect/Path";
14
17
  import * as ChildProcess from "effect/process/ChildProcess";
15
18
  import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
@@ -76,6 +79,8 @@ const decodeBase64 = (value: string) => Buffer.from(value, "base64").toString("u
76
79
 
77
80
  const expandHome = Effect.fn(function* (input: string) {
78
81
  if (!input.startsWith("~")) return input;
82
+ // `~` is the user's real home directory, not a configured value.
83
+ // oxlint-disable-next-line effecttsgo/process-env-in-effect -- home expansion reads the real process env
79
84
  const home = yield* Effect.sync(() => process.env.HOME ?? process.env.USERPROFILE);
80
85
  if (!home) {
81
86
  return yield* new KubeConfigError({
@@ -199,7 +204,7 @@ export const runExecCredential = Effect.fn(function* (options: {
199
204
  }) {
200
205
  const cacheKey = JSON.stringify([options.command, options.args ?? [], options.env ?? {}]);
201
206
  const cached = execCache.get(cacheKey);
202
- const now = yield* Effect.sync(() => Date.now());
207
+ const now = yield* Clock.currentTimeMillis;
203
208
  if (cached && cached.expiresAt > now) {
204
209
  return cached.credentials;
205
210
  }
@@ -270,12 +275,16 @@ export const runExecCredential = Effect.fn(function* (options: {
270
275
  : undefined,
271
276
  };
272
277
 
273
- const expiresAt = status.expirationTimestamp
274
- ? // Re-mint 30s before the declared expiry.
275
- new Date(status.expirationTimestamp).getTime() - 30_000
276
- : // No declared expiry: cache briefly so bursts of requests share one
277
- // plugin invocation without holding a stale credential for long.
278
- now + 60_000;
278
+ const declaredExpiry = status.expirationTimestamp
279
+ ? DateTime.make(status.expirationTimestamp)
280
+ : Option.none();
281
+ const expiresAt = Option.match(declaredExpiry, {
282
+ // Re-mint 30s before the declared expiry.
283
+ onSome: (expiry) => DateTime.toEpochMillis(expiry) - 30_000,
284
+ // No (valid) declared expiry: cache briefly so bursts of requests share
285
+ // one plugin invocation without holding a stale credential for long.
286
+ onNone: () => now + 60_000,
287
+ });
279
288
  execCache.set(cacheKey, { credentials, expiresAt });
280
289
 
281
290
  return credentials;
@@ -344,6 +344,7 @@ import * as Context from "effect/Context";
344
344
  import * as Config from "effect/Config";
345
345
  import * as ConfigProvider from "effect/ConfigProvider";
346
346
  import * as Effect from "effect/Effect";
347
+ import * as SecureRandom from "effect/crypto/SecureRandom";
347
348
  import * as FetchHttpClient from "effect/http/FetchHttpClient";
348
349
  import * as Layer from "effect/Layer";
349
350
  import * as Logger from "effect/Logger";
@@ -361,6 +362,7 @@ const layer = makeEntrypointLayer(tag, entrypoint);
361
362
  const platform = Layer.mergeAll(
362
363
  BunServices.layer,
363
364
  FetchHttpClient.layer,
365
+ SecureRandom.layerWebCrypto,
364
366
  Logger.layer([Logger.consolePretty()]),
365
367
  );
366
368
 
@@ -434,6 +436,7 @@ import * as Context from "effect/Context";
434
436
  import * as Config from "effect/Config";
435
437
  import * as ConfigProvider from "effect/ConfigProvider";
436
438
  import * as Effect from "effect/Effect";
439
+ import * as SecureRandom from "effect/crypto/SecureRandom";
437
440
  import * as FetchHttpClient from "effect/http/FetchHttpClient";
438
441
  import * as Layer from "effect/Layer";
439
442
  import * as Logger from "effect/Logger";
@@ -447,6 +450,7 @@ const layer = makeEntrypointLayer(tag, entrypoint);
447
450
  const platform = Layer.mergeAll(
448
451
  BunServices.layer,
449
452
  FetchHttpClient.layer,
453
+ SecureRandom.layerWebCrypto,
450
454
  Logger.layer([Logger.consolePretty()]),
451
455
  );
452
456