@crossdelta/infrastructure 0.11.3 → 0.11.5

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.
package/dist/index.cjs CHANGED
@@ -1134,6 +1134,7 @@ var materializeStreams = (provider, namespace, config) => {
1134
1134
  return job;
1135
1135
  };
1136
1136
  // lib/runtimes/doks/caddy.ts
1137
+ var import_node_crypto = require("node:crypto");
1137
1138
  var k8s5 = __toESM(require("@pulumi/kubernetes"));
1138
1139
  var CADDY_DEFAULTS = {
1139
1140
  resources: {
@@ -1171,8 +1172,11 @@ var generateHandleBlock = (handle, level, basicAuth) => {
1171
1172
  ${inner}
1172
1173
  }`, level);
1173
1174
  };
1174
- var generateRouteBlock = (route) => {
1175
+ var generateRouteBlock = (route, encode) => {
1175
1176
  const body = [];
1177
+ if (!route.redirect && encode?.length) {
1178
+ body.push(` encode ${encode.join(" ")}`);
1179
+ }
1176
1180
  if (route.handles && route.handles.length > 0) {
1177
1181
  for (const handle of route.handles) {
1178
1182
  body.push(generateHandleBlock(handle, 1, route.basicAuth));
@@ -1208,8 +1212,14 @@ var generateGlobalBlock = (config) => {
1208
1212
  return lines.join(`
1209
1213
  `);
1210
1214
  };
1211
- var generateCatchAllBlock = (upstream) => ["https:// {", " tls {", " on_demand", " }", ` reverse_proxy ${upstream}`, "}"].join(`
1215
+ var generateCatchAllBlock = (upstream, encode) => {
1216
+ const lines = ["https:// {", " tls {", " on_demand", " }"];
1217
+ if (encode?.length)
1218
+ lines.push(` encode ${encode.join(" ")}`);
1219
+ lines.push(` reverse_proxy ${upstream}`, "}");
1220
+ return lines.join(`
1212
1221
  `);
1222
+ };
1213
1223
  var buildResourceSpec = (config, defaults) => {
1214
1224
  const resources = config ?? defaults ?? CADDY_DEFAULTS.resources;
1215
1225
  return {
@@ -1224,9 +1234,9 @@ var generateCaddyfile = (config) => {
1224
1234
  }`;
1225
1235
  const blocks = [
1226
1236
  generateGlobalBlock(config),
1227
- ...config.routes.map(generateRouteBlock),
1237
+ ...config.routes.map((route) => generateRouteBlock(route, config.encode)),
1228
1238
  healthCheckBlock,
1229
- ...config.catchAllUpstream && config.onDemandTls ? [generateCatchAllBlock(config.catchAllUpstream)] : []
1239
+ ...config.catchAllUpstream && config.onDemandTls ? [generateCatchAllBlock(config.catchAllUpstream, config.encode)] : []
1230
1240
  ];
1231
1241
  return blocks.join(`
1232
1242
 
@@ -1239,6 +1249,7 @@ var deployCaddy = (provider, namespace, config) => {
1239
1249
  const healthCheck = config.healthCheck ?? CADDY_DEFAULTS.healthCheck;
1240
1250
  const storage = config.storage ?? CADDY_DEFAULTS.storage;
1241
1251
  const caddyfile = generateCaddyfile(config);
1252
+ const caddyfileHash = import_node_crypto.createHash("sha256").update(caddyfile).digest("hex").slice(0, 16);
1242
1253
  const configMap = new k8s5.core.v1.ConfigMap(name, {
1243
1254
  metadata: { name, namespace, labels },
1244
1255
  data: { Caddyfile: caddyfile }
@@ -1282,7 +1293,10 @@ var deployCaddy = (provider, namespace, config) => {
1282
1293
  strategy: { type: "Recreate" },
1283
1294
  selector: { matchLabels: { app: name } },
1284
1295
  template: {
1285
- metadata: { labels },
1296
+ metadata: {
1297
+ labels,
1298
+ annotations: { "checksum/caddyfile": caddyfileHash }
1299
+ },
1286
1300
  spec: {
1287
1301
  containers,
1288
1302
  ...config.imagePullSecretName && {
package/dist/index.js CHANGED
@@ -1038,6 +1038,7 @@ var materializeStreams = (provider, namespace, config) => {
1038
1038
  return job;
1039
1039
  };
1040
1040
  // lib/runtimes/doks/caddy.ts
1041
+ import { createHash } from "node:crypto";
1041
1042
  import * as k8s5 from "@pulumi/kubernetes";
1042
1043
  var CADDY_DEFAULTS = {
1043
1044
  resources: {
@@ -1075,8 +1076,11 @@ var generateHandleBlock = (handle, level, basicAuth) => {
1075
1076
  ${inner}
1076
1077
  }`, level);
1077
1078
  };
1078
- var generateRouteBlock = (route) => {
1079
+ var generateRouteBlock = (route, encode) => {
1079
1080
  const body = [];
1081
+ if (!route.redirect && encode?.length) {
1082
+ body.push(` encode ${encode.join(" ")}`);
1083
+ }
1080
1084
  if (route.handles && route.handles.length > 0) {
1081
1085
  for (const handle of route.handles) {
1082
1086
  body.push(generateHandleBlock(handle, 1, route.basicAuth));
@@ -1112,8 +1116,14 @@ var generateGlobalBlock = (config) => {
1112
1116
  return lines.join(`
1113
1117
  `);
1114
1118
  };
1115
- var generateCatchAllBlock = (upstream) => ["https:// {", " tls {", " on_demand", " }", ` reverse_proxy ${upstream}`, "}"].join(`
1119
+ var generateCatchAllBlock = (upstream, encode) => {
1120
+ const lines = ["https:// {", " tls {", " on_demand", " }"];
1121
+ if (encode?.length)
1122
+ lines.push(` encode ${encode.join(" ")}`);
1123
+ lines.push(` reverse_proxy ${upstream}`, "}");
1124
+ return lines.join(`
1116
1125
  `);
1126
+ };
1117
1127
  var buildResourceSpec = (config, defaults) => {
1118
1128
  const resources = config ?? defaults ?? CADDY_DEFAULTS.resources;
1119
1129
  return {
@@ -1128,9 +1138,9 @@ var generateCaddyfile = (config) => {
1128
1138
  }`;
1129
1139
  const blocks = [
1130
1140
  generateGlobalBlock(config),
1131
- ...config.routes.map(generateRouteBlock),
1141
+ ...config.routes.map((route) => generateRouteBlock(route, config.encode)),
1132
1142
  healthCheckBlock,
1133
- ...config.catchAllUpstream && config.onDemandTls ? [generateCatchAllBlock(config.catchAllUpstream)] : []
1143
+ ...config.catchAllUpstream && config.onDemandTls ? [generateCatchAllBlock(config.catchAllUpstream, config.encode)] : []
1134
1144
  ];
1135
1145
  return blocks.join(`
1136
1146
 
@@ -1143,6 +1153,7 @@ var deployCaddy = (provider, namespace, config) => {
1143
1153
  const healthCheck = config.healthCheck ?? CADDY_DEFAULTS.healthCheck;
1144
1154
  const storage = config.storage ?? CADDY_DEFAULTS.storage;
1145
1155
  const caddyfile = generateCaddyfile(config);
1156
+ const caddyfileHash = createHash("sha256").update(caddyfile).digest("hex").slice(0, 16);
1146
1157
  const configMap = new k8s5.core.v1.ConfigMap(name, {
1147
1158
  metadata: { name, namespace, labels },
1148
1159
  data: { Caddyfile: caddyfile }
@@ -1186,7 +1197,10 @@ var deployCaddy = (provider, namespace, config) => {
1186
1197
  strategy: { type: "Recreate" },
1187
1198
  selector: { matchLabels: { app: name } },
1188
1199
  template: {
1189
- metadata: { labels },
1200
+ metadata: {
1201
+ labels,
1202
+ annotations: { "checksum/caddyfile": caddyfileHash }
1203
+ },
1190
1204
  spec: {
1191
1205
  containers,
1192
1206
  ...config.imagePullSecretName && {
@@ -459,6 +459,8 @@ export interface CaddyConfig {
459
459
  port: number;
460
460
  path: string;
461
461
  };
462
+ /** Response encoding (e.g., ['zstd', 'gzip']). Omit to disable. */
463
+ encode?: string[];
462
464
  }
463
465
  export interface CaddyResult {
464
466
  /** The Kubernetes Deployment */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossdelta/infrastructure",
3
- "version": "0.11.3",
3
+ "version": "0.11.5",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {