@highstate/k8s 0.19.1 → 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 (107) 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-LGHFSXNT.js → chunk-9hs97f1q.js} +23 -17
  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 -2
  19. package/dist/impl/dynamic-endpoint-resolver.js +91 -0
  20. package/dist/impl/gateway-route.js +226 -166
  21. package/dist/impl/tls-certificate.js +31 -31
  22. package/dist/index.js +293 -166
  23. package/dist/units/cert-manager/index.js +19 -14
  24. package/dist/units/cluster-patch/index.js +14 -13
  25. package/dist/units/dns01-issuer/index.js +82 -42
  26. package/dist/units/existing-cluster/index.js +59 -26
  27. package/dist/units/gateway-api/index.js +15 -16
  28. package/dist/units/reduced-access-cluster/index.js +32 -36
  29. package/package.json +23 -21
  30. package/src/cluster.ts +12 -8
  31. package/src/config-map.ts +15 -5
  32. package/src/container.ts +4 -2
  33. package/src/cron-job.ts +51 -5
  34. package/src/deployment.ts +49 -18
  35. package/src/gateway/backend.ts +3 -3
  36. package/src/gateway/gateway.ts +12 -56
  37. package/src/helm.ts +354 -22
  38. package/src/impl/dynamic-endpoint-resolver.ts +109 -0
  39. package/src/impl/gateway-route.ts +231 -57
  40. package/src/impl/tls-certificate.ts +8 -3
  41. package/src/index.ts +1 -0
  42. package/src/job.ts +38 -6
  43. package/src/kubectl.ts +166 -0
  44. package/src/namespace.ts +47 -3
  45. package/src/network-policy.ts +1 -1
  46. package/src/pvc.ts +12 -2
  47. package/src/rbac.ts +28 -5
  48. package/src/scripting/bundle.ts +21 -98
  49. package/src/scripting/environment.ts +4 -10
  50. package/src/secret.ts +15 -5
  51. package/src/service.ts +28 -6
  52. package/src/shared.ts +31 -3
  53. package/src/stateful-set.ts +49 -18
  54. package/src/tls.ts +31 -5
  55. package/src/units/cluster-patch/index.ts +5 -5
  56. package/src/units/dns01-issuer/index.ts +56 -12
  57. package/src/units/existing-cluster/index.ts +36 -15
  58. package/src/units/reduced-access-cluster/index.ts +6 -3
  59. package/src/worker.ts +4 -2
  60. package/src/workload.ts +474 -217
  61. package/LICENSE +0 -21
  62. package/dist/chunk-4G6LLC2X.js +0 -240
  63. package/dist/chunk-4G6LLC2X.js.map +0 -1
  64. package/dist/chunk-BR2CLUUD.js +0 -230
  65. package/dist/chunk-BR2CLUUD.js.map +0 -1
  66. package/dist/chunk-DCUMJSO6.js +0 -427
  67. package/dist/chunk-DCUMJSO6.js.map +0 -1
  68. package/dist/chunk-FE4SHRAJ.js +0 -286
  69. package/dist/chunk-FE4SHRAJ.js.map +0 -1
  70. package/dist/chunk-HH2JJELM.js +0 -13
  71. package/dist/chunk-HH2JJELM.js.map +0 -1
  72. package/dist/chunk-KMLRI5UZ.js +0 -155
  73. package/dist/chunk-KMLRI5UZ.js.map +0 -1
  74. package/dist/chunk-LGHFSXNT.js.map +0 -1
  75. package/dist/chunk-MIC2BHGS.js +0 -301
  76. package/dist/chunk-MIC2BHGS.js.map +0 -1
  77. package/dist/chunk-OBDQONMV.js +0 -401
  78. package/dist/chunk-OBDQONMV.js.map +0 -1
  79. package/dist/chunk-P2VOUU7E.js +0 -1626
  80. package/dist/chunk-P2VOUU7E.js.map +0 -1
  81. package/dist/chunk-PZ5AY32C.js +0 -9
  82. package/dist/chunk-PZ5AY32C.js.map +0 -1
  83. package/dist/chunk-RVB4WWZZ.js +0 -267
  84. package/dist/chunk-RVB4WWZZ.js.map +0 -1
  85. package/dist/chunk-TWBMG6TD.js +0 -315
  86. package/dist/chunk-TWBMG6TD.js.map +0 -1
  87. package/dist/chunk-VCXWCZ43.js +0 -279
  88. package/dist/chunk-VCXWCZ43.js.map +0 -1
  89. package/dist/chunk-YIJUVPU2.js +0 -297
  90. package/dist/chunk-YIJUVPU2.js.map +0 -1
  91. package/dist/cron-job-NX4HD4FI.js +0 -8
  92. package/dist/cron-job-NX4HD4FI.js.map +0 -1
  93. package/dist/deployment-O2LJ5WR5.js +0 -8
  94. package/dist/deployment-O2LJ5WR5.js.map +0 -1
  95. package/dist/impl/gateway-route.js.map +0 -1
  96. package/dist/impl/tls-certificate.js.map +0 -1
  97. package/dist/index.js.map +0 -1
  98. package/dist/job-SYME6Y43.js +0 -8
  99. package/dist/job-SYME6Y43.js.map +0 -1
  100. package/dist/stateful-set-VJYKTQ72.js +0 -8
  101. package/dist/stateful-set-VJYKTQ72.js.map +0 -1
  102. package/dist/units/cert-manager/index.js.map +0 -1
  103. package/dist/units/cluster-patch/index.js.map +0 -1
  104. package/dist/units/dns01-issuer/index.js.map +0 -1
  105. package/dist/units/existing-cluster/index.js.map +0 -1
  106. package/dist/units/gateway-api/index.js.map +0 -1
  107. package/dist/units/reduced-access-cluster/index.js.map +0 -1
@@ -1,427 +0,0 @@
1
- import { Service } from './chunk-TWBMG6TD.js';
2
- import { commonExtraArgs, NamespacedResource, Namespace, mapMetadata, getProvider } from './chunk-OBDQONMV.js';
3
- import { output, toPromise, interpolate, ComponentResource, normalizeInputsAndMap, normalizeInputs, normalize } from '@highstate/pulumi';
4
- import { parseEndpoint } from '@highstate/common';
5
- import { getOrCreate } from '@highstate/contract';
6
- import { gateway } from '@highstate/gateway-api';
7
- import { omit, pipe, map } from 'remeda';
8
-
9
- function resolveBackendRef(ref) {
10
- if (Service.isInstance(ref)) {
11
- return output({
12
- name: ref.metadata.name,
13
- namespace: ref.metadata.namespace,
14
- port: ref.spec.ports[0].port
15
- });
16
- }
17
- if ("service" in ref) {
18
- const service = output(ref.service);
19
- return output({
20
- name: service.metadata.name,
21
- namespace: service.metadata.namespace,
22
- port: ref.port
23
- });
24
- }
25
- return output({
26
- name: ref.name,
27
- namespace: ref.namespace,
28
- port: ref.port
29
- });
30
- }
31
- var gatewayExtraArgs = [...commonExtraArgs, "fqdn", "fqdns"];
32
- var Gateway = class _Gateway extends NamespacedResource {
33
- constructor(type, name, args, opts, metadata, namespace, spec, status) {
34
- super(type, name, args, opts, metadata, namespace);
35
- this.spec = spec;
36
- this.status = status;
37
- }
38
- static apiVersion = "gateway.networking.k8s.io/v1";
39
- static kind = "Gateway";
40
- /**
41
- * The Highstate gateway entity.
42
- */
43
- get entity() {
44
- return output(this.entityBase);
45
- }
46
- /**
47
- * Returns the endpoints L3 endpoints on which the gateway is exposed.
48
- */
49
- get endpoints() {
50
- return this.status.addresses.apply((addresses) => {
51
- if (!addresses) {
52
- return [];
53
- }
54
- return addresses.map((address) => parseEndpoint(address.value));
55
- });
56
- }
57
- /**
58
- * Creates a new gateway.
59
- */
60
- static create(name, args, opts) {
61
- return new CreatedGateway(name, args, opts);
62
- }
63
- /**
64
- * Creates a new gateway or patches an existing one.
65
- *
66
- * @param name The name of the resource. May not be the same as the gateway name.
67
- * @param args The arguments to create or patch the gateway with.
68
- * @param opts Optional resource options.
69
- */
70
- static createOrPatch(name, args, opts) {
71
- if (args.existing) {
72
- return new GatewayPatch(name, {
73
- ...args,
74
- name: output(args.existing).metadata.name,
75
- namespace: Namespace.forResourceAsync(args.existing, output(args.namespace).cluster)
76
- });
77
- }
78
- return new CreatedGateway(name, args, opts);
79
- }
80
- /**
81
- * Creates a new gateway or gets an existing one.
82
- *
83
- * @param name The name of the resource. May not be the same as the gateway name. Will not be used when existing gateway is retrieved.
84
- * @param args The arguments to create or get the gateway with.
85
- * @param opts Optional resource options.
86
- */
87
- static async createOrGet(name, args, opts) {
88
- if (args.existing) {
89
- return await _Gateway.forAsync(args.existing, output(args.namespace).cluster);
90
- }
91
- return new CreatedGateway(name, args, opts);
92
- }
93
- /**
94
- * Patches an existing gateway.
95
- *
96
- * Will throw an error if the gateway does not exist.
97
- *
98
- * @param name The name of the resource. May not be the same as the gateway name.
99
- * @param args The arguments to patch the gateway with.
100
- * @param opts Optional resource options.
101
- */
102
- static patch(name, args, opts) {
103
- return new GatewayPatch(name, args, opts);
104
- }
105
- /**
106
- * Wraps an existing Kubernetes gateway.
107
- */
108
- static wrap(name, args, opts) {
109
- return new WrappedGateway(name, args, opts);
110
- }
111
- /**
112
- * Gets an existing gateway.
113
- *
114
- * Will throw an error if the gateway does not exist.
115
- */
116
- static get(name, args, opts) {
117
- return new ExternalGateway(name, args, opts);
118
- }
119
- static gatewayCache = /* @__PURE__ */ new Map();
120
- /**
121
- * Gets an existing gateway for a given entity.
122
- * Prefer this method over `get` when possible.
123
- *
124
- * It automatically names the resource with the following format: `{clusterName}.{namespace}.{gatewayName}.{clusterId}`.
125
- *
126
- * This method is idempotent and will return the same instance for the same entity.
127
- *
128
- * @param entity The entity to get the gateway for.
129
- * @param cluster The cluster where the gateway is located.
130
- */
131
- static for(entity, cluster) {
132
- return getOrCreate(
133
- _Gateway.gatewayCache,
134
- `${entity.clusterName}.${entity.metadata.namespace}.${entity.metadata.name}.${entity.clusterId}`,
135
- (name) => {
136
- return _Gateway.get(name, {
137
- name: entity.metadata.name,
138
- namespace: Namespace.forResourceAsync(entity, cluster)
139
- });
140
- }
141
- );
142
- }
143
- /**
144
- * Gets an existing gateway for a given entity.
145
- * Prefer this method over `get` when possible.
146
- *
147
- * It automatically names the resource with the following format: `{clusterName}.{namespace}.{gatewayName}.{clusterId}`.
148
- *
149
- * This method is idempotent and will return the same instance for the same entity.
150
- *
151
- * @param entity The entity to get the gateway for.
152
- * @param cluster The cluster where the gateway is located.
153
- */
154
- static async forAsync(entity, cluster) {
155
- const resolvedEntity = await toPromise(entity);
156
- return _Gateway.for(resolvedEntity, output(cluster));
157
- }
158
- /**
159
- * Creates a gateway with the provided name/namespace/cluster only once.
160
- *
161
- * It automatically names the resource with the following format: `{name}.{namespace}.{clusterName}.{clusterId}`.
162
- *
163
- * On subsequent calls the gateway is patched with the union of existing and requested listeners.
164
- * Only the listeners field is modified to avoid altering other spec fields.
165
- *
166
- * @param name The name of the gateway to create.
167
- * @param args The arguments to create the gateway with.
168
- * @param opts Optional resource options.
169
- */
170
- static async createOnce(args, opts) {
171
- const { name, namespace, cluster } = await toPromise({
172
- name: args.name,
173
- namespace: output(args.namespace).metadata.name,
174
- cluster: output(args.namespace).cluster
175
- });
176
- const fullName = `${name}.${namespace}.${cluster.name}.${cluster.id}`;
177
- const existing = _Gateway.gatewayCache.get(fullName);
178
- if (existing) {
179
- _Gateway.patch(
180
- fullName,
181
- {
182
- name,
183
- namespace: args.namespace,
184
- listeners: args.listeners
185
- },
186
- opts
187
- );
188
- return existing;
189
- }
190
- const created = _Gateway.create(
191
- fullName,
192
- {
193
- ...args,
194
- name,
195
- namespace: args.namespace
196
- },
197
- opts
198
- );
199
- _Gateway.gatewayCache.set(fullName, created);
200
- return created;
201
- }
202
- };
203
- var CreatedGateway = class extends Gateway {
204
- constructor(name, args, opts) {
205
- const gatewayResource = output(args.namespace).cluster.apply((cluster) => {
206
- return new gateway.v1.Gateway(
207
- name,
208
- {
209
- metadata: mapMetadata(args, name),
210
- spec: omit(args, gatewayExtraArgs)
211
- },
212
- { ...opts, parent: this, provider: getProvider(cluster) }
213
- );
214
- });
215
- super(
216
- "highstate:k8s:Gateway",
217
- name,
218
- args,
219
- opts,
220
- gatewayResource.metadata,
221
- output(args.namespace),
222
- gatewayResource.spec,
223
- gatewayResource.status
224
- );
225
- }
226
- };
227
- var GatewayPatch = class extends Gateway {
228
- constructor(name, args, opts) {
229
- const gatewayResource = output(args.namespace).cluster.apply((cluster) => {
230
- return new gateway.v1.GatewayPatch(
231
- name,
232
- {
233
- metadata: mapMetadata(args, name),
234
- spec: omit(args, gatewayExtraArgs)
235
- },
236
- { ...opts, parent: this, provider: getProvider(cluster) }
237
- );
238
- });
239
- super(
240
- "highstate:k8s:GatewayPatch",
241
- name,
242
- args,
243
- opts,
244
- gatewayResource.metadata,
245
- output(args.namespace),
246
- gatewayResource.spec,
247
- gatewayResource.status
248
- );
249
- }
250
- };
251
- var WrappedGateway = class extends Gateway {
252
- constructor(name, args, opts) {
253
- super(
254
- "highstate:k8s:WrappedGateway",
255
- name,
256
- args,
257
- opts,
258
- output(args.gateway).metadata,
259
- output(args.namespace),
260
- output(args.gateway).spec,
261
- output(args.gateway).status
262
- );
263
- }
264
- };
265
- var ExternalGateway = class extends Gateway {
266
- constructor(name, args, opts) {
267
- const gatewayResource = output(args.namespace).cluster.apply((cluster) => {
268
- return gateway.v1.Gateway.get(
269
- name,
270
- interpolate`${output(args.namespace).metadata.name}/${args.name}`,
271
- { ...opts, parent: this, provider: getProvider(cluster) }
272
- );
273
- });
274
- super(
275
- "highstate:k8s:ExternalGateway",
276
- name,
277
- args,
278
- opts,
279
- gatewayResource.metadata,
280
- output(args.namespace),
281
- gatewayResource.spec,
282
- gatewayResource.status
283
- );
284
- }
285
- };
286
- var HttpRoute = class extends ComponentResource {
287
- /**
288
- * The underlying Kubernetes resource.
289
- */
290
- route;
291
- constructor(name, args, opts) {
292
- super("highstate:k8s:HttpRoute", name, args, opts);
293
- this.route = output(args.gateway).cluster.apply((cluster) => {
294
- return new gateway.v1.HTTPRoute(
295
- name,
296
- {
297
- metadata: mapMetadata(args, name).apply((metadata) => ({
298
- ...metadata,
299
- namespace: output(args.gateway).namespace.metadata.name
300
- })),
301
- spec: {
302
- hostnames: normalizeInputs(args.hostname, args.hostnames),
303
- parentRefs: [
304
- {
305
- name: output(args.gateway).metadata.name
306
- }
307
- ],
308
- rules: normalizeInputsAndMap(args.rule, args.rules, (rule) => ({
309
- timeouts: rule.timeouts,
310
- matches: pipe(
311
- normalize(rule.match, rule.matches),
312
- map(mapHttpRouteRuleMatch),
313
- addDefaultPathMatch
314
- ),
315
- filters: normalize(rule.filter, rule.filters),
316
- backendRefs: normalizeInputsAndMap(rule.backend, rule.backends, resolveBackendRef)
317
- }))
318
- }
319
- },
320
- { ...opts, parent: this, provider: getProvider(cluster) }
321
- );
322
- });
323
- }
324
- };
325
- function addDefaultPathMatch(matches) {
326
- return matches.length ? matches : [{ path: { type: "PathPrefix", value: "/" } }];
327
- }
328
- function mapHttpRouteRuleMatch(match) {
329
- if (typeof match === "string") {
330
- return { path: { type: "PathPrefix", value: match } };
331
- }
332
- return match;
333
- }
334
- var TcpRoute = class extends ComponentResource {
335
- /**
336
- * The underlying Kubernetes resource.
337
- */
338
- route;
339
- constructor(name, args, opts) {
340
- super("highstate:k8s:TcpRoute", name, args, opts);
341
- const gatewayOutput = output(args.gateway);
342
- const parentRefs = output({
343
- gateway: gatewayOutput,
344
- listenerName: args.listenerName
345
- }).apply(
346
- ({ gateway: gateway5, listenerName }) => [
347
- {
348
- group: "gateway.networking.k8s.io",
349
- kind: "Gateway",
350
- name: gateway5.metadata.name,
351
- namespace: gateway5.namespace.metadata.name,
352
- sectionName: listenerName
353
- }
354
- ]
355
- );
356
- const backendRefs = normalizeInputsAndMap(args.backend, args.backends, resolveBackendRef);
357
- this.route = gatewayOutput.cluster.apply((cluster) => {
358
- return new gateway.v1alpha2.TCPRoute(
359
- name,
360
- {
361
- metadata: mapMetadata(args, name).apply((metadata) => ({
362
- ...metadata,
363
- namespace: gatewayOutput.namespace.metadata.name
364
- })),
365
- spec: {
366
- parentRefs,
367
- rules: [
368
- {
369
- backendRefs
370
- }
371
- ]
372
- }
373
- },
374
- { ...opts, parent: this, provider: getProvider(cluster) }
375
- );
376
- });
377
- }
378
- };
379
- var UdpRoute = class extends ComponentResource {
380
- /**
381
- * The underlying Kubernetes resource.
382
- */
383
- route;
384
- constructor(name, args, opts) {
385
- super("highstate:k8s:UdpRoute", name, args, opts);
386
- const gatewayOutput = output(args.gateway);
387
- const parentRefs = output({
388
- gateway: gatewayOutput,
389
- listenerName: args.listenerName
390
- }).apply(
391
- ({ gateway: gateway5, listenerName }) => [
392
- {
393
- group: "gateway.networking.k8s.io",
394
- kind: "Gateway",
395
- name: gateway5.metadata.name,
396
- namespace: gateway5.namespace.metadata.name,
397
- sectionName: listenerName
398
- }
399
- ]
400
- );
401
- const backendRefs = normalizeInputsAndMap(args.backend, args.backends, resolveBackendRef);
402
- this.route = gatewayOutput.cluster.apply((cluster) => {
403
- return new gateway.v1alpha2.UDPRoute(
404
- name,
405
- {
406
- metadata: mapMetadata(args, name).apply((metadata) => ({
407
- ...metadata,
408
- namespace: gatewayOutput.namespace.metadata.name
409
- })),
410
- spec: {
411
- parentRefs,
412
- rules: [
413
- {
414
- backendRefs
415
- }
416
- ]
417
- }
418
- },
419
- { ...opts, parent: this, provider: getProvider(cluster) }
420
- );
421
- });
422
- }
423
- };
424
-
425
- export { Gateway, HttpRoute, TcpRoute, UdpRoute, mapHttpRouteRuleMatch, resolveBackendRef };
426
- //# sourceMappingURL=chunk-DCUMJSO6.js.map
427
- //# sourceMappingURL=chunk-DCUMJSO6.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/gateway/backend.ts","../src/gateway/gateway.ts","../src/gateway/http-route.ts","../src/gateway/tcp-route.ts","../src/gateway/udp-route.ts"],"names":["output","gateway","ComponentResource","normalizeInputsAndMap"],"mappings":";;;;;;;;AAoCO,SAAS,kBAAkB,GAAA,EAAiD;AACjF,EAAA,IAAI,OAAA,CAAQ,UAAA,CAAW,GAAG,CAAA,EAAG;AAC3B,IAAA,OAAO,MAAA,CAAO;AAAA,MACZ,IAAA,EAAM,IAAI,QAAA,CAAS,IAAA;AAAA,MACnB,SAAA,EAAW,IAAI,QAAA,CAAS,SAAA;AAAA,MACxB,IAAA,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C1B,IAAA;AAAA,QACA;AAAA,UACE,UAAU,WAAA,CAAY,IAAA,EAAM,IAAI,CAAA,CAAE,MAAM,CAAA,QAAA,MAAa;AAAA,YACnD,GAAG,QAAA;AAAA,YACH,SAAA,EAAW,aAAA,CAAc,SAAA,CAAU,QAAA,CAAS;AAAA,WAC9C,CAAE,CAAA;AAAA,UACF,IAAA,EAAM;AAAA,YACJ,UAAA;AAAA,YACA,KAAA,EAAO;AAAA,cACL;AAAA,gBACE;AAAA;AACF;AACF;AACF,SACF;AAAA,QACA,EAAE,GAAG,IAAA,EAAM,MAAA,EAAQ,MAAM,QAAA,EAAU,WAAA,CAAY,OAAO,CAAA;AAAE,OAC1D;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AACF","file":"chunk-DCUMJSO6.js","sourcesContent":["import type { core } from \"@pulumi/kubernetes\"\nimport { type Input, type Output, output, type Unwrap } from \"@highstate/pulumi\"\nimport { Service } from \"../service\"\n\nexport interface FullBackendRef {\n /**\n * The name of the resource being referenced.\n */\n name: Input<string>\n\n /**\n * The namespace of the resource being referenced.\n * May be undefined if the resource is not in a namespace.\n */\n namespace?: Input<string | undefined>\n\n /**\n * The port of the resource being referenced.\n */\n port: Input<number>\n}\n\nexport interface ServiceBackendRef {\n /**\n * The name of the service being referenced.\n */\n service: Input<core.v1.Service>\n\n /**\n * The port of the service being referenced.\n */\n port: Input<number>\n}\n\nexport type BackendRef = FullBackendRef | ServiceBackendRef | Service\n\nexport function resolveBackendRef(ref: BackendRef): Output<Unwrap<FullBackendRef>> {\n if (Service.isInstance(ref)) {\n return output({\n name: ref.metadata.name,\n namespace: ref.metadata.namespace,\n port: ref.spec.ports[0].port,\n })\n }\n\n if (\"service\" in ref) {\n const service = output(ref.service)\n\n return output({\n name: service.metadata.name,\n namespace: service.metadata.namespace,\n port: ref.port,\n })\n }\n\n return output({\n name: ref.name,\n namespace: ref.namespace,\n port: ref.port,\n })\n}\n","import type { k8s, network } from \"@highstate/library\"\nimport type { types } from \"@pulumi/kubernetes\"\nimport type { SetRequired } from \"type-fest\"\nimport { parseEndpoint } from \"@highstate/common\"\nimport { getOrCreate } from \"@highstate/contract\"\nimport { gateway, type types as gwTypes } from \"@highstate/gateway-api\"\nimport {\n type ComponentResourceOptions,\n type Input,\n type InputArray,\n type Inputs,\n interpolate,\n type Output,\n output,\n toPromise,\n} from \"@highstate/pulumi\"\nimport { omit } from \"remeda\"\nimport { Namespace } from \"../namespace\"\nimport {\n commonExtraArgs,\n getProvider,\n mapMetadata,\n NamespacedResource,\n type ScopedResourceArgs,\n} from \"../shared\"\n\nexport type GatewayArgs = ScopedResourceArgs & {\n /**\n * The FQDN to configure the listeners for.\n */\n fqdn?: Input<string>\n\n /**\n * The FQDNs to configure the listeners for.\n */\n fqdns?: InputArray<string>\n} & gwTypes.input.gateway.v1.GatewaySpec\n\nexport type CreateOrGetGatewayArgs = GatewayArgs & {\n /**\n * The gateway entity to patch/retrieve.\n */\n existing: Input<k8s.Gateway> | undefined\n}\n\nconst gatewayExtraArgs = [...commonExtraArgs, \"fqdn\", \"fqdns\"] as const\n\n/**\n * Represents a Kubernetes Gateway resource.\n */\nexport abstract class Gateway extends NamespacedResource {\n static readonly apiVersion = \"gateway.networking.k8s.io/v1\"\n static readonly kind = \"Gateway\"\n\n protected constructor(\n type: string,\n name: string,\n args: Inputs,\n opts: ComponentResourceOptions | undefined,\n\n /**\n * The namespace where the gateway is located.\n */\n metadata: Output<types.output.meta.v1.ObjectMeta>,\n namespace: Output<Namespace>,\n\n /**\n * The spec of the underlying Gateway resource.\n */\n readonly spec: Output<gwTypes.output.gateway.v1.GatewaySpec>,\n\n /**\n * The status of the underlying Gateway resource.\n */\n readonly status: Output<gwTypes.output.gateway.v1.GatewayStatus>,\n ) {\n super(type, name, args, opts, metadata, namespace)\n }\n\n /**\n * The Highstate gateway entity.\n */\n get entity(): Output<k8s.Gateway> {\n return output(this.entityBase)\n }\n\n /**\n * Returns the endpoints L3 endpoints on which the gateway is exposed.\n */\n get endpoints(): Output<network.L3Endpoint[]> {\n return this.status.addresses.apply(addresses => {\n if (!addresses) {\n return []\n }\n\n return addresses.map(address => parseEndpoint(address.value))\n })\n }\n\n /**\n * Creates a new gateway.\n */\n static create(name: string, args: GatewayArgs, opts?: ComponentResourceOptions): Gateway {\n return new CreatedGateway(name, args, opts)\n }\n\n /**\n * Creates a new gateway or patches an existing one.\n *\n * @param name The name of the resource. May not be the same as the gateway name.\n * @param args The arguments to create or patch the gateway with.\n * @param opts Optional resource options.\n */\n static createOrPatch(\n name: string,\n args: CreateOrGetGatewayArgs,\n opts?: ComponentResourceOptions,\n ): Gateway {\n if (args.existing) {\n return new GatewayPatch(name, {\n ...args,\n name: output(args.existing).metadata.name,\n namespace: Namespace.forResourceAsync(args.existing, output(args.namespace).cluster),\n })\n }\n\n return new CreatedGateway(name, args, opts)\n }\n\n /**\n * Creates a new gateway or gets an existing one.\n *\n * @param name The name of the resource. May not be the same as the gateway name. Will not be used when existing gateway is retrieved.\n * @param args The arguments to create or get the gateway with.\n * @param opts Optional resource options.\n */\n static async createOrGet(\n name: string,\n args: CreateOrGetGatewayArgs,\n opts?: ComponentResourceOptions,\n ): Promise<Gateway> {\n if (args.existing) {\n return await Gateway.forAsync(args.existing, output(args.namespace).cluster)\n }\n\n return new CreatedGateway(name, args, opts)\n }\n\n /**\n * Patches an existing gateway.\n *\n * Will throw an error if the gateway does not exist.\n *\n * @param name The name of the resource. May not be the same as the gateway name.\n * @param args The arguments to patch the gateway with.\n * @param opts Optional resource options.\n */\n static patch(name: string, args: GatewayArgs, opts?: ComponentResourceOptions): Gateway {\n return new GatewayPatch(name, args, opts)\n }\n\n /**\n * Wraps an existing Kubernetes gateway.\n */\n static wrap(name: string, args: WrappedGatewayArgs, opts?: ComponentResourceOptions): Gateway {\n return new WrappedGateway(name, args, opts)\n }\n\n /**\n * Gets an existing gateway.\n *\n * Will throw an error if the gateway does not exist.\n */\n static get(name: string, args: ExternalGatewayArgs, opts?: ComponentResourceOptions): Gateway {\n return new ExternalGateway(name, args, opts)\n }\n\n private static readonly gatewayCache = new Map<string, Gateway>()\n\n /**\n * Gets an existing gateway for a given entity.\n * Prefer this method over `get` when possible.\n *\n * It automatically names the resource with the following format: `{clusterName}.{namespace}.{gatewayName}.{clusterId}`.\n *\n * This method is idempotent and will return the same instance for the same entity.\n *\n * @param entity The entity to get the gateway for.\n * @param cluster The cluster where the gateway is located.\n */\n static for(entity: k8s.Gateway, cluster: Input<k8s.Cluster>): Gateway {\n return getOrCreate(\n Gateway.gatewayCache,\n `${entity.clusterName}.${entity.metadata.namespace}.${entity.metadata.name}.${entity.clusterId}`,\n name => {\n return Gateway.get(name, {\n name: entity.metadata.name,\n namespace: Namespace.forResourceAsync(entity, cluster),\n })\n },\n )\n }\n\n /**\n * Gets an existing gateway for a given entity.\n * Prefer this method over `get` when possible.\n *\n * It automatically names the resource with the following format: `{clusterName}.{namespace}.{gatewayName}.{clusterId}`.\n *\n * This method is idempotent and will return the same instance for the same entity.\n *\n * @param entity The entity to get the gateway for.\n * @param cluster The cluster where the gateway is located.\n */\n static async forAsync(entity: Input<k8s.Gateway>, cluster: Input<k8s.Cluster>): Promise<Gateway> {\n const resolvedEntity = await toPromise(entity)\n\n return Gateway.for(resolvedEntity, output(cluster))\n }\n\n /**\n * Creates a gateway with the provided name/namespace/cluster only once.\n *\n * It automatically names the resource with the following format: `{name}.{namespace}.{clusterName}.{clusterId}`.\n *\n * On subsequent calls the gateway is patched with the union of existing and requested listeners.\n * Only the listeners field is modified to avoid altering other spec fields.\n *\n * @param name The name of the gateway to create.\n * @param args The arguments to create the gateway with.\n * @param opts Optional resource options.\n */\n static async createOnce(\n args: SetRequired<GatewayArgs, \"name\">,\n opts?: ComponentResourceOptions,\n ): Promise<Gateway> {\n const { name, namespace, cluster } = await toPromise({\n name: args.name,\n namespace: output(args.namespace).metadata.name,\n cluster: output(args.namespace).cluster,\n })\n\n const fullName = `${name}.${namespace}.${cluster.name}.${cluster.id}`\n\n const existing = Gateway.gatewayCache.get(fullName)\n if (existing) {\n Gateway.patch(\n fullName,\n {\n name,\n namespace: args.namespace,\n listeners: args.listeners,\n },\n opts,\n )\n\n return existing\n }\n\n const created = Gateway.create(\n fullName,\n {\n ...args,\n name,\n namespace: args.namespace,\n },\n opts,\n )\n\n Gateway.gatewayCache.set(fullName, created)\n return created\n }\n}\n\nclass CreatedGateway extends Gateway {\n constructor(name: string, args: GatewayArgs, opts?: ComponentResourceOptions) {\n const gatewayResource = output(args.namespace).cluster.apply(cluster => {\n return new gateway.v1.Gateway(\n name,\n {\n metadata: mapMetadata(args, name),\n spec: omit(args, gatewayExtraArgs),\n },\n { ...opts, parent: this, provider: getProvider(cluster) },\n )\n })\n\n super(\n \"highstate:k8s:Gateway\",\n name,\n args,\n opts,\n\n gatewayResource.metadata as Output<types.output.meta.v1.ObjectMeta>,\n output(args.namespace),\n gatewayResource.spec,\n gatewayResource.status,\n )\n }\n}\n\nclass GatewayPatch extends Gateway {\n constructor(name: string, args: GatewayArgs, opts?: ComponentResourceOptions) {\n const gatewayResource = output(args.namespace).cluster.apply(cluster => {\n return new gateway.v1.GatewayPatch(\n name,\n {\n metadata: mapMetadata(args, name),\n spec: omit(args, gatewayExtraArgs),\n },\n { ...opts, parent: this, provider: getProvider(cluster) },\n )\n })\n\n super(\n \"highstate:k8s:GatewayPatch\",\n name,\n args,\n opts,\n\n gatewayResource.metadata as Output<types.output.meta.v1.ObjectMeta>,\n output(args.namespace),\n gatewayResource.spec,\n gatewayResource.status,\n )\n }\n}\n\nexport type WrappedGatewayArgs = {\n /**\n * The underlying Kubernetes gateway to wrap.\n */\n gateway: Input<gateway.v1.Gateway>\n\n /**\n * The namespace where the gateway is located.\n */\n namespace: Input<Namespace>\n}\n\nclass WrappedGateway extends Gateway {\n constructor(name: string, args: WrappedGatewayArgs, opts?: ComponentResourceOptions) {\n super(\n \"highstate:k8s:WrappedGateway\",\n name,\n args,\n opts,\n\n output(args.gateway).metadata as Output<types.output.meta.v1.ObjectMeta>,\n output(args.namespace),\n output(args.gateway).spec,\n output(args.gateway).status,\n )\n }\n}\n\nexport type ExternalGatewayArgs = {\n /**\n * The name of the gateway to get.\n */\n name: Input<string>\n\n /**\n * The namespace of the gateway to get.\n */\n namespace: Input<Namespace>\n}\n\nclass ExternalGateway extends Gateway {\n constructor(name: string, args: ExternalGatewayArgs, opts?: ComponentResourceOptions) {\n const gatewayResource = output(args.namespace).cluster.apply(cluster => {\n return gateway.v1.Gateway.get(\n name,\n interpolate`${output(args.namespace).metadata.name}/${args.name}`,\n { ...opts, parent: this, provider: getProvider(cluster) },\n )\n })\n\n super(\n \"highstate:k8s:ExternalGateway\",\n name,\n args,\n opts,\n\n gatewayResource.metadata as Output<types.output.meta.v1.ObjectMeta>,\n output(args.namespace),\n gatewayResource.spec,\n gatewayResource.status,\n )\n }\n}\n","import type { Gateway } from \"./gateway\"\nimport { gateway, type types } from \"@highstate/gateway-api\"\nimport {\n ComponentResource,\n type ComponentResourceOptions,\n type Input,\n type InputArray,\n normalize,\n normalizeInputs,\n normalizeInputsAndMap,\n type Output,\n output,\n} from \"@highstate/pulumi\"\nimport { map, pipe } from \"remeda\"\nimport { getProvider, mapMetadata, type ScopedResourceArgs } from \"../shared\"\nimport { type BackendRef, resolveBackendRef } from \"./backend\"\n\nexport type HttpRouteArgs = Omit<ScopedResourceArgs, \"namespace\"> & {\n /**\n * The gateway to associate with the route.\n */\n gateway: Input<Gateway>\n\n /**\n * The alias for `hostnames: [hostname]`.\n */\n hostname?: Input<string>\n\n /**\n * The rule of the route.\n */\n rule?: Input<HttpRouteRuleArgs>\n\n /**\n * The rules of the route.\n */\n rules?: InputArray<HttpRouteRuleArgs>\n} & Omit<Partial<types.input.gateway.v1.HTTPRouteSpec>, \"rules\">\n\nexport type HttpRouteRuleArgs = Omit<\n types.input.gateway.v1.HTTPRouteSpecRules,\n \"matches\" | \"filters\" | \"backendRefs\"\n> & {\n /**\n * The conditions of the rule.\n * Can be specified as string to match on the path.\n */\n matches?: InputArray<HttpRouteRuleMatchOptions>\n\n /**\n * The condition of the rule.\n * Can be specified as string to match on the path.\n */\n match?: Input<HttpRouteRuleMatchOptions>\n\n /**\n * The filters of the rule.\n */\n filters?: InputArray<types.input.gateway.v1.HTTPRouteSpecRulesFilters>\n\n /**\n * The filter of the rule.\n */\n filter?: Input<types.input.gateway.v1.HTTPRouteSpecRulesFilters>\n\n /**\n * The service to route to.\n */\n backend?: Input<BackendRef>\n\n /**\n * The services to route to.\n */\n backends?: InputArray<BackendRef>\n}\n\nexport type HttpRouteRuleMatchOptions = types.input.gateway.v1.HTTPRouteSpecRulesMatches | string\n\nexport class HttpRoute extends ComponentResource {\n /**\n * The underlying Kubernetes resource.\n */\n public readonly route: Output<gateway.v1.HTTPRoute>\n\n constructor(name: string, args: HttpRouteArgs, opts?: ComponentResourceOptions) {\n super(\"highstate:k8s:HttpRoute\", name, args, opts)\n\n this.route = output(args.gateway).cluster.apply(cluster => {\n return new gateway.v1.HTTPRoute(\n name,\n {\n metadata: mapMetadata(args, name).apply(metadata => ({\n ...metadata,\n namespace: output(args.gateway).namespace.metadata.name,\n })),\n spec: {\n hostnames: normalizeInputs(args.hostname, args.hostnames),\n\n parentRefs: [\n {\n name: output(args.gateway).metadata.name,\n },\n ],\n\n rules: normalizeInputsAndMap(args.rule, args.rules, rule => ({\n timeouts: rule.timeouts,\n\n matches: pipe(\n normalize(rule.match, rule.matches),\n map(mapHttpRouteRuleMatch),\n addDefaultPathMatch,\n ),\n\n filters: normalize(rule.filter, rule.filters),\n backendRefs: normalizeInputsAndMap(rule.backend, rule.backends, resolveBackendRef),\n })),\n } satisfies types.input.gateway.v1.HTTPRouteSpec,\n },\n { ...opts, parent: this, provider: getProvider(cluster) },\n )\n })\n }\n}\n\nfunction addDefaultPathMatch(\n matches: types.input.gateway.v1.HTTPRouteSpecRulesMatches[],\n): types.input.gateway.v1.HTTPRouteSpecRulesMatches[] {\n return matches.length ? matches : [{ path: { type: \"PathPrefix\", value: \"/\" } }]\n}\n\nexport function mapHttpRouteRuleMatch(\n match: HttpRouteRuleMatchOptions,\n): types.input.gateway.v1.HTTPRouteSpecRulesMatches {\n if (typeof match === \"string\") {\n return { path: { type: \"PathPrefix\", value: match } }\n }\n\n return match\n}\n","import type { Gateway } from \"./gateway\"\nimport { gateway, type types } from \"@highstate/gateway-api\"\nimport {\n ComponentResource,\n type ComponentResourceOptions,\n type Input,\n type InputArray,\n normalizeInputsAndMap,\n type Output,\n output,\n} from \"@highstate/pulumi\"\nimport { getProvider, mapMetadata, type ScopedResourceArgs } from \"../shared\"\nimport { type BackendRef, resolveBackendRef } from \"./backend\"\n\nexport type TcpRouteArgs = Omit<ScopedResourceArgs, \"namespace\"> & {\n /**\n * The gateway to associate with the route.\n */\n gateway: Input<Gateway>\n\n /**\n * The name of the listener to attach the route to.\n */\n listenerName: Input<string>\n\n /**\n * The backend reference handled by the route.\n */\n backend?: Input<BackendRef>\n\n /**\n * The backend references handled by the route.\n */\n backends?: InputArray<BackendRef>\n}\n\nexport class TcpRoute extends ComponentResource {\n /**\n * The underlying Kubernetes resource.\n */\n public readonly route: Output<gateway.v1alpha2.TCPRoute>\n\n constructor(name: string, args: TcpRouteArgs, opts?: ComponentResourceOptions) {\n super(\"highstate:k8s:TcpRoute\", name, args, opts)\n\n const gatewayOutput = output(args.gateway)\n\n const parentRefs = output({\n gateway: gatewayOutput,\n listenerName: args.listenerName,\n }).apply(\n ({ gateway, listenerName }) =>\n [\n {\n group: \"gateway.networking.k8s.io\",\n kind: \"Gateway\",\n name: gateway.metadata.name,\n namespace: gateway.namespace.metadata.name,\n sectionName: listenerName,\n },\n ] satisfies types.input.gateway.v1alpha2.TCPRouteSpecParentRefs[],\n )\n\n const backendRefs = normalizeInputsAndMap(args.backend, args.backends, resolveBackendRef)\n\n this.route = gatewayOutput.cluster.apply(cluster => {\n return new gateway.v1alpha2.TCPRoute(\n name,\n {\n metadata: mapMetadata(args, name).apply(metadata => ({\n ...metadata,\n namespace: gatewayOutput.namespace.metadata.name,\n })),\n spec: {\n parentRefs,\n rules: [\n {\n backendRefs,\n },\n ],\n } satisfies types.input.gateway.v1alpha2.TCPRouteSpec,\n },\n { ...opts, parent: this, provider: getProvider(cluster) },\n )\n })\n }\n}\n","import type { Gateway } from \"./gateway\"\nimport { gateway, type types } from \"@highstate/gateway-api\"\nimport {\n ComponentResource,\n type ComponentResourceOptions,\n type Input,\n type InputArray,\n normalizeInputsAndMap,\n type Output,\n output,\n} from \"@highstate/pulumi\"\nimport { getProvider, mapMetadata, type ScopedResourceArgs } from \"../shared\"\nimport { type BackendRef, resolveBackendRef } from \"./backend\"\n\nexport type UdpRouteArgs = Omit<ScopedResourceArgs, \"namespace\"> & {\n /**\n * The gateway to associate with the route.\n */\n gateway: Input<Gateway>\n\n /**\n * The name of the listener to attach the route to.\n */\n listenerName: Input<string>\n\n /**\n * The backend reference handled by the route.\n */\n backend?: Input<BackendRef>\n\n /**\n * The backend references handled by the route.\n */\n backends?: InputArray<BackendRef>\n}\n\nexport class UdpRoute extends ComponentResource {\n /**\n * The underlying Kubernetes resource.\n */\n public readonly route: Output<gateway.v1alpha2.UDPRoute>\n\n constructor(name: string, args: UdpRouteArgs, opts?: ComponentResourceOptions) {\n super(\"highstate:k8s:UdpRoute\", name, args, opts)\n\n const gatewayOutput = output(args.gateway)\n\n const parentRefs = output({\n gateway: gatewayOutput,\n listenerName: args.listenerName,\n }).apply(\n ({ gateway, listenerName }) =>\n [\n {\n group: \"gateway.networking.k8s.io\",\n kind: \"Gateway\",\n name: gateway.metadata.name,\n namespace: gateway.namespace.metadata.name,\n sectionName: listenerName,\n },\n ] satisfies types.input.gateway.v1alpha2.UDPRouteSpecParentRefs[],\n )\n\n const backendRefs = normalizeInputsAndMap(args.backend, args.backends, resolveBackendRef)\n\n this.route = gatewayOutput.cluster.apply(cluster => {\n return new gateway.v1alpha2.UDPRoute(\n name,\n {\n metadata: mapMetadata(args, name).apply(metadata => ({\n ...metadata,\n namespace: gatewayOutput.namespace.metadata.name,\n })),\n spec: {\n parentRefs,\n rules: [\n {\n backendRefs,\n },\n ],\n } satisfies types.input.gateway.v1alpha2.UDPRouteSpec,\n },\n { ...opts, parent: this, provider: getProvider(cluster) },\n )\n })\n }\n}\n"]}