@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
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ import {
3
+ StatefulSet
4
+ } from "./chunk-z6bmpnm7.js";
5
+ import"./chunk-h1b79v66.js";
6
+ import"./chunk-k4w9zpn5.js";
7
+ import"./chunk-facs31cb.js";
8
+ import"./chunk-b05q6fm2.js";
9
+ export {
10
+ StatefulSet
11
+ };
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ import {
3
+ Job
4
+ } from "./chunk-qyshvz32.js";
5
+ import"./chunk-h1b79v66.js";
6
+ import"./chunk-k4w9zpn5.js";
7
+ import"./chunk-facs31cb.js";
8
+ import"./chunk-b05q6fm2.js";
9
+ export {
10
+ Job
11
+ };
@@ -0,0 +1,299 @@
1
+ // @bun
2
+ import {
3
+ Service
4
+ } from "./chunk-k4w9zpn5.js";
5
+ import {
6
+ Namespace,
7
+ NamespacedResource,
8
+ commonExtraArgs,
9
+ getProvider,
10
+ mapMetadata
11
+ } from "./chunk-facs31cb.js";
12
+
13
+ // src/gateway/backend.ts
14
+ import { output } from "@highstate/pulumi";
15
+ function resolveBackendRef(ref) {
16
+ if (Service.isInstance(ref)) {
17
+ return output({
18
+ name: ref.metadata.name,
19
+ namespace: ref.metadata.namespace,
20
+ port: ref.spec.ports[0].port
21
+ });
22
+ }
23
+ if ("service" in ref) {
24
+ const service = output(ref.service);
25
+ return output({
26
+ name: service.metadata.name,
27
+ namespace: service.metadata.namespace,
28
+ port: ref.port ?? service.spec.ports[0].port
29
+ });
30
+ }
31
+ return output({
32
+ name: ref.name,
33
+ namespace: ref.namespace,
34
+ port: ref.port
35
+ });
36
+ }
37
+
38
+ // src/gateway/gateway.ts
39
+ import { parseEndpoint } from "@highstate/common";
40
+ import { getOrCreate } from "@highstate/contract";
41
+ import { gateway } from "@highstate/gateway-api";
42
+ import { k8s } from "@highstate/library";
43
+ import {
44
+ interpolate,
45
+ makeEntityOutput,
46
+ output as output2,
47
+ toPromise
48
+ } from "@highstate/pulumi";
49
+ import { omit } from "remeda";
50
+ var gatewayExtraArgs = [...commonExtraArgs, "fqdn", "fqdns"];
51
+
52
+ class Gateway extends NamespacedResource {
53
+ spec;
54
+ status;
55
+ static apiVersion = "gateway.networking.k8s.io/v1";
56
+ static kind = "Gateway";
57
+ constructor(type, name, args, opts, metadata, namespace, spec, status) {
58
+ super(type, name, args, opts, metadata, namespace);
59
+ this.spec = spec;
60
+ this.status = status;
61
+ }
62
+ get entity() {
63
+ return makeEntityOutput({
64
+ entity: k8s.gatewayEntity,
65
+ identity: this.metadata.uid,
66
+ meta: {
67
+ title: this.metadata.name
68
+ },
69
+ value: {
70
+ ...this.entityBase
71
+ }
72
+ });
73
+ }
74
+ get endpoints() {
75
+ return this.status.addresses.apply((addresses) => {
76
+ if (!addresses) {
77
+ return [];
78
+ }
79
+ return addresses.map((address) => parseEndpoint(address.value));
80
+ });
81
+ }
82
+ static create(name, args, opts) {
83
+ return new CreatedGateway(name, args, opts);
84
+ }
85
+ static createOrPatch(name, args, opts) {
86
+ if (args.existing) {
87
+ return new GatewayPatch(name, {
88
+ ...args,
89
+ name: output2(args.existing).metadata.name,
90
+ namespace: Namespace.forResourceAsync(args.existing, output2(args.namespace).cluster)
91
+ });
92
+ }
93
+ return new CreatedGateway(name, args, opts);
94
+ }
95
+ static async createOrGet(name, args, opts) {
96
+ if (args.existing) {
97
+ return await Gateway.forAsync(args.existing, output2(args.namespace).cluster);
98
+ }
99
+ return new CreatedGateway(name, args, opts);
100
+ }
101
+ static patch(name, args, opts) {
102
+ return new GatewayPatch(name, args, opts);
103
+ }
104
+ static wrap(name, args, opts) {
105
+ return new WrappedGateway(name, args, opts);
106
+ }
107
+ static get(name, args, opts) {
108
+ return new ExternalGateway(name, args, opts);
109
+ }
110
+ static gatewayCache = new Map;
111
+ static for(entity, cluster) {
112
+ return getOrCreate(Gateway.gatewayCache, `${entity.clusterName}.${entity.metadata.namespace}.${entity.metadata.name}.${entity.clusterId}`, (name) => {
113
+ return Gateway.get(name, {
114
+ name: entity.metadata.name,
115
+ namespace: Namespace.forResourceAsync(entity, cluster)
116
+ });
117
+ });
118
+ }
119
+ static async forAsync(entity, cluster) {
120
+ const resolvedEntity = await toPromise(entity);
121
+ return Gateway.for(resolvedEntity, output2(cluster));
122
+ }
123
+ }
124
+
125
+ class CreatedGateway extends Gateway {
126
+ constructor(name, args, opts) {
127
+ const gatewayResource = output2(args.namespace).cluster.apply((cluster) => {
128
+ return new gateway.v1.Gateway(name, {
129
+ metadata: mapMetadata(args, name),
130
+ spec: omit(args, gatewayExtraArgs)
131
+ }, { ...opts, parent: this, provider: getProvider(cluster) });
132
+ });
133
+ super("highstate:k8s:Gateway", name, args, opts, gatewayResource.metadata, output2(args.namespace), gatewayResource.spec, gatewayResource.status);
134
+ }
135
+ }
136
+
137
+ class GatewayPatch extends Gateway {
138
+ constructor(name, args, opts) {
139
+ const gatewayResource = output2(args.namespace).cluster.apply((cluster) => {
140
+ return new gateway.v1.GatewayPatch(name, {
141
+ metadata: mapMetadata(args, name),
142
+ spec: omit(args, gatewayExtraArgs)
143
+ }, { ...opts, parent: this, provider: getProvider(cluster) });
144
+ });
145
+ super("highstate:k8s:GatewayPatch", name, args, opts, gatewayResource.metadata, output2(args.namespace), gatewayResource.spec, gatewayResource.status);
146
+ }
147
+ }
148
+
149
+ class WrappedGateway extends Gateway {
150
+ constructor(name, args, opts) {
151
+ super("highstate:k8s:WrappedGateway", name, args, opts, output2(args.gateway).metadata, output2(args.namespace), output2(args.gateway).spec, output2(args.gateway).status);
152
+ }
153
+ }
154
+
155
+ class ExternalGateway extends Gateway {
156
+ constructor(name, args, opts) {
157
+ const gatewayResource = output2(args.namespace).cluster.apply((cluster) => {
158
+ return gateway.v1.Gateway.get(name, interpolate`${output2(args.namespace).metadata.name}/${args.name}`, { ...opts, parent: this, provider: getProvider(cluster) });
159
+ });
160
+ super("highstate:k8s:ExternalGateway", name, args, opts, gatewayResource.metadata, output2(args.namespace), gatewayResource.spec, gatewayResource.status);
161
+ }
162
+ }
163
+
164
+ // src/gateway/http-route.ts
165
+ import { gateway as gateway2 } from "@highstate/gateway-api";
166
+ import {
167
+ ComponentResource,
168
+ normalize,
169
+ normalizeInputs,
170
+ normalizeInputsAndMap,
171
+ output as output3
172
+ } from "@highstate/pulumi";
173
+ import { map, pipe } from "remeda";
174
+ class HttpRoute extends ComponentResource {
175
+ route;
176
+ constructor(name, args, opts) {
177
+ super("highstate:k8s:HttpRoute", name, args, opts);
178
+ this.route = output3(args.gateway).cluster.apply((cluster) => {
179
+ return new gateway2.v1.HTTPRoute(name, {
180
+ metadata: mapMetadata(args, name).apply((metadata) => ({
181
+ ...metadata,
182
+ namespace: output3(args.gateway).namespace.metadata.name
183
+ })),
184
+ spec: {
185
+ hostnames: normalizeInputs(args.hostname, args.hostnames),
186
+ parentRefs: [
187
+ {
188
+ name: output3(args.gateway).metadata.name
189
+ }
190
+ ],
191
+ rules: normalizeInputsAndMap(args.rule, args.rules, (rule) => ({
192
+ timeouts: rule.timeouts,
193
+ matches: pipe(normalize(rule.match, rule.matches), map(mapHttpRouteRuleMatch), addDefaultPathMatch),
194
+ filters: normalize(rule.filter, rule.filters),
195
+ backendRefs: normalizeInputsAndMap(rule.backend, rule.backends, resolveBackendRef)
196
+ }))
197
+ }
198
+ }, { ...opts, parent: this, provider: getProvider(cluster) });
199
+ });
200
+ }
201
+ }
202
+ function addDefaultPathMatch(matches) {
203
+ return matches.length ? matches : [{ path: { type: "PathPrefix", value: "/" } }];
204
+ }
205
+ function mapHttpRouteRuleMatch(match) {
206
+ if (typeof match === "string") {
207
+ return { path: { type: "PathPrefix", value: match } };
208
+ }
209
+ return match;
210
+ }
211
+
212
+ // src/gateway/tcp-route.ts
213
+ import { gateway as gateway3 } from "@highstate/gateway-api";
214
+ import {
215
+ ComponentResource as ComponentResource2,
216
+ normalizeInputsAndMap as normalizeInputsAndMap2,
217
+ output as output4
218
+ } from "@highstate/pulumi";
219
+ class TcpRoute extends ComponentResource2 {
220
+ route;
221
+ constructor(name, args, opts) {
222
+ super("highstate:k8s:TcpRoute", name, args, opts);
223
+ const gatewayOutput = output4(args.gateway);
224
+ const parentRefs = output4({
225
+ gateway: gatewayOutput,
226
+ listenerName: args.listenerName
227
+ }).apply(({ gateway: gateway4, listenerName }) => [
228
+ {
229
+ group: "gateway.networking.k8s.io",
230
+ kind: "Gateway",
231
+ name: gateway4.metadata.name,
232
+ namespace: gateway4.namespace.metadata.name,
233
+ sectionName: listenerName
234
+ }
235
+ ]);
236
+ const backendRefs = normalizeInputsAndMap2(args.backend, args.backends, resolveBackendRef);
237
+ this.route = gatewayOutput.cluster.apply((cluster) => {
238
+ return new gateway3.v1alpha2.TCPRoute(name, {
239
+ metadata: mapMetadata(args, name).apply((metadata) => ({
240
+ ...metadata,
241
+ namespace: gatewayOutput.namespace.metadata.name
242
+ })),
243
+ spec: {
244
+ parentRefs,
245
+ rules: [
246
+ {
247
+ backendRefs
248
+ }
249
+ ]
250
+ }
251
+ }, { ...opts, parent: this, provider: getProvider(cluster) });
252
+ });
253
+ }
254
+ }
255
+
256
+ // src/gateway/udp-route.ts
257
+ import { gateway as gateway4 } from "@highstate/gateway-api";
258
+ import {
259
+ ComponentResource as ComponentResource3,
260
+ normalizeInputsAndMap as normalizeInputsAndMap3,
261
+ output as output5
262
+ } from "@highstate/pulumi";
263
+ class UdpRoute extends ComponentResource3 {
264
+ route;
265
+ constructor(name, args, opts) {
266
+ super("highstate:k8s:UdpRoute", name, args, opts);
267
+ const gatewayOutput = output5(args.gateway);
268
+ const parentRefs = output5({
269
+ gateway: gatewayOutput,
270
+ listenerName: args.listenerName
271
+ }).apply(({ gateway: gateway5, listenerName }) => [
272
+ {
273
+ group: "gateway.networking.k8s.io",
274
+ kind: "Gateway",
275
+ name: gateway5.metadata.name,
276
+ namespace: gateway5.namespace.metadata.name,
277
+ sectionName: listenerName
278
+ }
279
+ ]);
280
+ const backendRefs = normalizeInputsAndMap3(args.backend, args.backends, resolveBackendRef);
281
+ this.route = gatewayOutput.cluster.apply((cluster) => {
282
+ return new gateway4.v1alpha2.UDPRoute(name, {
283
+ metadata: mapMetadata(args, name).apply((metadata) => ({
284
+ ...metadata,
285
+ namespace: gatewayOutput.namespace.metadata.name
286
+ })),
287
+ spec: {
288
+ parentRefs,
289
+ rules: [
290
+ {
291
+ backendRefs
292
+ }
293
+ ]
294
+ }
295
+ }, { ...opts, parent: this, provider: getProvider(cluster) });
296
+ });
297
+ }
298
+ }
299
+ export { resolveBackendRef, Gateway, HttpRoute, mapHttpRouteRuleMatch, TcpRoute, UdpRoute };
@@ -0,0 +1,155 @@
1
+ // @bun
2
+ import {
3
+ Namespace,
4
+ NamespacedResource,
5
+ Secret,
6
+ commonExtraArgs,
7
+ getProvider,
8
+ mapMetadata
9
+ } from "./chunk-facs31cb.js";
10
+
11
+ // src/tls.ts
12
+ import { cert_manager } from "@highstate/cert-manager";
13
+ import { getOrCreate } from "@highstate/contract";
14
+ import { k8s } from "@highstate/library";
15
+ import {
16
+ interpolate,
17
+ makeEntityOutput,
18
+ output,
19
+ toPromise
20
+ } from "@highstate/pulumi";
21
+ import { omit } from "remeda";
22
+ var certManagerCertificateWaitFor = "condition=Ready";
23
+ function mapCertificateMetadata(args, fallbackName) {
24
+ return mapMetadata(args, fallbackName).apply((metadata) => ({
25
+ ...metadata,
26
+ annotations: {
27
+ ...metadata.annotations,
28
+ "pulumi.com/waitFor": metadata.annotations?.["pulumi.com/waitFor"] ?? certManagerCertificateWaitFor
29
+ }
30
+ }));
31
+ }
32
+
33
+ class Certificate extends NamespacedResource {
34
+ name;
35
+ spec;
36
+ status;
37
+ static apiVersion = "cert-manager.io/v1";
38
+ static kind = "Certificate";
39
+ _secret;
40
+ constructor(type, name, args, opts, metadata, namespace, spec, status) {
41
+ super(type, name, args, opts, metadata, namespace);
42
+ this.name = name;
43
+ this.spec = spec;
44
+ this.status = status;
45
+ }
46
+ get entity() {
47
+ return makeEntityOutput({
48
+ entity: k8s.certificateEntity,
49
+ identity: this.metadata.uid,
50
+ meta: {
51
+ title: this.metadata.name
52
+ },
53
+ value: {
54
+ ...this.entityBase
55
+ }
56
+ });
57
+ }
58
+ get secret() {
59
+ if (this._secret) {
60
+ return this._secret;
61
+ }
62
+ this._secret = output({
63
+ secretName: this.spec.apply((spec) => spec.secretName),
64
+ namespace: this.namespace
65
+ }).apply(({ secretName, namespace }) => {
66
+ return Secret.get(`${this.name}.secret`, {
67
+ name: secretName,
68
+ namespace
69
+ });
70
+ });
71
+ return this._secret;
72
+ }
73
+ static create(name, args, opts) {
74
+ return new CreatedCertificate(name, args, opts);
75
+ }
76
+ static createOrPatch(name, args, opts) {
77
+ if (args.existing) {
78
+ return new CertificatePatch(name, {
79
+ ...args,
80
+ name: output(args.existing).metadata.name,
81
+ namespace: Namespace.forResourceAsync(args.existing, output(args.namespace).cluster)
82
+ });
83
+ }
84
+ return new CreatedCertificate(name, args, opts);
85
+ }
86
+ static async createOrGet(name, args, opts) {
87
+ if (args.existing) {
88
+ return await Certificate.forAsync(args.existing, output(args.namespace).cluster);
89
+ }
90
+ return new CreatedCertificate(name, args, opts);
91
+ }
92
+ static patch(name, args, opts) {
93
+ return new CertificatePatch(name, args, opts);
94
+ }
95
+ static wrap(name, args, opts) {
96
+ return new WrappedCertificate(name, args, opts);
97
+ }
98
+ static get(name, args, opts) {
99
+ return new ExternalCertificate(name, args, opts);
100
+ }
101
+ static certificateCache = new Map;
102
+ static for(entity, cluster) {
103
+ return getOrCreate(Certificate.certificateCache, `${entity.clusterName}.${entity.metadata.namespace}.${entity.metadata.name}.${entity.clusterId}`, (name) => {
104
+ return Certificate.get(name, {
105
+ name: entity.metadata.name,
106
+ namespace: Namespace.forResourceAsync(entity, cluster)
107
+ });
108
+ });
109
+ }
110
+ static async forAsync(entity, cluster) {
111
+ const resolvedEntity = await toPromise(entity);
112
+ return Certificate.for(resolvedEntity, output(cluster));
113
+ }
114
+ }
115
+
116
+ class CreatedCertificate extends Certificate {
117
+ constructor(name, args, opts) {
118
+ const certificate = output(args.namespace).cluster.apply((cluster) => {
119
+ return new cert_manager.v1.Certificate(name, {
120
+ metadata: mapCertificateMetadata(args, name),
121
+ spec: omit(args, commonExtraArgs)
122
+ }, { ...opts, parent: this, provider: getProvider(cluster) });
123
+ });
124
+ super("highstate:k8s:Certificate", name, args, opts, certificate.metadata, output(args.namespace), certificate.spec, certificate.status);
125
+ }
126
+ }
127
+
128
+ class CertificatePatch extends Certificate {
129
+ constructor(name, args, opts) {
130
+ const certificate = output(args.namespace).cluster.apply((cluster) => {
131
+ return new cert_manager.v1.CertificatePatch(name, {
132
+ metadata: mapCertificateMetadata(args, name),
133
+ spec: omit(args, commonExtraArgs)
134
+ }, { ...opts, parent: this, provider: getProvider(cluster) });
135
+ });
136
+ super("highstate:k8s:CertificatePatch", name, args, opts, certificate.metadata, output(args.namespace), certificate.spec, certificate.status);
137
+ }
138
+ }
139
+
140
+ class WrappedCertificate extends Certificate {
141
+ constructor(name, args, opts) {
142
+ super("highstate:k8s:WrappedCertificate", name, args, opts, output(args.certificate).metadata, output(args.namespace), output(args.certificate).spec, output(args.certificate).status);
143
+ }
144
+ }
145
+
146
+ class ExternalCertificate extends Certificate {
147
+ constructor(name, args, opts) {
148
+ const certificate = output(args.namespace).cluster.apply((cluster) => {
149
+ return cert_manager.v1.Certificate.get(name, interpolate`${output(args.namespace).metadata.name}/${args.name}`, { ...opts, parent: this, provider: getProvider(cluster) });
150
+ });
151
+ super("highstate:k8s:ExternalCertificate", name, args, opts, certificate.metadata, output(args.namespace), certificate.spec, certificate.status);
152
+ }
153
+ }
154
+
155
+ export { Certificate };
@@ -0,0 +1,170 @@
1
+ // @bun
2
+ import {
3
+ Workload,
4
+ filterPatchOwnedContainersInTemplate,
5
+ getWorkloadServiceComponents,
6
+ workloadServiceExtraArgs
7
+ } from "./chunk-h1b79v66.js";
8
+ import {
9
+ Namespace,
10
+ getProvider,
11
+ mapMetadata
12
+ } from "./chunk-facs31cb.js";
13
+
14
+ // src/deployment.ts
15
+ import { getOrCreate } from "@highstate/contract";
16
+ import { k8s } from "@highstate/library";
17
+ import {
18
+ interpolate,
19
+ makeEntityOutput,
20
+ output,
21
+ toPromise
22
+ } from "@highstate/pulumi";
23
+ import { apps } from "@pulumi/kubernetes";
24
+ import { deepmerge } from "deepmerge-ts";
25
+ import { omit } from "remeda";
26
+ class Deployment extends Workload {
27
+ spec;
28
+ status;
29
+ static apiVersion = "apps/v1";
30
+ static kind = "Deployment";
31
+ constructor(type, name, args, opts, metadata, namespace, terminalArgs, containers, networkPolicy, service, routes, spec, status) {
32
+ super(type, name, args, opts, metadata, namespace, terminalArgs, containers, spec.template, networkPolicy, service, routes);
33
+ this.spec = spec;
34
+ this.status = status;
35
+ }
36
+ get templateMetadata() {
37
+ return this.spec.template.metadata;
38
+ }
39
+ getTerminalMeta() {
40
+ return output({
41
+ title: "Deployment",
42
+ globalTitle: interpolate`Deployment | ${this.metadata.name}`,
43
+ description: "The shell inside the deployment.",
44
+ icon: "devicon:kubernetes"
45
+ });
46
+ }
47
+ get entity() {
48
+ const service = this._service.apply((service2) => service2?.entity);
49
+ return makeEntityOutput({
50
+ entity: k8s.deploymentEntity,
51
+ identity: this.metadata.uid,
52
+ meta: {
53
+ title: this.metadata.name
54
+ },
55
+ value: {
56
+ ...this.entityBase,
57
+ service,
58
+ spec: this.spec
59
+ }
60
+ });
61
+ }
62
+ static create(name, args, opts) {
63
+ return new CreatedDeployment(name, args, opts);
64
+ }
65
+ static createOrPatch(name, args, opts) {
66
+ if (args.existing) {
67
+ return new DeploymentPatch(name, {
68
+ ...args,
69
+ name: output(args.existing).metadata.name,
70
+ namespace: Namespace.forResourceAsync(args.existing, output(args.namespace).cluster)
71
+ });
72
+ }
73
+ return new CreatedDeployment(name, args, opts);
74
+ }
75
+ static async createOrGet(name, args, opts) {
76
+ if (args.existing) {
77
+ return await Deployment.forAsync(args.existing, output(args.namespace).cluster);
78
+ }
79
+ return new CreatedDeployment(name, args, opts);
80
+ }
81
+ static patch(name, args, opts) {
82
+ return new DeploymentPatch(name, args, opts);
83
+ }
84
+ static wrap(name, args, opts) {
85
+ return new WrappedDeployment(name, args, opts);
86
+ }
87
+ static get(name, args, opts) {
88
+ return new ExternalDeployment(name, args, opts);
89
+ }
90
+ static deploymentCache = new Map;
91
+ static for(entity, cluster) {
92
+ return getOrCreate(Deployment.deploymentCache, `${entity.clusterName}.${entity.metadata.namespace}.${entity.metadata.name}.${entity.clusterId}`, (name) => {
93
+ return Deployment.get(name, {
94
+ name: entity.metadata.name,
95
+ namespace: Namespace.forResource(entity, cluster)
96
+ });
97
+ });
98
+ }
99
+ static async forAsync(entity, cluster) {
100
+ const resolvedEntity = await toPromise(entity);
101
+ return Deployment.for(resolvedEntity, cluster);
102
+ }
103
+ }
104
+
105
+ class CreatedDeployment extends Deployment {
106
+ constructor(name, args, opts) {
107
+ const { labels, podTemplate, networkPolicy, containers, service, routes } = getWorkloadServiceComponents(name, args, () => this, opts);
108
+ const deployment = output(args.namespace).cluster.apply((cluster) => {
109
+ return new apps.v1.Deployment(name, {
110
+ metadata: mapMetadata(args, name),
111
+ spec: output({ args, podTemplate, labels }).apply(({ args: args2, podTemplate: podTemplate2, labels: labels2 }) => {
112
+ return deepmerge({
113
+ template: podTemplate2,
114
+ selector: { matchLabels: labels2 }
115
+ }, omit(args2, workloadServiceExtraArgs));
116
+ })
117
+ }, { ...opts, parent: this, provider: getProvider(cluster) });
118
+ });
119
+ super("highstate:k8s:Deployment", name, args, opts, deployment.metadata, output(args.namespace), output(args.terminal ?? {}), containers, networkPolicy, service, routes, deployment.spec, deployment.status);
120
+ }
121
+ }
122
+
123
+ class DeploymentPatch extends Deployment {
124
+ constructor(name, args, opts) {
125
+ const { podTemplate, networkPolicy, containers, service, routes } = getWorkloadServiceComponents(name, args, () => this, opts, true);
126
+ const deployment = output(args.namespace).cluster.apply((cluster) => {
127
+ return new apps.v1.DeploymentPatch(name, {
128
+ metadata: mapMetadata(args, name),
129
+ spec: output({ args, podTemplate }).apply(({ args: args2, podTemplate: podTemplate2 }) => {
130
+ const spec = deepmerge({ template: podTemplate2 }, omit(args2, workloadServiceExtraArgs));
131
+ if (spec.template) {
132
+ spec.template = filterPatchOwnedContainersInTemplate(spec.template, podTemplate2);
133
+ }
134
+ return spec;
135
+ })
136
+ }, {
137
+ ...opts,
138
+ parent: this,
139
+ provider: getProvider(cluster)
140
+ });
141
+ });
142
+ const filteredSpec = output({ spec: deployment.spec, podTemplate }).apply(({ spec, podTemplate: podTemplate2 }) => {
143
+ if (!spec.template) {
144
+ return spec;
145
+ }
146
+ return {
147
+ ...spec,
148
+ template: filterPatchOwnedContainersInTemplate(spec.template, podTemplate2)
149
+ };
150
+ });
151
+ super("highstate:k8s:DeploymentPatch", name, args, opts, deployment.metadata, output(args.namespace), output(args.terminal ?? {}), containers, networkPolicy, service, routes, filteredSpec, deployment.status);
152
+ }
153
+ }
154
+
155
+ class WrappedDeployment extends Deployment {
156
+ constructor(name, args, opts) {
157
+ super("highstate:k8s:WrappedDeployment", name, args, opts, output(args.deployment).metadata, output(args.namespace), output(args.terminal ?? {}), output([]), output(undefined), output(undefined), output([]), output(args.deployment).spec, output(args.deployment).status);
158
+ }
159
+ }
160
+
161
+ class ExternalDeployment extends Deployment {
162
+ constructor(name, args, opts) {
163
+ const deployment = output(args.namespace).cluster.apply((cluster) => {
164
+ return apps.v1.Deployment.get(name, interpolate`${output(args.namespace).metadata.name}/${args.name}`, { ...opts, parent: this, provider: getProvider(cluster) });
165
+ });
166
+ super("highstate:k8s:ExternalDeployment", name, args, opts, deployment.metadata, output(args.namespace), output({}), output([]), output(undefined), output(undefined), output([]), deployment.spec, deployment.status);
167
+ }
168
+ }
169
+
170
+ export { Deployment };