@highstate/k8s 0.20.0 → 0.21.1

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 (81) hide show
  1. package/dist/chunk-23vn2rdc.js +11 -0
  2. package/dist/chunk-2pfx13ay.js +11 -0
  3. package/dist/chunk-46ntav0c.js +299 -0
  4. package/dist/chunk-556pc9e6.js +155 -0
  5. package/dist/chunk-7kgjgcft.js +170 -0
  6. package/dist/{chunk-ADHZK6V2.js → chunk-9hs97f1q.js} +13 -11
  7. package/dist/chunk-aame3x1b.js +11 -0
  8. package/dist/chunk-b05q6fm2.js +37 -0
  9. package/dist/chunk-bmvc9d2d.js +11 -0
  10. package/dist/chunk-de82bbp2.js +7 -0
  11. package/dist/chunk-facs31cb.js +624 -0
  12. package/dist/chunk-h1b79v66.js +1425 -0
  13. package/dist/chunk-k4w9zpn5.js +215 -0
  14. package/dist/chunk-pqc6w52f.js +352 -0
  15. package/dist/chunk-qyshvz32.js +176 -0
  16. package/dist/chunk-tpfyj6fe.js +199 -0
  17. package/dist/chunk-z6bmpnm7.js +180 -0
  18. package/dist/highstate.manifest.json +3 -3
  19. package/dist/impl/dynamic-endpoint-resolver.js +82 -81
  20. package/dist/impl/gateway-route.js +131 -168
  21. package/dist/impl/tls-certificate.js +31 -32
  22. package/dist/index.js +245 -201
  23. package/dist/units/cert-manager/index.js +19 -13
  24. package/dist/units/cluster-patch/index.js +9 -8
  25. package/dist/units/dns01-issuer/index.js +44 -41
  26. package/dist/units/existing-cluster/index.js +25 -13
  27. package/dist/units/gateway-api/index.js +15 -16
  28. package/dist/units/reduced-access-cluster/index.js +28 -32
  29. package/package.json +21 -21
  30. package/src/cron-job.ts +26 -1
  31. package/src/deployment.ts +17 -1
  32. package/src/job.ts +15 -1
  33. package/src/scripting/bundle.ts +21 -98
  34. package/src/scripting/environment.ts +2 -9
  35. package/src/shared.ts +1 -1
  36. package/src/stateful-set.ts +17 -1
  37. package/src/workload.ts +31 -14
  38. package/LICENSE +0 -21
  39. package/dist/chunk-23X5SXQG.js +0 -301
  40. package/dist/chunk-23X5SXQG.js.map +0 -1
  41. package/dist/chunk-ADHZK6V2.js.map +0 -1
  42. package/dist/chunk-BTAEFJ5N.js +0 -291
  43. package/dist/chunk-BTAEFJ5N.js.map +0 -1
  44. package/dist/chunk-HH2JJELM.js +0 -13
  45. package/dist/chunk-HH2JJELM.js.map +0 -1
  46. package/dist/chunk-IXE3OKB4.js +0 -249
  47. package/dist/chunk-IXE3OKB4.js.map +0 -1
  48. package/dist/chunk-OG2OPX7B.js +0 -333
  49. package/dist/chunk-OG2OPX7B.js.map +0 -1
  50. package/dist/chunk-P26SQ2ZB.js +0 -393
  51. package/dist/chunk-P26SQ2ZB.js.map +0 -1
  52. package/dist/chunk-PG27ZY2H.js +0 -319
  53. package/dist/chunk-PG27ZY2H.js.map +0 -1
  54. package/dist/chunk-PZYGZSN5.js +0 -54
  55. package/dist/chunk-PZYGZSN5.js.map +0 -1
  56. package/dist/chunk-S77TE7UC.js +0 -309
  57. package/dist/chunk-S77TE7UC.js.map +0 -1
  58. package/dist/chunk-SZKOAHNX.js +0 -1804
  59. package/dist/chunk-SZKOAHNX.js.map +0 -1
  60. package/dist/chunk-TOLFVF4S.js +0 -889
  61. package/dist/chunk-TOLFVF4S.js.map +0 -1
  62. package/dist/chunk-TVKT3ZYX.js +0 -423
  63. package/dist/chunk-TVKT3ZYX.js.map +0 -1
  64. package/dist/cron-job-RKB2HYTO.js +0 -7
  65. package/dist/cron-job-RKB2HYTO.js.map +0 -1
  66. package/dist/deployment-T35TUOL2.js +0 -7
  67. package/dist/deployment-T35TUOL2.js.map +0 -1
  68. package/dist/impl/dynamic-endpoint-resolver.js.map +0 -1
  69. package/dist/impl/gateway-route.js.map +0 -1
  70. package/dist/impl/tls-certificate.js.map +0 -1
  71. package/dist/index.js.map +0 -1
  72. package/dist/job-PE4AKOHB.js +0 -7
  73. package/dist/job-PE4AKOHB.js.map +0 -1
  74. package/dist/stateful-set-LUIRHQJY.js +0 -7
  75. package/dist/stateful-set-LUIRHQJY.js.map +0 -1
  76. package/dist/units/cert-manager/index.js.map +0 -1
  77. package/dist/units/cluster-patch/index.js.map +0 -1
  78. package/dist/units/dns01-issuer/index.js.map +0 -1
  79. package/dist/units/existing-cluster/index.js.map +0 -1
  80. package/dist/units/gateway-api/index.js.map +0 -1
  81. package/dist/units/reduced-access-cluster/index.js.map +0 -1
@@ -1,10 +1,18 @@
1
- import { dns01SolverMediator } from '../../chunk-HH2JJELM.js';
2
- import { getProviderAsync, Namespace, Secret } from '../../chunk-TOLFVF4S.js';
3
- import '../../chunk-PZYGZSN5.js';
4
- import { cert_manager } from '@highstate/cert-manager';
5
- import { k8s, common } from '@highstate/library';
6
- import { forUnit, makeEntityOutput } from '@highstate/pulumi';
1
+ // @bun
2
+ import {
3
+ dns01SolverMediator
4
+ } from "../../chunk-de82bbp2.js";
5
+ import {
6
+ Namespace,
7
+ Secret,
8
+ getProviderAsync
9
+ } from "../../chunk-facs31cb.js";
10
+ import"../../chunk-b05q6fm2.js";
7
11
 
12
+ // src/units/dns01-issuer/index.ts
13
+ import { cert_manager } from "@highstate/cert-manager";
14
+ import { common, k8s } from "@highstate/library";
15
+ import { forUnit, makeEntityOutput } from "@highstate/pulumi";
8
16
  var { name, args, secrets, inputs, outputs } = forUnit(k8s.dns01TlsIssuer);
9
17
  var provider = await getProviderAsync(inputs.k8sCluster);
10
18
  var certManagerNs = Namespace.get("cert-manager", {
@@ -34,38 +42,34 @@ var getAcmeServer = () => {
34
42
  return args.acmeServer.url;
35
43
  }
36
44
  };
37
- new cert_manager.v1.ClusterIssuer(
38
- name,
39
- {
40
- metadata: {
41
- name
42
- },
43
- spec: {
44
- acme: {
45
- server: getAcmeServer(),
46
- solvers: [
47
- {
48
- dns01: dns01SolverMediator.callOutput(inputs.dnsProvider.implRef, {
49
- namespace: certManagerNs
50
- }),
51
- selector: { dnsZones: inputs.dnsProvider.zones }
52
- }
53
- ],
54
- privateKeySecretRef: {
55
- name
56
- },
57
- externalAccountBinding: eabSecret ? {
58
- keyID: eabSecret.stringData.keyId,
59
- keySecretRef: {
60
- name: eabSecret.metadata.name,
61
- key: "keySecret"
62
- }
63
- } : void 0
64
- }
65
- }
45
+ new cert_manager.v1.ClusterIssuer(name, {
46
+ metadata: {
47
+ name
66
48
  },
67
- { provider }
68
- );
49
+ spec: {
50
+ acme: {
51
+ server: getAcmeServer(),
52
+ solvers: [
53
+ {
54
+ dns01: dns01SolverMediator.callOutput(inputs.dnsProvider.implRef, {
55
+ namespace: certManagerNs
56
+ }),
57
+ selector: { dnsZones: inputs.dnsProvider.zones }
58
+ }
59
+ ],
60
+ privateKeySecretRef: {
61
+ name
62
+ },
63
+ externalAccountBinding: eabSecret ? {
64
+ keyID: eabSecret.stringData.keyId,
65
+ keySecretRef: {
66
+ name: eabSecret.metadata.name,
67
+ key: "keySecret"
68
+ }
69
+ } : undefined
70
+ }
71
+ }
72
+ }, { provider });
69
73
  var dns01_issuer_default = outputs({
70
74
  tlsIssuer: makeEntityOutput({
71
75
  entity: common.tlsIssuerEntity,
@@ -88,7 +92,6 @@ var dns01_issuer_default = outputs({
88
92
  zones: inputs.dnsProvider.zones
89
93
  }
90
94
  });
91
-
92
- export { dns01_issuer_default as default };
93
- //# sourceMappingURL=index.js.map
94
- //# sourceMappingURL=index.js.map
95
+ export {
96
+ dns01_issuer_default as default
97
+ };
@@ -1,17 +1,30 @@
1
- import { detectExternalIps, createK8sTerminal } from '../../chunk-ADHZK6V2.js';
2
- import '../../chunk-TOLFVF4S.js';
3
- import '../../chunk-PZYGZSN5.js';
4
- import { parseAddress, mergeAddresses, parseEndpoints, parseEndpoint, mergeEndpoints, l4EndpointToString, l3EndpointToString } from '@highstate/common';
5
- import { k8s, common } from '@highstate/library';
6
- import { forUnit, toPromise, makeEntityOutput } from '@highstate/pulumi';
7
- import { KubeConfig, AppsV1Api } from '@kubernetes/client-node';
8
- import { Provider, core } from '@pulumi/kubernetes';
1
+ // @bun
2
+ import {
3
+ createK8sTerminal,
4
+ detectExternalIps
5
+ } from "../../chunk-9hs97f1q.js";
6
+ import"../../chunk-facs31cb.js";
7
+ import"../../chunk-b05q6fm2.js";
9
8
 
9
+ // src/units/existing-cluster/index.ts
10
+ import {
11
+ l3EndpointToString,
12
+ l4EndpointToString,
13
+ mergeAddresses,
14
+ mergeEndpoints,
15
+ parseAddress,
16
+ parseEndpoint,
17
+ parseEndpoints
18
+ } from "@highstate/common";
19
+ import { common, k8s } from "@highstate/library";
20
+ import { forUnit, makeEntityOutput, toPromise } from "@highstate/pulumi";
21
+ import { AppsV1Api, KubeConfig } from "@kubernetes/client-node";
22
+ import { core, Provider } from "@pulumi/kubernetes";
10
23
  var { name, args, inputs, secrets, outputs } = forUnit(k8s.existingCluster);
11
24
  var kubeconfigContent = await toPromise(secrets.kubeconfig.apply(JSON.stringify));
12
25
  var provider = new Provider(name, { kubeconfig: kubeconfigContent });
13
26
  var networkPolicyImplRef;
14
- var kubeConfig = new KubeConfig();
27
+ var kubeConfig = new KubeConfig;
15
28
  kubeConfig.loadFromString(kubeconfigContent);
16
29
  var appsApi = kubeConfig.makeApiClient(AppsV1Api);
17
30
  var hasCilium = await appsApi.readNamespacedDaemonSet({ name: "cilium", namespace: "kube-system" }).then(() => true).catch(() => false);
@@ -77,7 +90,6 @@ var existing_cluster_default = outputs({
77
90
  apiEndpoints: apiEndpoints.map(l4EndpointToString)
78
91
  }
79
92
  });
80
-
81
- export { existing_cluster_default as default };
82
- //# sourceMappingURL=index.js.map
83
- //# sourceMappingURL=index.js.map
93
+ export {
94
+ existing_cluster_default as default
95
+ };
@@ -1,22 +1,21 @@
1
- import { getProviderAsync } from '../../chunk-TOLFVF4S.js';
2
- import '../../chunk-PZYGZSN5.js';
3
- import { k8s } from '@highstate/library';
4
- import { forUnit } from '@highstate/pulumi';
5
- import { yaml } from '@pulumi/kubernetes';
1
+ // @bun
2
+ import {
3
+ getProviderAsync
4
+ } from "../../chunk-facs31cb.js";
5
+ import"../../chunk-b05q6fm2.js";
6
6
 
7
+ // src/units/gateway-api/index.ts
8
+ import { k8s } from "@highstate/library";
9
+ import { forUnit } from "@highstate/pulumi";
10
+ import { yaml } from "@pulumi/kubernetes";
7
11
  var { inputs, outputs } = forUnit(k8s.gatewayApi);
8
12
  var provider = await getProviderAsync(inputs.k8sCluster);
9
- new yaml.v2.ConfigFile(
10
- "gateway-api",
11
- {
12
- file: "https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.4.0/experimental-install.yaml"
13
- },
14
- { provider }
15
- );
13
+ new yaml.v2.ConfigFile("gateway-api", {
14
+ file: "https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.4.0/experimental-install.yaml"
15
+ }, { provider });
16
16
  var gateway_api_default = outputs({
17
17
  k8sCluster: inputs.k8sCluster
18
18
  });
19
-
20
- export { gateway_api_default as default };
21
- //# sourceMappingURL=index.js.map
22
- //# sourceMappingURL=index.js.map
19
+ export {
20
+ gateway_api_default as default
21
+ };
@@ -1,30 +1,29 @@
1
- import { createK8sTerminal } from '../../chunk-ADHZK6V2.js';
2
- import { ClusterAccessScope, Namespace, getClusterKubeconfigContent } from '../../chunk-TOLFVF4S.js';
3
- import '../../chunk-PZYGZSN5.js';
4
- import { text, trimIndentation } from '@highstate/contract';
5
- import { k8s } from '@highstate/library';
6
- import { forUnit, toPromise, output, interpolate, makeFileOutput, secret } from '@highstate/pulumi';
7
- import { join } from 'remeda';
1
+ // @bun
2
+ import {
3
+ createK8sTerminal
4
+ } from "../../chunk-9hs97f1q.js";
5
+ import {
6
+ ClusterAccessScope,
7
+ Namespace,
8
+ getClusterKubeconfigContent
9
+ } from "../../chunk-facs31cb.js";
10
+ import"../../chunk-b05q6fm2.js";
8
11
 
12
+ // src/units/reduced-access-cluster/index.ts
13
+ import { text, trimIndentation } from "@highstate/contract";
14
+ import { k8s } from "@highstate/library";
15
+ import { forUnit, interpolate, makeFileOutput, output, secret, toPromise } from "@highstate/pulumi";
16
+ import { join } from "remeda";
9
17
  var { args, inputs, outputs } = forUnit(k8s.reducedAccessCluster);
10
18
  var resolvedInputs = await toPromise(inputs);
11
- var accessScope = new ClusterAccessScope(
12
- "scope",
13
- {
14
- namespace: Namespace.for(resolvedInputs.namespace, inputs.k8sCluster),
15
- extraNamespaces: resolvedInputs.extraNamespaces.map((ns) => Namespace.for(ns, inputs.k8sCluster)),
16
- rules: args.rules,
17
- resources: resolvedInputs.resources
18
- },
19
- {}
20
- );
21
- var resourceLines = await toPromise(
22
- output(
23
- resolvedInputs.resources.map(
24
- (r) => r.isNamespaced ? interpolate`- ${r.kind} "${r.metadata.namespace}/${r.metadata.name}"` : interpolate`- ${r.kind} "${r.metadata.name}"`
25
- )
26
- ).apply(join("\n"))
27
- );
19
+ var accessScope = new ClusterAccessScope("scope", {
20
+ namespace: Namespace.for(resolvedInputs.namespace, inputs.k8sCluster),
21
+ extraNamespaces: resolvedInputs.extraNamespaces.map((ns) => Namespace.for(ns, inputs.k8sCluster)),
22
+ rules: args.rules,
23
+ resources: resolvedInputs.resources
24
+ }, {});
25
+ var resourceLines = await toPromise(output(resolvedInputs.resources.map((r) => r.isNamespaced ? interpolate`- ${r.kind} "${r.metadata.namespace}/${r.metadata.name}"` : interpolate`- ${r.kind} "${r.metadata.name}"`)).apply(join(`
26
+ `)));
28
27
  var reduced_access_cluster_default = outputs({
29
28
  k8sCluster: accessScope.cluster,
30
29
  $terminals: [createK8sTerminal(secret(getClusterKubeconfigContent(accessScope.cluster)))],
@@ -59,15 +58,13 @@ var reduced_access_cluster_default = outputs({
59
58
  },
60
59
  {
61
60
  type: "markdown",
62
- content: secret(
63
- interpolate`
61
+ content: secret(interpolate`
64
62
  You can also copy the following content of the kubeconfig file:
65
63
 
66
64
  \`\`\`yaml
67
65
  ${accessScope.cluster.kubeconfig}
68
66
  \`\`\`
69
- `.apply(trimIndentation)
70
- )
67
+ `.apply(trimIndentation))
71
68
  },
72
69
  {
73
70
  type: "markdown",
@@ -77,7 +74,6 @@ var reduced_access_cluster_default = outputs({
77
74
  }
78
75
  }
79
76
  });
80
-
81
- export { reduced_access_cluster_default as default };
82
- //# sourceMappingURL=index.js.map
83
- //# sourceMappingURL=index.js.map
77
+ export {
78
+ reduced_access_cluster_default as default
79
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highstate/k8s",
3
- "version": "0.20.0",
3
+ "version": "0.21.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -61,11 +61,26 @@
61
61
  "stdlib"
62
62
  ]
63
63
  },
64
+ "scripts": {
65
+ "build": "highstate build",
66
+ "update-charts": "../../../scripts/update-charts.sh ./assets/charts.json",
67
+ "update-images": "../../../scripts/update-images.sh ./assets/images.json",
68
+ "generate-crds": "./scripts/generate-crds.sh",
69
+ "typecheck": "tsgo --noEmit --skipLibCheck",
70
+ "biome": "biome check --write --unsafe --error-on-warnings",
71
+ "biome:check": "biome check --error-on-warnings"
72
+ },
64
73
  "dependencies": {
74
+ "@highstate/cert-manager": "0.20.0",
75
+ "@highstate/common": "0.20.0",
76
+ "@highstate/contract": "0.20.0",
77
+ "@highstate/gateway-api": "0.20.0",
78
+ "@highstate/library": "0.20.0",
79
+ "@highstate/pulumi": "0.20.0",
65
80
  "@kubernetes/client-node": "^1.1.0",
66
81
  "@pulumi/command": "^1.0.2",
67
82
  "@pulumi/kubernetes": "^4.18.0",
68
- "@pulumi/pulumi": "3.220.0",
83
+ "@pulumi/pulumi": "3.232.0",
69
84
  "crypto-hash": "^3.1.0",
70
85
  "deepmerge-ts": "^7.1.5",
71
86
  "glob": "^11.0.1",
@@ -73,30 +88,15 @@
73
88
  "get-port-please": "^3.1.2",
74
89
  "pkg-types": "^2.1.0",
75
90
  "remeda": "^2.21.0",
76
- "yaml": "^2.8.1",
77
- "@highstate/cert-manager": "0.14.0",
78
- "@highstate/common": "0.20.0",
79
- "@highstate/contract": "0.20.0",
80
- "@highstate/gateway-api": "0.14.0",
81
- "@highstate/library": "0.20.0",
82
- "@highstate/pulumi": "0.20.0"
91
+ "yaml": "^2.8.1"
83
92
  },
84
93
  "devDependencies": {
85
94
  "@biomejs/biome": "2.2.0",
95
+ "@highstate/cli": "0.20.0",
86
96
  "@typescript/native-preview": "^7.0.0-dev.20250920.1",
87
- "type-fest": "^4.41.0",
88
- "@highstate/cli": "0.20.0"
97
+ "type-fest": "^4.41.0"
89
98
  },
90
99
  "repository": {
91
100
  "url": "https://github.com/highstate-io/highstate"
92
- },
93
- "scripts": {
94
- "build": "highstate build",
95
- "update-charts": "../../../scripts/update-charts.sh ./assets/charts.json",
96
- "update-images": "../../../scripts/update-images.sh ./assets/images.json",
97
- "generate-crds": "./scripts/generate-crds.sh",
98
- "typecheck": "tsgo --noEmit --skipLibCheck",
99
- "biome": "biome check --write --unsafe --error-on-warnings",
100
- "biome:check": "biome check --error-on-warnings"
101
101
  }
102
- }
102
+ }
package/src/cron-job.ts CHANGED
@@ -355,6 +355,31 @@ class CronJobPatch extends CronJob {
355
355
  )
356
356
  })
357
357
 
358
+ const filteredSpec = output({ spec: cronJob.spec, podTemplate }).apply(
359
+ ({ spec, podTemplate }) => {
360
+ const template = spec.jobTemplate?.spec?.template
361
+ if (!template) {
362
+ return spec
363
+ }
364
+
365
+ const filteredTemplate = filterPatchOwnedContainersInTemplate(
366
+ template as Unwrap<types.input.core.v1.PodTemplateSpec>,
367
+ podTemplate,
368
+ ) as types.output.core.v1.PodTemplateSpec
369
+
370
+ return {
371
+ ...spec,
372
+ jobTemplate: {
373
+ ...spec.jobTemplate,
374
+ spec: {
375
+ ...spec.jobTemplate.spec,
376
+ template: filteredTemplate,
377
+ },
378
+ },
379
+ }
380
+ },
381
+ ) as Output<types.output.batch.v1.CronJobSpec>
382
+
358
383
  super(
359
384
  "highstate:k8s:CronJobPatch",
360
385
  name,
@@ -365,7 +390,7 @@ class CronJobPatch extends CronJob {
365
390
  output(args.terminal ?? {}),
366
391
  containers,
367
392
  networkPolicy,
368
- cronJob.spec,
393
+ filteredSpec,
369
394
  cronJob.status,
370
395
  )
371
396
  }
package/src/deployment.ts CHANGED
@@ -332,6 +332,22 @@ class DeploymentPatch extends Deployment {
332
332
  )
333
333
  })
334
334
 
335
+ const filteredSpec = output({ spec: deployment.spec, podTemplate }).apply(
336
+ ({ spec, podTemplate }) => {
337
+ if (!spec.template) {
338
+ return spec
339
+ }
340
+
341
+ return {
342
+ ...spec,
343
+ template: filterPatchOwnedContainersInTemplate(
344
+ spec.template as Unwrap<types.input.core.v1.PodTemplateSpec>,
345
+ podTemplate,
346
+ ) as types.output.core.v1.PodTemplateSpec,
347
+ }
348
+ },
349
+ ) as Output<types.output.apps.v1.DeploymentSpec>
350
+
335
351
  super(
336
352
  "highstate:k8s:DeploymentPatch",
337
353
  name,
@@ -347,7 +363,7 @@ class DeploymentPatch extends Deployment {
347
363
  service,
348
364
  routes,
349
365
 
350
- deployment.spec,
366
+ filteredSpec,
351
367
  deployment.status,
352
368
  )
353
369
  }
package/src/job.ts CHANGED
@@ -326,6 +326,20 @@ class JobPatch extends Job {
326
326
  )
327
327
  })
328
328
 
329
+ const filteredSpec = output({ spec: job.spec, podTemplate }).apply(({ spec, podTemplate }) => {
330
+ if (!spec.template) {
331
+ return spec
332
+ }
333
+
334
+ return {
335
+ ...spec,
336
+ template: filterPatchOwnedContainersInTemplate(
337
+ spec.template as Unwrap<types.input.core.v1.PodTemplateSpec>,
338
+ podTemplate,
339
+ ) as types.output.core.v1.PodTemplateSpec,
340
+ }
341
+ }) as Output<types.output.batch.v1.JobSpec>
342
+
329
343
  super(
330
344
  "highstate:k8s:JobPatch",
331
345
  name,
@@ -336,7 +350,7 @@ class JobPatch extends Job {
336
350
  output(args.terminal ?? {}),
337
351
  containers,
338
352
  networkPolicy,
339
- job.spec,
353
+ filteredSpec,
340
354
  job.status,
341
355
  )
342
356
 
@@ -12,14 +12,10 @@ import {
12
12
  output,
13
13
  type Unwrap,
14
14
  } from "@pulumi/pulumi"
15
- import { serializeFunction } from "@pulumi/pulumi/runtime/index.js"
16
15
  import { deepmerge } from "deepmerge-ts"
17
- import { readPackageJSON } from "pkg-types"
18
- import { mapValues, omitBy } from "remeda"
19
16
  import { ConfigMap } from "../config-map"
20
17
  import {
21
18
  emptyScriptEnvironment,
22
- functionScriptImages,
23
19
  type ResolvedScriptEnvironment,
24
20
  type ScriptDistribution,
25
21
  type ScriptEnvironment,
@@ -87,35 +83,19 @@ export class ScriptBundle extends ComponentResource {
87
83
  Unwrap<ResolvedScriptEnvironment>
88
84
  >
89
85
 
90
- const hasFunctionScripts = scriptEnvironment.apply(scriptEnvironment => {
91
- return Object.values(scriptEnvironment.files).some(file => typeof file === "function")
92
- })
93
-
94
86
  this.distribution = args.distribution
95
87
  this.environment = scriptEnvironment.environment
96
88
 
97
- this.image = hasFunctionScripts.apply(hasFunctionScripts =>
98
- output(
99
- hasFunctionScripts
100
- ? functionScriptImages[args.distribution]
101
- : scriptEnvironment[args.distribution].image,
102
- ),
103
- )
89
+ this.image = scriptEnvironment[args.distribution].image
104
90
 
105
- this.allowedEndpoints = output({ scriptEnvironment, hasFunctionScripts }).apply(
106
- ({ scriptEnvironment, hasFunctionScripts }) => {
107
- const allowedEndpoints = [
108
- ...scriptEnvironment.allowedEndpoints,
109
- ...scriptEnvironment[args.distribution].allowedEndpoints,
110
- ]
111
-
112
- if (hasFunctionScripts) {
113
- allowedEndpoints.push("tcp://registry.npmjs.org:443")
114
- }
91
+ this.allowedEndpoints = scriptEnvironment.apply(scriptEnvironment => {
92
+ const allowedEndpoints = [
93
+ ...scriptEnvironment.allowedEndpoints,
94
+ ...scriptEnvironment[args.distribution].allowedEndpoints,
95
+ ]
115
96
 
116
- return allowedEndpoints.map(endpoint => parseEndpoint(endpoint))
117
- },
118
- )
97
+ return allowedEndpoints.map(endpoint => parseEndpoint(endpoint))
98
+ })
119
99
 
120
100
  this.configMap = output({ scriptEnvironment, args }).apply(({ scriptEnvironment, args }) => {
121
101
  return ConfigMap.create(
@@ -129,49 +109,32 @@ export class ScriptBundle extends ComponentResource {
129
109
  )
130
110
  })
131
111
 
132
- this.volumes = output({ hasFunctionScripts, volumes: scriptEnvironment.volumes }).apply(
133
- ({ hasFunctionScripts, volumes }) => {
134
- return [
135
- ...volumes,
136
- {
137
- name: this.configMap.metadata.name,
112
+ this.volumes = scriptEnvironment.volumes.apply(volumes => {
113
+ return [
114
+ ...volumes,
115
+ {
116
+ name: this.configMap.metadata.name,
138
117
 
139
- configMap: {
140
- name: this.configMap.metadata.name,
141
- defaultMode: 0o550, // read and execute permissions
142
- },
118
+ configMap: {
119
+ name: this.configMap.metadata.name,
120
+ defaultMode: 0o550, // read and execute permissions
143
121
  },
144
- ...(hasFunctionScripts ? [{ name: "node-modules", emptyDir: {} }] : []),
145
- ]
146
- },
147
- )
122
+ },
123
+ ]
124
+ })
148
125
 
149
- this.volumeMounts = output({
150
- hasFunctionScripts,
151
- volumeMounts: scriptEnvironment.volumeMounts,
152
- }).apply(({ hasFunctionScripts, volumeMounts }) => {
126
+ this.volumeMounts = scriptEnvironment.volumeMounts.apply(volumeMounts => {
153
127
  return [
154
128
  ...volumeMounts,
155
129
  {
156
130
  volume: this.configMap,
157
131
  mountPath: "/scripts",
158
132
  },
159
- ...(hasFunctionScripts
160
- ? [{ name: "node-modules", mountPath: "/scripts/node_modules" }]
161
- : []),
162
133
  ]
163
134
  })
164
135
  }
165
136
  }
166
137
 
167
- function stripWorkspacePrefix(value: string): string {
168
- if (value.startsWith("workspace:")) {
169
- return value.replace("workspace:", "")
170
- }
171
-
172
- return value
173
- }
174
-
175
138
  async function createScriptData(
176
139
  distribution: ScriptDistribution,
177
140
  environment: Unwrap<ResolvedScriptEnvironment>,
@@ -182,48 +145,8 @@ async function createScriptData(
182
145
  const distributionEnvironment = environment[distribution]
183
146
  const setupScripts = { ...environment.setupScripts }
184
147
 
185
- let hasFunctionScripts = false
186
-
187
148
  for (const key in environment.files) {
188
- if (typeof environment.files[key] === "function") {
189
- const serialized = await serializeFunction(environment.files[key])
190
-
191
- scriptData[key] = text`
192
- #!/usr/local/bin/bun
193
-
194
- ${serialized.text}
195
-
196
- exports.${serialized.exportName}()
197
- `
198
-
199
- hasFunctionScripts = true
200
- } else {
201
- scriptData[key] = environment.files[key]
202
- }
203
- }
204
-
205
- if (hasFunctionScripts) {
206
- const packageJson = await readPackageJSON()
207
-
208
- packageJson.dependencies = omitBy(
209
- mapValues(packageJson.dependencies ?? {}, stripWorkspacePrefix),
210
- (_, key) => key.startsWith("@highstate/"),
211
- )
212
-
213
- packageJson.devDependencies = omitBy(
214
- mapValues(packageJson.devDependencies ?? {}, stripWorkspacePrefix),
215
- (_, key) => key.startsWith("@highstate/"),
216
- )
217
-
218
- scriptData["package.json"] = JSON.stringify(packageJson, null, 2)
219
-
220
- setupScripts["resolve-dependencies.sh"] = text`
221
- #!/usr/local/bin/bun
222
- set -e
223
-
224
- cd /scripts
225
- bun install --production
226
- `
149
+ scriptData[key] = environment.files[key]
227
150
  }
228
151
 
229
152
  if (distributionEnvironment.preInstallPackages.length > 0) {
@@ -1,7 +1,7 @@
1
1
  import type { InputEndpoint } from "@highstate/common"
2
2
  import type { Input, InputArray, InputRecord } from "@highstate/pulumi"
3
3
  import type { ContainerEnvironment, ContainerVolumeMount, WorkloadVolume } from "../container"
4
- import { images } from ".."
4
+ import images from "../../assets/images.json"
5
5
 
6
6
  export type ScriptDistribution = "alpine" | "ubuntu"
7
7
 
@@ -39,8 +39,6 @@ export type DistributionEnvironment = {
39
39
  allowedEndpoints?: InputArray<InputEndpoint>
40
40
  }
41
41
 
42
- export type ScriptProgram = () => unknown
43
-
44
42
  export type ScriptEnvironment = {
45
43
  [distribution in ScriptDistribution]?: DistributionEnvironment
46
44
  } & {
@@ -57,7 +55,7 @@ export type ScriptEnvironment = {
57
55
  /**
58
56
  * The arbitrary files available in the environment including scripts.
59
57
  */
60
- files?: InputRecord<string | ScriptProgram>
58
+ files?: InputRecord<string>
61
59
 
62
60
  /**
63
61
  * The volumes that should be defined in the environment.
@@ -123,8 +121,3 @@ export const emptyScriptEnvironment: ResolvedScriptEnvironment = {
123
121
  environment: {},
124
122
  allowedEndpoints: [],
125
123
  }
126
-
127
- export const functionScriptImages: Record<ScriptDistribution, string> = {
128
- alpine: "oven/bun@sha256:6b14922b0885c3890cdb0b396090af1da486ba941df5ee94391eef64f7113c61",
129
- ubuntu: "oven/bun@sha256:66b431441dc4c36d7e8164bfc61e6348ec1d7ce2862fc3a29f5dc9856e8205e4",
130
- }
package/src/shared.ts CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  type Unwrap,
13
13
  } from "@highstate/pulumi"
14
14
  import { core, Provider, type types } from "@pulumi/kubernetes"
15
- import * as images from "../assets/images.json"
15
+ import images from "../assets/images.json"
16
16
  import { Namespace } from "./namespace"
17
17
 
18
18
  const providers = new Map<`${string}.${string}`, Provider>()