alchemy-docker-k3s 0.1.2 → 0.1.4

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.d.mts CHANGED
@@ -33,6 +33,12 @@ interface K3sDefinition {
33
33
  addons?: {
34
34
  traefik?: boolean;
35
35
  metricsServer?: boolean;
36
+ /**
37
+ * Additional Helm values for K3s' bundled Traefik chart, merged into its HelmChartConfig,
38
+ * e.g. `{ ports: { websecure: { transport: { respondingTimeouts: { readTimeout: "30m" } } } } }`.
39
+ * The Hetzner load-balancer annotation the package sets always wins. Requires `traefik`.
40
+ */
41
+ traefikValues?: Record<string, unknown>;
36
42
  };
37
43
  /** K3s' built-in Flannel data plane. @default "vxlan" */
38
44
  flannelBackend?: "vxlan" | "wireguard-native";
@@ -46,6 +52,7 @@ interface NormalizedK3sDefinition {
46
52
  addons: {
47
53
  traefik: boolean;
48
54
  metricsServer: boolean;
55
+ traefikValues: Record<string, unknown>;
49
56
  };
50
57
  flannelBackend: "vxlan" | "wireguard-native";
51
58
  }
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import * as Provider from "alchemy/Provider";
5
5
  import * as Redacted from "effect/Redacted";
6
6
  import { parse } from "yaml";
7
7
  import { chmod, mkdir, writeFile } from "node:fs/promises";
8
- import { dirname, join, resolve } from "node:path";
8
+ import { dirname, join } from "node:path";
9
9
  import { execFile } from "node:child_process";
10
10
  import { promisify } from "node:util";
11
11
  import * as Layer from "effect/Layer";
@@ -60,11 +60,16 @@ const normalizeK3sDefinition = (definition) => {
60
60
  clusterDns: definition.clusterDns ?? "10.43.0.10",
61
61
  addons: {
62
62
  traefik: definition.addons?.traefik ?? true,
63
- metricsServer: definition.addons?.metricsServer ?? true
63
+ metricsServer: definition.addons?.metricsServer ?? true,
64
+ traefikValues: definition.addons?.traefikValues ?? {}
64
65
  },
65
66
  flannelBackend: definition.flannelBackend ?? "vxlan"
66
67
  };
67
68
  if (normalized.flannelBackend !== "vxlan" && normalized.flannelBackend !== "wireguard-native") throw new Error(`flannelBackend must be "vxlan" or "wireguard-native"; received ${JSON.stringify(normalized.flannelBackend)}`);
69
+ const traefikValues = normalized.addons.traefikValues;
70
+ const isJson = (value) => value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value) || Array.isArray(value) && value.every(isJson) || typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype && Object.values(value).every(isJson);
71
+ if (typeof traefikValues !== "object" || traefikValues === null || Array.isArray(traefikValues) || !isJson(traefikValues)) throw new Error("addons.traefikValues must be a plain JSON object of Helm values");
72
+ if (!normalized.addons.traefik && Object.keys(traefikValues).length > 0) throw new Error("addons.traefikValues requires addons.traefik");
68
73
  const ranges = [["clusterCidr", normalized.clusterCidr], ["serviceCidr", normalized.serviceCidr]];
69
74
  for (const [name, cidr] of ranges) if (ipv4CidrRange(cidr) === void 0) throw new Error(`${name} must be an IPv4 CIDR; received ${JSON.stringify(cidr)}`);
70
75
  const clusterRange = ipv4CidrRange(normalized.clusterCidr);
@@ -126,9 +131,16 @@ const resolveChannelVersion = async (channel, fetcher = fetch) => {
126
131
  };
127
132
  //#endregion
128
133
  //#region ../shared/src/kubeconfig.ts
134
+ /**
135
+ * Relative to the directory Alchemy runs from. Alchemy identifies a cluster by
136
+ * its connection's auth, which contains this path, so an absolute path would
137
+ * make every checkout or workspace look like a different cluster and replace
138
+ * everything deployed to it. Reading the cluster rewrites the file wherever
139
+ * Alchemy runs.
140
+ */
129
141
  const kubeconfigPath = (provider, fqn) => {
130
142
  const safe = fqn.replace(/[^a-zA-Z0-9_.-]+/g, "-").replace(/^-|-$/g, "");
131
- return resolve(join(".alchemy", "kubeconfigs", provider, `${safe}.yaml`));
143
+ return join(".alchemy", "kubeconfigs", provider, `${safe}.yaml`);
132
144
  };
133
145
  const writeKubeconfig = async (path, contents) => {
134
146
  await mkdir(dirname(path), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alchemy-docker-k3s",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Persistent local k3d clusters for Alchemy",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",