@highstate/k8s 0.7.2 → 0.7.3

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 (44) hide show
  1. package/dist/{helm-wPTgVV1N.js → chunk-K4WKJ4L5.js} +89 -47
  2. package/dist/chunk-K4WKJ4L5.js.map +1 -0
  3. package/dist/{shared-Clzbl5K-.js → chunk-T5Z2M4JE.js} +21 -7
  4. package/dist/chunk-T5Z2M4JE.js.map +1 -0
  5. package/dist/highstate.manifest.json +9 -0
  6. package/dist/index.js +304 -154
  7. package/dist/index.js.map +1 -0
  8. package/dist/units/access-point/index.js +9 -7
  9. package/dist/units/access-point/index.js.map +1 -0
  10. package/dist/units/cert-manager/index.js +29 -29
  11. package/dist/units/cert-manager/index.js.map +1 -0
  12. package/dist/units/dns01-issuer/index.js +22 -14
  13. package/dist/units/dns01-issuer/index.js.map +1 -0
  14. package/dist/units/existing-cluster/index.js +49 -21
  15. package/dist/units/existing-cluster/index.js.map +1 -0
  16. package/package.json +15 -16
  17. package/src/access-point.ts +185 -0
  18. package/src/container.ts +271 -0
  19. package/src/cron-job.ts +77 -0
  20. package/src/deployment.ts +210 -0
  21. package/src/gateway/backend.ts +61 -0
  22. package/src/gateway/http-route.ts +139 -0
  23. package/src/gateway/index.ts +2 -0
  24. package/src/helm.ts +298 -0
  25. package/src/index.ts +61 -0
  26. package/src/job.ts +66 -0
  27. package/src/network-policy.ts +732 -0
  28. package/src/pod.ts +5 -0
  29. package/src/pvc.ts +178 -0
  30. package/src/scripting/bundle.ts +244 -0
  31. package/src/scripting/container.ts +44 -0
  32. package/src/scripting/environment.ts +79 -0
  33. package/src/scripting/index.ts +3 -0
  34. package/src/service.ts +279 -0
  35. package/src/shared.ts +150 -0
  36. package/src/stateful-set.ts +159 -0
  37. package/src/units/access-point/index.ts +12 -0
  38. package/src/units/cert-manager/index.ts +37 -0
  39. package/src/units/dns01-issuer/index.ts +41 -0
  40. package/src/units/dns01-issuer/solver.ts +23 -0
  41. package/src/units/existing-cluster/index.ts +107 -0
  42. package/src/workload.ts +150 -0
  43. package/assets/charts.json +0 -8
  44. package/dist/index.d.ts +0 -1036
package/dist/index.js CHANGED
@@ -1,26 +1,55 @@
1
- import { m as mapMetadata, c as commonExtraArgs, v as verifyProvider, r as resourceIdToString, a as mapSelectorLikeToSelector, b as mapNamespaceNameToSelector, d as mapNamespaceLikeToNamespaceName, g as getAppDisplayName, e as getAppName } from './shared-Clzbl5K-.js';
2
- export { h as createNamespace, f as createProvider, i as getNamespace } from './shared-Clzbl5K-.js';
3
- import { ComponentResource, output, normalize, toPromise, apply } from '@highstate/pulumi';
4
- import { core, apps, networking, batch } from '@pulumi/kubernetes';
5
- import { omit, concat, map, uniqueBy, capitalize, mergeDeep, flat, merge, pipe } from 'remeda';
6
- import { deepmerge } from 'deepmerge-ts';
7
- import { output as output$1, ComponentResource as ComponentResource$1 } from '@pulumi/pulumi';
8
- import { S as Service, m as mapContainerPortToServicePort, H as HttpRoute, a as mapServiceToLabelSelector } from './helm-wPTgVV1N.js';
9
- export { C as Chart, R as RenderedChart, b as getChartService, g as getChartServiceOutput, r as resolveHelmChart } from './helm-wPTgVV1N.js';
10
- import { parseDomain, ParseResultType } from 'parse-domain';
11
- import '@highstate/library';
12
- import { DnsRecord } from '@highstate/common';
13
- import { gateway } from '@highstate/gateway-api';
14
- import { trimIndentation, text } from '@highstate/contract';
15
- import 'path';
16
- import 'node:fs/promises';
17
- import 'nano-spawn';
18
- import 'crypto-hash';
19
- import '@pulumi/command';
20
- import 'glob';
1
+ import {
2
+ Chart,
3
+ HttpRoute,
4
+ RenderedChart,
5
+ Service,
6
+ getChartService,
7
+ getChartServiceOutput,
8
+ mapContainerPortToServicePort,
9
+ mapServiceToLabelSelector,
10
+ resolveHelmChart
11
+ } from "./chunk-K4WKJ4L5.js";
12
+ import {
13
+ commonExtraArgs,
14
+ createNamespace,
15
+ getAppDisplayName,
16
+ getAppName,
17
+ getNamespace,
18
+ getProvider,
19
+ mapMetadata,
20
+ mapNamespaceLikeToNamespaceName,
21
+ mapNamespaceNameToSelector,
22
+ mapSelectorLikeToSelector,
23
+ resourceIdToString,
24
+ verifyProvider
25
+ } from "./chunk-T5Z2M4JE.js";
21
26
 
22
- const extraPersistentVolumeClaimArgs = [...commonExtraArgs, "size", "cluster"];
23
- class PersistentVolumeClaim extends ComponentResource {
27
+ // src/deployment.ts
28
+ import {
29
+ output as output4,
30
+ ComponentResource as ComponentResource3,
31
+ interpolate
32
+ } from "@highstate/pulumi";
33
+ import { apps } from "@pulumi/kubernetes";
34
+ import { omit as omit3 } from "remeda";
35
+ import { deepmerge as deepmerge2 } from "deepmerge-ts";
36
+ import { trimIndentation } from "@highstate/contract";
37
+
38
+ // src/container.ts
39
+ import { core as core2 } from "@pulumi/kubernetes";
40
+ import { normalize, output as output2 } from "@highstate/pulumi";
41
+ import { concat, map, omit as omit2 } from "remeda";
42
+
43
+ // src/pvc.ts
44
+ import { core } from "@pulumi/kubernetes";
45
+ import {
46
+ ComponentResource,
47
+ output
48
+ } from "@highstate/pulumi";
49
+ import { deepmerge } from "deepmerge-ts";
50
+ import { omit } from "remeda";
51
+ var extraPersistentVolumeClaimArgs = [...commonExtraArgs, "size", "cluster"];
52
+ var PersistentVolumeClaim = class extends ComponentResource {
24
53
  constructor(type, name, args, opts, clusterInfo, metadata, spec, status) {
25
54
  super(type, name, args, opts);
26
55
  this.clusterInfo = clusterInfo;
@@ -49,8 +78,8 @@ class PersistentVolumeClaim extends ComponentResource {
49
78
  opts
50
79
  );
51
80
  }
52
- }
53
- class CreatedPersistentVolumeClaim extends PersistentVolumeClaim {
81
+ };
82
+ var CreatedPersistentVolumeClaim = class extends PersistentVolumeClaim {
54
83
  constructor(name, args, opts) {
55
84
  const pvc = output(args).apply((args2) => {
56
85
  return new core.v1.PersistentVolumeClaim(
@@ -83,8 +112,8 @@ class CreatedPersistentVolumeClaim extends PersistentVolumeClaim {
83
112
  pvc.status
84
113
  );
85
114
  }
86
- }
87
- class ExternalPersistentVolumeClaim extends PersistentVolumeClaim {
115
+ };
116
+ var ExternalPersistentVolumeClaim = class extends PersistentVolumeClaim {
88
117
  constructor(name, id, clusterInfo, opts) {
89
118
  const pvc = output(id).apply(async (id2) => {
90
119
  await verifyProvider(opts.provider, this.clusterInfo);
@@ -106,9 +135,10 @@ class ExternalPersistentVolumeClaim extends PersistentVolumeClaim {
106
135
  pvc.status
107
136
  );
108
137
  }
109
- }
138
+ };
110
139
 
111
- const containerExtraArgs = [
140
+ // src/container.ts
141
+ var containerExtraArgs = [
112
142
  "port",
113
143
  "volumeMount",
114
144
  "volume",
@@ -119,7 +149,7 @@ const containerExtraArgs = [
119
149
  function mapContainerToRaw(container, fallbackName) {
120
150
  const containerName = container.name ?? fallbackName;
121
151
  return {
122
- ...omit(container, containerExtraArgs),
152
+ ...omit2(container, containerExtraArgs),
123
153
  name: containerName,
124
154
  ports: normalize(container.port, container.ports),
125
155
  volumeMounts: map(normalize(container.volumeMount, container.volumeMounts), mapVolumeMount),
@@ -176,10 +206,10 @@ function mapContainerEnvironment(environment) {
176
206
  }
177
207
  function mapVolumeMount(volumeMount) {
178
208
  if ("volume" in volumeMount) {
179
- return omit(
209
+ return omit2(
180
210
  {
181
211
  ...volumeMount,
182
- name: output(volumeMount.volume).apply(mapWorkloadVolume).apply((volume) => output(volume.name))
212
+ name: output2(volumeMount.volume).apply(mapWorkloadVolume).apply((volume) => output2(volume.name))
183
213
  },
184
214
  ["volume"]
185
215
  );
@@ -190,14 +220,14 @@ function mapVolumeMount(volumeMount) {
190
220
  };
191
221
  }
192
222
  function mapEnvironmentSource(envFrom) {
193
- if (envFrom instanceof core.v1.ConfigMap) {
223
+ if (envFrom instanceof core2.v1.ConfigMap) {
194
224
  return {
195
225
  configMapRef: {
196
226
  name: envFrom.metadata.name
197
227
  }
198
228
  };
199
229
  }
200
- if (envFrom instanceof core.v1.Secret) {
230
+ if (envFrom instanceof core2.v1.Secret) {
201
231
  return {
202
232
  secretRef: {
203
233
  name: envFrom.metadata.name
@@ -215,7 +245,7 @@ function mapWorkloadVolume(volume) {
215
245
  }
216
246
  };
217
247
  }
218
- if (volume instanceof core.v1.PersistentVolumeClaim) {
248
+ if (volume instanceof core2.v1.PersistentVolumeClaim) {
219
249
  return {
220
250
  name: volume.metadata.name,
221
251
  persistentVolumeClaim: {
@@ -223,7 +253,7 @@ function mapWorkloadVolume(volume) {
223
253
  }
224
254
  };
225
255
  }
226
- if (volume instanceof core.v1.ConfigMap) {
256
+ if (volume instanceof core2.v1.ConfigMap) {
227
257
  return {
228
258
  name: volume.metadata.name,
229
259
  configMap: {
@@ -231,7 +261,7 @@ function mapWorkloadVolume(volume) {
231
261
  }
232
262
  };
233
263
  }
234
- if (volume instanceof core.v1.Secret) {
264
+ if (volume instanceof core2.v1.Secret) {
235
265
  return {
236
266
  name: volume.metadata.name,
237
267
  secret: {
@@ -242,17 +272,21 @@ function mapWorkloadVolume(volume) {
242
272
  return volume;
243
273
  }
244
274
 
245
- const workloadExtraArgs = [...commonExtraArgs, "container", "containers"];
246
- const publicWorkloadExtraArgs = [...workloadExtraArgs, "service", "httpRoute"];
275
+ // src/workload.ts
276
+ import { normalize as normalize2 } from "@highstate/pulumi";
277
+ import { ComponentResource as ComponentResource2, output as output3 } from "@pulumi/pulumi";
278
+ import { uniqueBy } from "remeda";
279
+ var workloadExtraArgs = [...commonExtraArgs, "container", "containers"];
280
+ var publicWorkloadExtraArgs = [...workloadExtraArgs, "service", "httpRoute"];
247
281
  function getWorkloadComponents(name, args) {
248
282
  const labels = {
249
283
  "app.kubernetes.io/name": name
250
284
  };
251
- const containers = output$1(args).apply((args2) => normalize(args2.container, args2.containers));
285
+ const containers = output3(args).apply((args2) => normalize2(args2.container, args2.containers));
252
286
  const volumes = containers.apply((containers2) => {
253
- const containerVolumes = containers2.flatMap((container) => normalize(container.volume, container.volumes)).map(mapWorkloadVolume);
287
+ const containerVolumes = containers2.flatMap((container) => normalize2(container.volume, container.volumes)).map(mapWorkloadVolume);
254
288
  const containerVolumeMounts = containers2.flatMap((container) => {
255
- return normalize(container.volumeMount, container.volumeMounts).map((volumeMount) => {
289
+ return normalize2(container.volumeMount, container.volumeMounts).map((volumeMount) => {
256
290
  return "volume" in volumeMount ? volumeMount.volume : void 0;
257
291
  }).filter(Boolean);
258
292
  }).map(mapWorkloadVolume);
@@ -262,7 +296,7 @@ function getWorkloadComponents(name, args) {
262
296
  }
263
297
  function getPublicWorkloadComponents(name, args, parent, opts) {
264
298
  const { labels, containers, volumes } = getWorkloadComponents(name, args);
265
- const service = output$1({ args, containers }).apply(({ args: args2, containers: containers2 }) => {
299
+ const service = output3({ args, containers }).apply(({ args: args2, containers: containers2 }) => {
266
300
  if (!args2.service && !args2.httpRoute) {
267
301
  return void 0;
268
302
  }
@@ -272,7 +306,7 @@ function getPublicWorkloadComponents(name, args, parent, opts) {
272
306
  if (args2.patch) {
273
307
  return void 0;
274
308
  }
275
- const ports = containers2.flatMap((container) => normalize(container.port, container.ports));
309
+ const ports = containers2.flatMap((container) => normalize2(container.port, container.ports));
276
310
  return Service.create(
277
311
  name,
278
312
  {
@@ -288,7 +322,7 @@ function getPublicWorkloadComponents(name, args, parent, opts) {
288
322
  { parent: parent(), ...opts }
289
323
  );
290
324
  });
291
- const httpRoute = output$1({
325
+ const httpRoute = output3({
292
326
  args,
293
327
  service
294
328
  }).apply(({ args: args2, service: service2 }) => {
@@ -312,10 +346,12 @@ function getPublicWorkloadComponents(name, args, parent, opts) {
312
346
  return { labels, containers, volumes, service, httpRoute };
313
347
  }
314
348
 
315
- class Deployment extends ComponentResource {
316
- constructor(type, name, args, opts, clusterInfo, metadata, spec, status, _service, _httpRoute, resources) {
349
+ // src/deployment.ts
350
+ var Deployment = class extends ComponentResource3 {
351
+ constructor(type, name, args, opts, cluster, metadata, spec, status, _service, _httpRoute, resources) {
317
352
  super(type, name, args, opts);
318
- this.clusterInfo = clusterInfo;
353
+ this.args = args;
354
+ this.cluster = cluster;
319
355
  this.metadata = metadata;
320
356
  this.spec = spec;
321
357
  this.status = status;
@@ -327,14 +363,17 @@ class Deployment extends ComponentResource {
327
363
  * The Highstate deployment entity.
328
364
  */
329
365
  get entity() {
330
- return output({
366
+ return output4({
331
367
  type: "k8s.deployment",
332
- clusterInfo: this.clusterInfo,
368
+ clusterInfo: this.cluster.info,
333
369
  metadata: this.metadata,
334
370
  spec: this.spec,
335
371
  service: this._service.apply((service) => service?.entity)
336
372
  });
337
373
  }
374
+ get optionalService() {
375
+ return this._service;
376
+ }
338
377
  /**
339
378
  * The service associated with the deployment.
340
379
  */
@@ -357,11 +396,36 @@ class Deployment extends ComponentResource {
357
396
  return httpRoute;
358
397
  });
359
398
  }
399
+ /**
400
+ * The instance terminal to interact with the deployment.
401
+ */
402
+ get terminal() {
403
+ return output4({
404
+ name: this.metadata.name,
405
+ title: this.metadata.name,
406
+ image: "ghcr.io/exeteres/highstate/terminal-kubectl",
407
+ command: ["script", "-q", "-c", "/enter-container.sh", "/dev/null"],
408
+ files: {
409
+ "/kubeconfig": this.cluster.kubeconfig,
410
+ "/enter-container.sh": {
411
+ mode: 493,
412
+ content: interpolate`
413
+ #!/bin/bash
414
+
415
+ exec kubectl exec -it -n ${this.metadata.namespace} deployment/${this.metadata.name} -- ${this.args.terminalShell ?? "bash"}
416
+ `.apply(trimIndentation)
417
+ }
418
+ },
419
+ env: {
420
+ KUBECONFIG: "/kubeconfig"
421
+ }
422
+ });
423
+ }
360
424
  static create(name, args, opts) {
361
425
  return new CreatedDeployment(name, args, opts);
362
426
  }
363
- }
364
- class CreatedDeployment extends Deployment {
427
+ };
428
+ var CreatedDeployment = class extends Deployment {
365
429
  constructor(name, args, opts) {
366
430
  const { labels, containers, volumes, service, httpRoute } = getPublicWorkloadComponents(
367
431
  name,
@@ -369,29 +433,25 @@ class CreatedDeployment extends Deployment {
369
433
  () => this,
370
434
  opts
371
435
  );
372
- const deployment = output({ args, containers, volumes }).apply(
436
+ const deployment = output4({ args, containers, volumes }).apply(
373
437
  async ({ args: args2, containers: containers2, volumes: volumes2 }) => {
374
438
  await verifyProvider(opts.provider, args2.cluster.info);
375
439
  return new (args2.patch ? apps.v1.DeploymentPatch : apps.v1.Deployment)(
376
440
  name,
377
441
  {
378
442
  metadata: mapMetadata(args2.patch?.metadata ?? args2, name),
379
- spec: deepmerge(
443
+ spec: deepmerge2(
380
444
  {
381
445
  template: {
382
- metadata: {
383
- labels
384
- },
446
+ metadata: !args2.patch ? { labels } : void 0,
385
447
  spec: {
386
448
  containers: containers2.map((container) => mapContainerToRaw(container, name)),
387
449
  volumes: volumes2
388
450
  }
389
451
  },
390
- selector: {
391
- matchLabels: labels
392
- }
452
+ selector: !args2.patch ? { matchLabels: labels } : void 0
393
453
  },
394
- omit(args2, publicWorkloadExtraArgs)
454
+ omit3(args2, publicWorkloadExtraArgs)
395
455
  )
396
456
  },
397
457
  { parent: this, ...opts }
@@ -403,7 +463,7 @@ class CreatedDeployment extends Deployment {
403
463
  name,
404
464
  args,
405
465
  opts,
406
- output(args.cluster).info,
466
+ output4(args.cluster),
407
467
  deployment.metadata,
408
468
  deployment.spec,
409
469
  deployment.status,
@@ -412,9 +472,17 @@ class CreatedDeployment extends Deployment {
412
472
  [deployment]
413
473
  );
414
474
  }
415
- }
475
+ };
416
476
 
417
- class StatefulSet extends ComponentResource {
477
+ // src/stateful-set.ts
478
+ import {
479
+ output as output5,
480
+ ComponentResource as ComponentResource4
481
+ } from "@highstate/pulumi";
482
+ import { apps as apps2 } from "@pulumi/kubernetes";
483
+ import { omit as omit4 } from "remeda";
484
+ import { deepmerge as deepmerge3 } from "deepmerge-ts";
485
+ var StatefulSet = class extends ComponentResource4 {
418
486
  constructor(type, name, args, opts, clusterInfo, metadata, spec, status, _service, _httpRoute) {
419
487
  super(type, name, args, opts);
420
488
  this.clusterInfo = clusterInfo;
@@ -428,13 +496,16 @@ class StatefulSet extends ComponentResource {
428
496
  * The Highstate stateful set entity.
429
497
  */
430
498
  get entity() {
431
- return output({
499
+ return output5({
432
500
  type: "k8s.stateful-set",
433
501
  clusterInfo: this.clusterInfo,
434
502
  metadata: this.metadata,
435
503
  service: this.service.entity
436
504
  });
437
505
  }
506
+ get optionalService() {
507
+ return this._service;
508
+ }
438
509
  /**
439
510
  * The service associated with the stateful set.
440
511
  */
@@ -460,8 +531,8 @@ class StatefulSet extends ComponentResource {
460
531
  static create(name, args, opts) {
461
532
  return new CreatedStatefulSet(name, args, opts);
462
533
  }
463
- }
464
- class CreatedStatefulSet extends StatefulSet {
534
+ };
535
+ var CreatedStatefulSet = class extends StatefulSet {
465
536
  constructor(name, args, opts) {
466
537
  const { containers, volumes, labels, service, httpRoute } = getPublicWorkloadComponents(
467
538
  name,
@@ -469,14 +540,14 @@ class CreatedStatefulSet extends StatefulSet {
469
540
  () => this,
470
541
  opts
471
542
  );
472
- const statefulSet = output({ args, containers, volumes, service }).apply(
543
+ const statefulSet = output5({ args, containers, volumes, service }).apply(
473
544
  async ({ args: args2, containers: containers2, volumes: volumes2, service: service2 }) => {
474
545
  await verifyProvider(opts.provider, args2.cluster?.info);
475
- return new (args2.patch ? apps.v1.StatefulSetPatch : apps.v1.StatefulSet)(
546
+ return new (args2.patch ? apps2.v1.StatefulSetPatch : apps2.v1.StatefulSet)(
476
547
  name,
477
548
  {
478
549
  metadata: mapMetadata(args2.patch?.metadata ?? args2, name),
479
- spec: deepmerge(
550
+ spec: deepmerge3(
480
551
  {
481
552
  serviceName: service2?.metadata.name || name,
482
553
  template: {
@@ -488,7 +559,7 @@ class CreatedStatefulSet extends StatefulSet {
488
559
  },
489
560
  selector: !args2.patch ? { matchLabels: labels } : void 0
490
561
  },
491
- omit(args2, publicWorkloadExtraArgs)
562
+ omit4(args2, publicWorkloadExtraArgs)
492
563
  )
493
564
  },
494
565
  { parent: this, ...opts }
@@ -500,7 +571,7 @@ class CreatedStatefulSet extends StatefulSet {
500
571
  name,
501
572
  args,
502
573
  opts,
503
- output(args.cluster).info,
574
+ output5(args.cluster).info,
504
575
  statefulSet.metadata,
505
576
  statefulSet.spec,
506
577
  statefulSet.status,
@@ -508,21 +579,31 @@ class CreatedStatefulSet extends StatefulSet {
508
579
  httpRoute
509
580
  );
510
581
  }
511
- }
582
+ };
512
583
 
513
- class NetworkPolicy extends ComponentResource {
584
+ // src/network-policy.ts
585
+ import { networking } from "@pulumi/kubernetes";
586
+ import {
587
+ ComponentResource as ComponentResource5,
588
+ normalize as normalize3,
589
+ output as output6
590
+ } from "@highstate/pulumi";
591
+ import { capitalize, flat, merge, mergeDeep } from "remeda";
592
+ import { parseDomain, ParseResultType } from "parse-domain";
593
+ import "@highstate/library";
594
+ var NetworkPolicy = class _NetworkPolicy extends ComponentResource5 {
514
595
  /**
515
596
  * The underlying network policy resource.
516
597
  */
517
598
  networkPolicy;
518
599
  constructor(name, args, opts) {
519
600
  super("k8s:network-policy", name, args, opts);
520
- const normalizedArgs = output(args).apply((args2) => {
521
- const ingressRules = normalize(args2.ingressRule, args2.ingressRules);
522
- const egressRules = normalize(args2.egressRule, args2.egressRules);
523
- const endpoints = normalize(args2.egressRule?.toEndpoint, args2.egressRule?.toEndpoints);
601
+ const normalizedArgs = output6(args).apply((args2) => {
602
+ const ingressRules = normalize3(args2.ingressRule, args2.ingressRules);
603
+ const egressRules = normalize3(args2.egressRule, args2.egressRules);
604
+ const endpoints = normalize3(args2.egressRule?.toEndpoint, args2.egressRule?.toEndpoints);
524
605
  const parsedEndpoints = endpoints.map((endpoint) => parseDomain(endpoint));
525
- const cidrsFromEndpoints = parsedEndpoints.filter((result) => result.type === ParseResultType.Ip).map((result) => NetworkPolicy.mapCidrFromEndpoint(result));
606
+ const cidrsFromEndpoints = parsedEndpoints.filter((result) => result.type === ParseResultType.Ip).map((result) => _NetworkPolicy.mapCidrFromEndpoint(result));
526
607
  const fqdnsFromEndpoints = parsedEndpoints.filter((result) => result.type !== ParseResultType.Invalid).map((result) => result.hostname);
527
608
  const extraEgressRules = [];
528
609
  if (args2.allowKubeDns) {
@@ -544,28 +625,28 @@ class NetworkPolicy extends ComponentResource {
544
625
  allowKubeApiServer: args2.allowKubeApiServer ?? false,
545
626
  ingressRules: ingressRules.map((rule) => ({
546
627
  all: rule.fromAll ?? false,
547
- cidrs: normalize(rule.fromCidr, rule.fromCidrs),
628
+ cidrs: normalize3(rule.fromCidr, rule.fromCidrs),
548
629
  fqdns: [],
549
- services: normalize(rule.fromService, rule.fromServices),
550
- namespaces: normalize(rule.fromNamespace, rule.fromNamespaces),
551
- selectors: normalize(rule.fromSelector, rule.fromSelectors),
552
- ports: normalize(rule.toPort, rule.toPorts)
630
+ services: normalize3(rule.fromService, rule.fromServices),
631
+ namespaces: normalize3(rule.fromNamespace, rule.fromNamespaces),
632
+ selectors: normalize3(rule.fromSelector, rule.fromSelectors),
633
+ ports: normalize3(rule.toPort, rule.toPorts)
553
634
  })),
554
635
  egressRules: egressRules.map((rule) => {
555
636
  return {
556
637
  all: rule.toAll ?? false,
557
- cidrs: normalize(rule.toCidr, rule.toCidrs).concat(cidrsFromEndpoints),
558
- fqdns: normalize(rule.toFqdn, rule.toFqdns).concat(fqdnsFromEndpoints),
559
- services: normalize(rule.toService, rule.toServices),
560
- namespaces: normalize(rule.toNamespace, rule.toNamespaces),
561
- selectors: normalize(rule.toSelector, rule.toSelectors),
562
- ports: normalize(rule.toPort, rule.toPorts)
638
+ cidrs: normalize3(rule.toCidr, rule.toCidrs).concat(cidrsFromEndpoints),
639
+ fqdns: normalize3(rule.toFqdn, rule.toFqdns).concat(fqdnsFromEndpoints),
640
+ services: normalize3(rule.toService, rule.toServices),
641
+ namespaces: normalize3(rule.toNamespace, rule.toNamespaces),
642
+ selectors: normalize3(rule.toSelector, rule.toSelectors),
643
+ ports: normalize3(rule.toPort, rule.toPorts)
563
644
  };
564
645
  }).concat(extraEgressRules)
565
646
  };
566
647
  });
567
648
  this.networkPolicy = normalizedArgs.apply((args2) => {
568
- return output(
649
+ return output6(
569
650
  this.create(name, args2, { ...opts, parent: this })
570
651
  );
571
652
  });
@@ -579,8 +660,8 @@ class NetworkPolicy extends ComponentResource {
579
660
  }
580
661
  static supportedCNIs = ["cilium"];
581
662
  static create(name, args, opts) {
582
- return output(args).apply(async (args2) => {
583
- if (!args2.cni || !NetworkPolicy.supportedCNIs.includes(args2.cni)) {
663
+ return output6(args).apply(async (args2) => {
664
+ if (!args2.cni || !_NetworkPolicy.supportedCNIs.includes(args2.cni)) {
584
665
  return new NativeNetworkPolicy(name, args2, opts);
585
666
  }
586
667
  const implName = `${capitalize(args2.cni)}NetworkPolicy`;
@@ -593,11 +674,11 @@ class NetworkPolicy extends ComponentResource {
593
674
  });
594
675
  }
595
676
  static allowInsideNamespace(namespace, k8sCluster, opts) {
596
- return NetworkPolicy.create(
677
+ return _NetworkPolicy.create(
597
678
  "allow-inside-namespace",
598
679
  {
599
680
  namespace,
600
- cni: output(k8sCluster).info.cni,
681
+ cni: output6(k8sCluster).info.cni,
601
682
  description: "Allow all traffic inside the namespace.",
602
683
  selector: {},
603
684
  ingressRule: { fromNamespace: namespace },
@@ -607,11 +688,11 @@ class NetworkPolicy extends ComponentResource {
607
688
  );
608
689
  }
609
690
  static allowKubeApiServer(namespace, k8sCluster, opts) {
610
- return NetworkPolicy.create(
691
+ return _NetworkPolicy.create(
611
692
  "allow-kube-api-server",
612
693
  {
613
694
  namespace,
614
- cni: output(k8sCluster).info.cni,
695
+ cni: output6(k8sCluster).info.cni,
615
696
  description: "Allow all traffic to the Kubernetes API server from the namespace.",
616
697
  allowKubeApiServer: true
617
698
  },
@@ -619,11 +700,11 @@ class NetworkPolicy extends ComponentResource {
619
700
  );
620
701
  }
621
702
  static allowKubeDns(namespace, k8sCluster, opts) {
622
- return NetworkPolicy.create(
703
+ return _NetworkPolicy.create(
623
704
  "allow-kube-dns",
624
705
  {
625
706
  namespace,
626
- cni: output(k8sCluster).info.cni,
707
+ cni: output6(k8sCluster).info.cni,
627
708
  description: "Allow all traffic to the Kubernetes DNS server from the namespace.",
628
709
  allowKubeDns: true
629
710
  },
@@ -631,22 +712,22 @@ class NetworkPolicy extends ComponentResource {
631
712
  );
632
713
  }
633
714
  static allowAllEgress(namespace, k8sCluster, opts) {
634
- return NetworkPolicy.create(
715
+ return _NetworkPolicy.create(
635
716
  "allow-all-egress",
636
717
  {
637
718
  namespace,
638
- cni: output(k8sCluster).info.cni,
719
+ cni: output6(k8sCluster).info.cni,
639
720
  description: "Allow all egress traffic from the namespace.",
640
721
  egressRule: { toAll: true }
641
722
  },
642
723
  opts
643
724
  );
644
725
  }
645
- }
646
- class NativeNetworkPolicy extends NetworkPolicy {
726
+ };
727
+ var NativeNetworkPolicy = class _NativeNetworkPolicy extends NetworkPolicy {
647
728
  create(name, args, opts) {
648
- const ingress = NativeNetworkPolicy.createIngressRules(args);
649
- const egress = NativeNetworkPolicy.createEgressRules(args);
729
+ const ingress = _NativeNetworkPolicy.createIngressRules(args);
730
+ const egress = _NativeNetworkPolicy.createEgressRules(args);
650
731
  const policyTypes = [];
651
732
  if (ingress.length > 0 || args.isolateIngress) {
652
733
  policyTypes.push("Ingress");
@@ -676,14 +757,14 @@ class NativeNetworkPolicy extends NetworkPolicy {
676
757
  };
677
758
  static createIngressRules(args) {
678
759
  return args.ingressRules.map((rule) => ({
679
- from: rule.all ? void 0 : NativeNetworkPolicy.createRulePeers(rule),
680
- ports: NativeNetworkPolicy.mapPorts(rule.ports)
760
+ from: rule.all ? void 0 : _NativeNetworkPolicy.createRulePeers(rule),
761
+ ports: _NativeNetworkPolicy.mapPorts(rule.ports)
681
762
  }));
682
763
  }
683
764
  static createEgressRules(args) {
684
765
  const needFallback = args.egressRules.some((rule) => rule.fqdns.length > 0);
685
766
  if (needFallback) {
686
- return [{ to: [{ ipBlock: NativeNetworkPolicy.fallbackIpBlock }] }];
767
+ return [{ to: [{ ipBlock: _NativeNetworkPolicy.fallbackIpBlock }] }];
687
768
  }
688
769
  const extraRules = [];
689
770
  if (args.allowKubeApiServer) {
@@ -691,16 +772,16 @@ class NativeNetworkPolicy extends NetworkPolicy {
691
772
  }
692
773
  return args.egressRules.map((rule) => {
693
774
  return {
694
- to: rule.all ? void 0 : NativeNetworkPolicy.createRulePeers(rule),
695
- ports: NativeNetworkPolicy.mapPorts(rule.ports)
775
+ to: rule.all ? void 0 : _NativeNetworkPolicy.createRulePeers(rule),
776
+ ports: _NativeNetworkPolicy.mapPorts(rule.ports)
696
777
  };
697
778
  }).concat(extraRules);
698
779
  }
699
780
  static createRulePeers(args) {
700
781
  return [
701
- ...NativeNetworkPolicy.createCidrPeers(args),
702
- ...NativeNetworkPolicy.createServicePeers(args),
703
- ...NativeNetworkPolicy.createSelectorPeers(args)
782
+ ..._NativeNetworkPolicy.createCidrPeers(args),
783
+ ..._NativeNetworkPolicy.createServicePeers(args),
784
+ ..._NativeNetworkPolicy.createSelectorPeers(args)
704
785
  ];
705
786
  }
706
787
  static createCidrPeers(args) {
@@ -719,7 +800,7 @@ class NativeNetworkPolicy extends NetworkPolicy {
719
800
  const selectorPeers = args.selectors.map((selector) => ({
720
801
  podSelector: mapSelectorLikeToSelector(selector)
721
802
  }));
722
- const namespacePeers = args.namespaces.map(NativeNetworkPolicy.createNamespacePeer);
803
+ const namespacePeers = args.namespaces.map(_NativeNetworkPolicy.createNamespacePeer);
723
804
  if (namespacePeers.length === 0) {
724
805
  return selectorPeers;
725
806
  }
@@ -752,10 +833,18 @@ class NativeNetworkPolicy extends NetworkPolicy {
752
833
  };
753
834
  });
754
835
  }
755
- }
836
+ };
756
837
 
838
+ // src/access-point.ts
839
+ import { DnsRecord } from "@highstate/common";
840
+ import { gateway } from "@highstate/gateway-api";
841
+ import {
842
+ normalize as normalize4,
843
+ output as output7,
844
+ toPromise
845
+ } from "@highstate/pulumi";
757
846
  function useAccessPoint(args) {
758
- const result = output({ args, namespaceName: output(args.namespace).metadata.name }).apply(
847
+ const result = output7({ args, namespaceName: output7(args.namespace).metadata.name }).apply(
759
848
  ({ args: args2, namespaceName }) => {
760
849
  const gateway2 = createGateway({
761
850
  ...args2,
@@ -764,7 +853,7 @@ function useAccessPoint(args) {
764
853
  },
765
854
  gateway: args2.accessPoint.gateway
766
855
  });
767
- const dnsRecords = normalize(args2.fqdn, args2.fqdns).map((fqdn) => {
856
+ const dnsRecords = normalize4(args2.fqdn, args2.fqdns).map((fqdn) => {
768
857
  return DnsRecord.create(fqdn, {
769
858
  provider: args2.accessPoint.dnsProvider,
770
859
  type: "A",
@@ -803,7 +892,7 @@ function useAccessPoint(args) {
803
892
  )
804
893
  );
805
894
  }
806
- return output({
895
+ return output7({
807
896
  gateway: gateway2,
808
897
  dnsRecords,
809
898
  networkPolicies
@@ -823,7 +912,7 @@ function useStandardAcessPoint(appName, namespace, args, inputs, provider) {
823
912
  });
824
913
  }
825
914
  function createGateway(args) {
826
- return output(args).apply((args2) => {
915
+ return output7(args).apply((args2) => {
827
916
  if (args2.clusterInfo.id !== args2.gateway.clusterInfo.id) {
828
917
  throw new Error(
829
918
  "The provided Kubernetes cluster is different from the one where the gateway controller is deployed."
@@ -838,12 +927,12 @@ function createGateway(args) {
838
927
  annotations: args2.annotations
839
928
  },
840
929
  spec: {
841
- gatewayClassName: output(args2.gateway).gatewayClassName,
842
- listeners: normalize(args2.fqdn, args2.fqdns).map((fqdn) => {
930
+ gatewayClassName: output7(args2.gateway).gatewayClassName,
931
+ listeners: normalize4(args2.fqdn, args2.fqdns).map((fqdn) => {
843
932
  const normalizedName = fqdn.replace(/\*/g, "wildcard");
844
933
  return {
845
934
  name: `https-${normalizedName}`,
846
- port: output(args2.gateway).httpsListenerPort,
935
+ port: output7(args2.gateway).httpsListenerPort,
847
936
  protocol: "HTTPS",
848
937
  hostname: fqdn,
849
938
  tls: {
@@ -859,12 +948,24 @@ function createGateway(args) {
859
948
  });
860
949
  }
861
950
 
862
- const emptyDistributionEnvironment = {
951
+ // src/scripting/bundle.ts
952
+ import { core as core3 } from "@pulumi/kubernetes";
953
+ import { apply, normalize as normalize5 } from "@highstate/pulumi";
954
+ import {
955
+ ComponentResource as ComponentResource6,
956
+ output as output8
957
+ } from "@pulumi/pulumi";
958
+ import { pipe } from "remeda";
959
+ import { deepmerge as deepmerge4 } from "deepmerge-ts";
960
+ import { text, trimIndentation as trimIndentation2 } from "@highstate/contract";
961
+
962
+ // src/scripting/environment.ts
963
+ var emptyDistributionEnvironment = {
863
964
  preInstallPackages: [],
864
965
  preInstallScripts: {},
865
966
  packages: []
866
967
  };
867
- const emptyScriptEnvironment = {
968
+ var emptyScriptEnvironment = {
868
969
  alpine: emptyDistributionEnvironment,
869
970
  ubuntu: emptyDistributionEnvironment,
870
971
  setupScripts: {},
@@ -875,7 +976,8 @@ const emptyScriptEnvironment = {
875
976
  environment: {}
876
977
  };
877
978
 
878
- class ScriptBundle extends ComponentResource$1 {
979
+ // src/scripting/bundle.ts
980
+ var ScriptBundle = class extends ComponentResource6 {
879
981
  /**
880
982
  * The config map containing the scripts.
881
983
  */
@@ -899,14 +1001,14 @@ class ScriptBundle extends ComponentResource$1 {
899
1001
  constructor(name, args, opts) {
900
1002
  super("highstate:k8s:ScriptBundle", name, args, opts);
901
1003
  const scriptEnvironment = pipe(
902
- output$1(args),
903
- apply((args2) => normalize(args2.environment, args2.environments)),
904
- apply((args2) => deepmerge(emptyScriptEnvironment, ...args2))
1004
+ output8(args),
1005
+ apply((args2) => normalize5(args2.environment, args2.environments)),
1006
+ apply((args2) => deepmerge4(emptyScriptEnvironment, ...args2))
905
1007
  );
906
1008
  this.distribution = args.distribution;
907
1009
  this.environment = scriptEnvironment.environment;
908
- this.configMap = output$1({ scriptEnvironment, args }).apply(({ scriptEnvironment: scriptEnvironment2, args: args2 }) => {
909
- return new core.v1.ConfigMap(
1010
+ this.configMap = output8({ scriptEnvironment, args }).apply(({ scriptEnvironment: scriptEnvironment2, args: args2 }) => {
1011
+ return new core3.v1.ConfigMap(
910
1012
  name,
911
1013
  {
912
1014
  metadata: mapMetadata(args2, name),
@@ -944,7 +1046,7 @@ class ScriptBundle extends ComponentResource$1 {
944
1046
  environment: this.environment
945
1047
  });
946
1048
  }
947
- }
1049
+ };
948
1050
  function createScriptData(distribution, environment) {
949
1051
  const scriptData = {};
950
1052
  const actions = [];
@@ -1013,7 +1115,7 @@ function createScriptData(distribution, environment) {
1013
1115
  for (const key in environment.scripts) {
1014
1116
  scriptData[key] = environment.scripts[key];
1015
1117
  }
1016
- scriptData["entrypoint.sh"] = trimIndentation(`
1118
+ scriptData["entrypoint.sh"] = trimIndentation2(`
1017
1119
  #!/bin/sh
1018
1120
  set -e
1019
1121
 
@@ -1049,45 +1151,56 @@ function getInstallPackagesScript(distribution, packages) {
1049
1151
  }
1050
1152
  }
1051
1153
 
1154
+ // src/scripting/container.ts
1155
+ import { output as output9 } from "@pulumi/pulumi";
1156
+ import { merge as merge2 } from "remeda";
1052
1157
  function createScriptContainer(options) {
1053
- return output$1(options).apply((options2) => {
1158
+ return output9(options).apply((options2) => {
1054
1159
  const image = options2.bundle.distribution === "alpine" ? "alpine@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c" : "ubuntu@sha256:72297848456d5d37d1262630108ab308d3e9ec7ed1c3286a32fe09856619a782";
1055
1160
  return {
1056
1161
  image,
1057
1162
  command: ["/scripts/entrypoint.sh", `/scripts/${options2.main}`],
1058
1163
  ...options2,
1059
- volumeMounts: merge(options2.bundle.volumeMounts, options2.volumeMounts),
1060
- volumes: merge(options2.bundle.volumes, options2.volumes),
1061
- environment: merge(options2.bundle.environment, options2.environment)
1164
+ volumeMounts: merge2(options2.bundle.volumeMounts, options2.volumeMounts),
1165
+ volumes: merge2(options2.bundle.volumes, options2.volumes),
1166
+ environment: merge2(options2.bundle.environment, options2.environment)
1062
1167
  };
1063
1168
  });
1064
1169
  }
1065
1170
 
1066
- const jobExtraArgs = [...commonExtraArgs, "container", "containers"];
1067
- class Job extends ComponentResource {
1171
+ // src/job.ts
1172
+ import { batch } from "@pulumi/kubernetes";
1173
+ import {
1174
+ ComponentResource as ComponentResource7,
1175
+ normalize as normalize6,
1176
+ output as output10
1177
+ } from "@highstate/pulumi";
1178
+ import { mergeDeep as mergeDeep2, omit as omit5 } from "remeda";
1179
+ var jobExtraArgs = [...commonExtraArgs, "container", "containers"];
1180
+ var Job = class extends ComponentResource7 {
1068
1181
  /**
1069
1182
  * The underlying Kubernetes job.
1070
1183
  */
1071
1184
  job;
1072
1185
  constructor(name, args, opts) {
1073
1186
  super("highstate:k8s:Job", name, args, opts);
1074
- this.job = output(args).apply((args2) => {
1075
- const containers = normalize(args2.container, args2.containers);
1187
+ this.job = output10(args).apply((args2) => {
1188
+ const containers = normalize6(args2.container, args2.containers);
1076
1189
  return new batch.v1.Job(
1077
1190
  name,
1078
1191
  {
1079
1192
  metadata: mapMetadata(args2, name),
1080
- spec: mergeDeep(
1193
+ spec: mergeDeep2(
1081
1194
  {
1082
1195
  template: {
1083
1196
  spec: {
1084
1197
  containers: containers.map((container) => mapContainerToRaw(container, name)),
1085
- volumes: containers.flatMap((container) => normalize(container.volume, container.volumes)).map(mapWorkloadVolume),
1198
+ volumes: containers.flatMap((container) => normalize6(container.volume, container.volumes)).map(mapWorkloadVolume),
1086
1199
  restartPolicy: "Never"
1087
1200
  }
1088
1201
  }
1089
1202
  },
1090
- omit(args2, jobExtraArgs)
1203
+ omit5(args2, jobExtraArgs)
1091
1204
  )
1092
1205
  },
1093
1206
  { parent: this, ...opts }
@@ -1095,37 +1208,45 @@ class Job extends ComponentResource {
1095
1208
  });
1096
1209
  this.registerOutputs({ job: this.job });
1097
1210
  }
1098
- }
1211
+ };
1099
1212
 
1100
- const cronJobExtraArgs = [...commonExtraArgs, "container", "containers"];
1101
- class CronJob extends ComponentResource {
1213
+ // src/cron-job.ts
1214
+ import { batch as batch2 } from "@pulumi/kubernetes";
1215
+ import {
1216
+ ComponentResource as ComponentResource8,
1217
+ normalize as normalize7,
1218
+ output as output11
1219
+ } from "@highstate/pulumi";
1220
+ import { mergeDeep as mergeDeep3, omit as omit6 } from "remeda";
1221
+ var cronJobExtraArgs = [...commonExtraArgs, "container", "containers"];
1222
+ var CronJob = class extends ComponentResource8 {
1102
1223
  /**
1103
1224
  * The underlying Kubernetes job.
1104
1225
  */
1105
1226
  cronJob;
1106
1227
  constructor(name, args, opts) {
1107
1228
  super("highstate:k8s:CronJob", name, args, opts);
1108
- this.cronJob = output(args).apply((args2) => {
1109
- const containers = normalize(args2.container, args2.containers);
1110
- return new batch.v1.CronJob(
1229
+ this.cronJob = output11(args).apply((args2) => {
1230
+ const containers = normalize7(args2.container, args2.containers);
1231
+ return new batch2.v1.CronJob(
1111
1232
  name,
1112
1233
  {
1113
1234
  metadata: mapMetadata(args2, name),
1114
- spec: mergeDeep(
1235
+ spec: mergeDeep3(
1115
1236
  {
1116
1237
  jobTemplate: {
1117
1238
  spec: {
1118
1239
  template: {
1119
1240
  spec: {
1120
1241
  containers: containers.map((container) => mapContainerToRaw(container, name)),
1121
- volumes: containers.flatMap((container) => normalize(container.volume, container.volumes)).map(mapWorkloadVolume)
1242
+ volumes: containers.flatMap((container) => normalize7(container.volume, container.volumes)).map(mapWorkloadVolume)
1122
1243
  }
1123
1244
  }
1124
1245
  }
1125
1246
  },
1126
1247
  schedule: args2.schedule
1127
1248
  },
1128
- omit(args2, cronJobExtraArgs)
1249
+ omit6(args2, cronJobExtraArgs)
1129
1250
  )
1130
1251
  },
1131
1252
  { parent: this, ...opts }
@@ -1133,6 +1254,35 @@ class CronJob extends ComponentResource {
1133
1254
  });
1134
1255
  this.registerOutputs({ cronJob: this.cronJob });
1135
1256
  }
1136
- }
1137
-
1138
- export { CronJob, Deployment, HttpRoute, Job, NetworkPolicy, PersistentVolumeClaim, ScriptBundle, Service, StatefulSet, createScriptContainer, getAppDisplayName, getAppName, mapContainerPortToServicePort, mapMetadata, mapNamespaceLikeToNamespaceName, mapNamespaceNameToSelector, mapSelectorLikeToSelector, mapServiceToLabelSelector, useAccessPoint, useStandardAcessPoint };
1257
+ };
1258
+ export {
1259
+ Chart,
1260
+ CronJob,
1261
+ Deployment,
1262
+ HttpRoute,
1263
+ Job,
1264
+ NetworkPolicy,
1265
+ PersistentVolumeClaim,
1266
+ RenderedChart,
1267
+ ScriptBundle,
1268
+ Service,
1269
+ StatefulSet,
1270
+ createNamespace,
1271
+ getProvider as createProvider,
1272
+ createScriptContainer,
1273
+ getAppDisplayName,
1274
+ getAppName,
1275
+ getChartService,
1276
+ getChartServiceOutput,
1277
+ getNamespace,
1278
+ mapContainerPortToServicePort,
1279
+ mapMetadata,
1280
+ mapNamespaceLikeToNamespaceName,
1281
+ mapNamespaceNameToSelector,
1282
+ mapSelectorLikeToSelector,
1283
+ mapServiceToLabelSelector,
1284
+ resolveHelmChart,
1285
+ useAccessPoint,
1286
+ useStandardAcessPoint
1287
+ };
1288
+ //# sourceMappingURL=index.js.map