@yunuseon/kayra 0.19.0 → 0.20.0
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/agent/skills/kayra-release/SKILL.md +1 -4
- package/agent/skills/kayra-rollout/SKILL.md +1 -4
- package/ansible/roles/app/tasks/main.yml +22 -0
- package/ansible/roles/platform/defaults/main.yml +3 -0
- package/ansible/roles/platform/tasks/main.yml +6 -86
- package/ansible/roles/platform/templates/platform.env.j2 +2 -0
- package/bin/kayra-app-hook.js +6 -0
- package/bin/kayra-app-init.js +6 -0
- package/bin/kayra-app-launch.js +6 -0
- package/bin/kayra-app-values.js +6 -0
- package/cli/dist/app-hook.js +75 -0
- package/cli/dist/app-init.js +65 -0
- package/cli/dist/app-launch.js +89 -0
- package/cli/dist/app-values.js +37 -0
- package/cli/dist/browser/assets/ibm-plex-sans-cyrillic-400-normal-BTotfTJu.woff +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-cyrillic-400-normal-DZqxrq2p.woff2 +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-cyrillic-600-normal-71GNu3SW.woff2 +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-cyrillic-600-normal-BGq0mW3O.woff +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-cyrillic-ext-400-normal-Dsrv2Tcn.woff +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-cyrillic-ext-400-normal-g30qAdWV.woff2 +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-cyrillic-ext-600-normal-Bz0x94Yp.woff +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-cyrillic-ext-600-normal-DUMzJB7m.woff2 +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-greek-400-normal-D9ESIMu3.woff +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-greek-400-normal-_efipK4i.woff2 +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-greek-600-normal-D-CqTdkO.woff +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-greek-600-normal-DzTrcv_p.woff2 +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-latin-ext-400-normal-C5H60-Va.woff2 +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-latin-ext-400-normal-RBey6euL.woff +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-latin-ext-600-normal-DIrixKbi.woff +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-latin-ext-600-normal-DOrvGEcy.woff2 +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-vietnamese-400-normal-DG4YqDda.woff2 +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-vietnamese-400-normal-fK1oJ5dG.woff +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-vietnamese-600-normal-DgdngZtN.woff +0 -0
- package/cli/dist/browser/assets/ibm-plex-sans-vietnamese-600-normal-DpPYBSTl.woff2 +0 -0
- package/cli/dist/browser/assets/index-DzIVPXyL.css +1 -0
- package/cli/dist/browser/assets/index-SP8bCDrl.js +7 -0
- package/cli/dist/browser/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-cyrillic-500-normal-DJqRU3vO.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-cyrillic-500-normal-DmUKJPL_.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-cyrillic-600-normal-8K4wrrwR.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-cyrillic-600-normal-EVf6-Yzo.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-cyrillic-700-normal-BWTpRfYl.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-cyrillic-700-normal-CEoEElIJ.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-greek-500-normal-D7SFKleX.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-greek-500-normal-JpySY46c.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-greek-600-normal-H7WoG9Et.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-greek-600-normal-mc2nkWzM.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-greek-700-normal-C6CZE3T8.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-greek-700-normal-DEigVDxa.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-600-normal-BfsvjouI.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-700-normal-BYuf6tUa.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-700-normal-D3wTyLJW.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-ext-500-normal-ckzbgY84.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-ext-600-normal-DObL3zCW.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-ext-700-normal-CZipNAKV.woff2 +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-latin-ext-700-normal-CxPITLHs.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-vietnamese-500-normal-DNRqzVM1.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-vietnamese-600-normal-OWROknRo.woff +0 -0
- package/cli/dist/browser/assets/jetbrains-mono-vietnamese-700-normal-BDLVIk2r.woff +0 -0
- package/cli/dist/browser/index.html +10 -3
- package/cli/dist/clients/api/start.js +1 -1
- package/cli/dist/clients/cli/invocation.js +25 -0
- package/cli/dist/clients/cli/parser.js +24 -7
- package/cli/dist/clients/cli/text.js +3 -3
- package/cli/dist/clients/cli/values.js +0 -1
- package/cli/dist/clients/cli/views.js +9 -2
- package/cli/dist/clients/mcp/tools.js +8 -1
- package/cli/dist/clients/ui/assets.js +1 -0
- package/cli/dist/clients/wire/contract.js +2 -2
- package/cli/dist/clients/wire/queries.js +1 -0
- package/cli/dist/clients/wire/schemas.js +4 -1
- package/cli/dist/clients/wire/words.js +14 -0
- package/cli/dist/core/adapters/opentofu.js +1 -1
- package/cli/dist/core/app-hook/hooks.js +90 -0
- package/cli/dist/core/app-hook/token.js +49 -0
- package/cli/dist/core/app-init/plan.js +208 -0
- package/cli/dist/core/app-values/model.js +45 -0
- package/cli/dist/core/app-values/store.js +124 -0
- package/cli/dist/core/ctl/answers.js +14 -9
- package/cli/dist/core/fleet/brand.js +10 -12
- package/cli/dist/core/fleet/settings.js +14 -9
- package/cli/dist/core/operations/catalog.js +46 -1
- package/cli/dist/core/operations/dispatch.js +37 -6
- package/cli/dist/core/recipes/app-check.js +14 -1
- package/cli/dist/core/recipes/app-hook.js +26 -0
- package/cli/dist/core/recipes/app-values.js +21 -0
- package/cli/dist/core/recipes/doctor.js +2 -2
- package/cli/dist/core/recipes/launch.js +51 -0
- package/cli/dist/core/validation/facts.js +1 -3
- package/cli/dist/deployer/brand.js +8 -5
- package/cli/dist/deployer/build/builder.js +10 -4
- package/cli/dist/deployer/build/client.js +44 -0
- package/cli/dist/deployer/build/routes.js +27 -6
- package/cli/dist/deployer/ctl/answers.js +6 -2
- package/cli/dist/deployer/ctl/ctl.js +66 -9
- package/cli/dist/deployer/deployer.js +113 -196
- package/cli/dist/deployer/forges/forge.js +0 -12
- package/cli/dist/deployer/forges/notify.js +3 -3
- package/cli/dist/deployer/http/http.js +0 -1
- package/cli/dist/deployer/http/page.js +4 -2
- package/cli/dist/deployer/http/webhook.js +0 -1
- package/cli/dist/deployer/runs/effects.js +70 -0
- package/cli/dist/deployer/runs/queue.js +5 -4
- package/cli/dist/deployer/runs/records.js +22 -3
- package/cli/dist/deployer/runs/restore.js +6 -0
- package/cli/dist/deployer/runs/run.js +51 -5
- package/cli/dist/deployer/runs/store.js +19 -3
- package/cli/dist/deployer/settings.js +69 -0
- package/cli/dist/lib/forge-repo.js +15 -0
- package/cli/dist/lib/names.js +13 -0
- package/cli/dist/main.js +46 -25
- package/compose/docker-compose.ci.yml +2 -0
- package/package.json +2 -2
- package/schema/app.json +5 -0
- package/schema/defaults.json +8 -0
- package/schema/vars-platform.json +8 -0
- package/scripts/local/verify.sh +9 -2
- package/terraform/modules/platform-dns/main.tf +66 -0
- package/terraform/modules/platform-dns/outputs.tf +9 -0
- package/terraform/modules/platform-dns/tests/fleet/.cache/apps/blog/site/app.yml +3 -0
- package/terraform/modules/platform-dns/tests/fleet/.cache/apps/shop/app.yml +6 -0
- package/terraform/modules/platform-dns/tests/fleet/servers/nested/server.yml +6 -0
- package/terraform/modules/platform-dns/tests/fleet/servers/shop/server.yml +7 -0
- package/terraform/modules/platform-dns/tests/fleet/servers/uncloned/server.yml +6 -0
- package/terraform/modules/platform-dns/tests/platform-dns.tftest.hcl +64 -0
- package/terraform/modules/platform-dns/variables.tf +25 -0
- package/cli/dist/browser/assets/index-C4HCL022.js +0 -7
- package/cli/dist/browser/assets/index-Ct0Eudk4.css +0 -1
- package/scripts/agent/guard.sh +0 -125
|
@@ -1,8 +1,45 @@
|
|
|
1
1
|
import { err, ok } from "../../lib/result.js";
|
|
2
2
|
import { imagesEnv, parseBundle } from "../build/bundle.js";
|
|
3
3
|
import { config, policy, up } from "../build/compose.js";
|
|
4
|
-
import { describeRoutes, routesOverride } from "../build/routes.js";
|
|
4
|
+
import { describeRoutes, readinessUrl, routesOverride } from "../build/routes.js";
|
|
5
5
|
import { typed } from "../../lib/typed.js";
|
|
6
|
+
/** How often, and how far apart, a URL is asked before it counts as not ready: a minute. */
|
|
7
|
+
const tries = 30;
|
|
8
|
+
const apart = 2_000;
|
|
9
|
+
/** Traefik answers 404 until it has seen the new containers; without a check path, a 404 counts only after this many tries. */
|
|
10
|
+
const routerGrace = 5;
|
|
11
|
+
/**
|
|
12
|
+
* Whether a URL is ready. With a check path: 2xx or 3xx. Without one, the
|
|
13
|
+
* app owes no particular answer, only one below 500.
|
|
14
|
+
*/
|
|
15
|
+
const passes = (status, strict, attempt) => strict ? status >= 200 && status < 400 : status > 0 && status < 500 && (status !== 404 || attempt >= routerGrace);
|
|
16
|
+
const probeUntil = async (fx, url, strict, attempt = 1) => {
|
|
17
|
+
const status = await fx.probe(url);
|
|
18
|
+
if (passes(status, strict, attempt))
|
|
19
|
+
return { url, status, ok: true };
|
|
20
|
+
if (attempt >= tries)
|
|
21
|
+
return { url, status, ok: false };
|
|
22
|
+
await fx.pause(apart);
|
|
23
|
+
return probeUntil(fx, url, strict, attempt + 1);
|
|
24
|
+
};
|
|
25
|
+
/** Each route asked through Traefik, once per URL; a URL some route gave a check path for is held to it. */
|
|
26
|
+
const readiness = async (routes, domain, fx) => {
|
|
27
|
+
const urls = [...new Set(routes.map((route) => readinessUrl(route, domain)))];
|
|
28
|
+
const strict = (url) => routes.some((route) => route.check !== undefined && readinessUrl(route, domain) === url);
|
|
29
|
+
if (urls.length > 0)
|
|
30
|
+
fx.log(`── Ready? ${urls.join(", ")}`);
|
|
31
|
+
const checks = await Promise.all(urls.map((url) => probeUntil(fx, url, strict(url))));
|
|
32
|
+
checks.forEach((check) => {
|
|
33
|
+
fx.log(`${check.ok ? "ready" : "NOT READY"} ${check.url} ${check.status === 0 ? "no answer" : String(check.status)}`);
|
|
34
|
+
});
|
|
35
|
+
return Object.freeze(checks);
|
|
36
|
+
};
|
|
37
|
+
/** Where the app answers: each routed host once. */
|
|
38
|
+
const appUrls = (routes, domain) => Object.freeze([...new Set(routes.map((route) => `https://${route.host}.${domain}/`))]);
|
|
39
|
+
const notReady = (checks) => checks
|
|
40
|
+
.filter((check) => !check.ok)
|
|
41
|
+
.map((check) => `${check.url} ${check.status === 0 ? "did not answer" : `answered ${String(check.status)}`}`)
|
|
42
|
+
.join("; ");
|
|
6
43
|
const step = async (fx, label, argv, options) => {
|
|
7
44
|
fx.log(`── ${label}`);
|
|
8
45
|
const exit = await fx.exec(argv, options);
|
|
@@ -46,7 +83,7 @@ export const deploy = async (app, ref, site, fx) => {
|
|
|
46
83
|
const commit = await fx.resolve(app, ref);
|
|
47
84
|
if (!commit.ok) {
|
|
48
85
|
fx.log(commit.error);
|
|
49
|
-
return typed({ ok: false });
|
|
86
|
+
return typed({ ok: false, error: commit.error });
|
|
50
87
|
}
|
|
51
88
|
const sha = commit.value;
|
|
52
89
|
fx.log(`── ${ref} is ${sha}`);
|
|
@@ -56,7 +93,7 @@ export const deploy = async (app, ref, site, fx) => {
|
|
|
56
93
|
if (!bundle.ok) {
|
|
57
94
|
fx.log(bundle.error);
|
|
58
95
|
await fx.status(app, sha, "kayra/build", "failure", "Build failed");
|
|
59
|
-
return typed({ ok: false, sha });
|
|
96
|
+
return typed({ ok: false, sha, error: `build: ${bundle.error}` });
|
|
60
97
|
}
|
|
61
98
|
await fx.status(app, sha, "kayra/build", "success", "Images built");
|
|
62
99
|
await fx.status(app, sha, "kayra/deploy", "pending", "Deploying");
|
|
@@ -64,11 +101,20 @@ export const deploy = async (app, ref, site, fx) => {
|
|
|
64
101
|
if (!deployed.ok) {
|
|
65
102
|
fx.log(deployed.error);
|
|
66
103
|
await fx.status(app, sha, "kayra/deploy", "failure", deployed.error);
|
|
67
|
-
return typed({ ok: false, sha });
|
|
104
|
+
return typed({ ok: false, sha, error: deployed.error });
|
|
105
|
+
}
|
|
106
|
+
const urls = appUrls(bundle.value.routes, site.domain);
|
|
107
|
+
const checks = await readiness(bundle.value.routes, site.domain, fx);
|
|
108
|
+
const unready = notReady(checks);
|
|
109
|
+
if (unready !== "") {
|
|
110
|
+
const error = `running, but not ready: ${unready}`;
|
|
111
|
+
fx.log(error);
|
|
112
|
+
await fx.status(app, sha, "kayra/deploy", "failure", "Not ready");
|
|
113
|
+
return typed({ ok: false, sha, error, urls, checks });
|
|
68
114
|
}
|
|
69
115
|
fx.log(`Deployed ${sha}`);
|
|
70
116
|
await fx.status(app, sha, "kayra/deploy", "success", "Deployed");
|
|
71
|
-
return typed({ ok: true, sha });
|
|
117
|
+
return typed({ ok: true, sha, urls, checks });
|
|
72
118
|
};
|
|
73
119
|
/** Renovate's settings, as the platform's .env holds them; the optional ones only when set. */
|
|
74
120
|
export const renovate = (env, dryRun, image) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
1
|
+
import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { owner as mintOwner, runId } from "../brand.js";
|
|
4
|
-
import { parseMeta } from "./records.js";
|
|
4
|
+
import { expired, parseMeta } from "./records.js";
|
|
5
5
|
import { typed } from "../../lib/typed.js";
|
|
6
|
-
/**
|
|
6
|
+
/** runs/: <owner>/<id>/{meta.json,log}. Only the deployer writes there; the builder's pages and ctl read it. */
|
|
7
7
|
const entries = (dir) => (existsSync(dir) ? readdirSync(dir).toSorted() : typed([]));
|
|
8
8
|
export const owners = (runs) => Object.freeze(entries(runs).flatMap((name) => {
|
|
9
9
|
const minted = mintOwner(name);
|
|
@@ -30,3 +30,19 @@ export const log = (runs, who, id) => {
|
|
|
30
30
|
const path = join(runs, who, id, "log");
|
|
31
31
|
return existsSync(path) ? readFileSync(path, "utf8") : undefined;
|
|
32
32
|
};
|
|
33
|
+
/** A run's meta.json, as it begins and again as it ends. */
|
|
34
|
+
export const writeMeta = (runs, who, run) => {
|
|
35
|
+
const dir = join(runs, who, run.id);
|
|
36
|
+
mkdirSync(dir, { recursive: true });
|
|
37
|
+
writeFileSync(join(dir, "meta.json"), JSON.stringify(run));
|
|
38
|
+
};
|
|
39
|
+
/** A line of a run's log, stamped with the time of day. */
|
|
40
|
+
export const appendLog = (runs, who, id, line) => {
|
|
41
|
+
appendFileSync(join(runs, who, id, "log"), `${new Date().toISOString().slice(11, 19)} ${line}\n`);
|
|
42
|
+
};
|
|
43
|
+
/** An owner's runs beyond the newest `keep`, gone. */
|
|
44
|
+
export const prune = (runs, who, keep) => {
|
|
45
|
+
expired(readdirSync(join(runs, who)), keep).forEach((old) => {
|
|
46
|
+
rmSync(join(runs, who, old), { recursive: true, force: true });
|
|
47
|
+
});
|
|
48
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { err, ok } from "../lib/result.js";
|
|
4
|
+
import { parseCron } from "./cron.js";
|
|
5
|
+
import { githubIssues } from "./forges/issues.js";
|
|
6
|
+
import { parseNotify, silent } from "./forges/notify.js";
|
|
7
|
+
import { typed } from "../lib/typed.js";
|
|
8
|
+
/** Mounted into the deployer only: the platform's tokens, each app's secrets, the notifier's key. */
|
|
9
|
+
export const mounts = { platform: "/run/platform-secrets", apps: "/run/app-secrets", deployer: "/run/deployer-secrets" };
|
|
10
|
+
/** A platform token, read on every use: a new one needs no restart. */
|
|
11
|
+
export const token = (name) => {
|
|
12
|
+
const path = join(mounts.platform, name);
|
|
13
|
+
return existsSync(path) ? readFileSync(path, "utf8").trim() : "";
|
|
14
|
+
};
|
|
15
|
+
const must = (result) => {
|
|
16
|
+
if (!result.ok)
|
|
17
|
+
throw new Error(result.error);
|
|
18
|
+
return result.value;
|
|
19
|
+
};
|
|
20
|
+
/** The configured notifier; its open alerts are kept in <platformDir>/alerts/<key>. */
|
|
21
|
+
const notifierFor = (config, platformDir) => {
|
|
22
|
+
if (config.kind === "none")
|
|
23
|
+
return silent;
|
|
24
|
+
const alerts = join(platformDir, "alerts");
|
|
25
|
+
const keyFile = join(mounts.deployer, "NOTIFIER_GITHUB_APP_KEY");
|
|
26
|
+
return githubIssues(config.repository, config.appId, {
|
|
27
|
+
fetch: async (url, init) => {
|
|
28
|
+
const response = await fetch(url, init);
|
|
29
|
+
const json = await response.json().catch(() => undefined);
|
|
30
|
+
return Object.freeze({ status: response.status, json });
|
|
31
|
+
},
|
|
32
|
+
privateKey: () => (existsSync(keyFile) ? ok(readFileSync(keyFile, "utf8")) : err(`${keyFile} is missing: notifier_github_app_key in secrets.yml`)),
|
|
33
|
+
now: () => Date.now(),
|
|
34
|
+
openIssue: (key) => {
|
|
35
|
+
const path = join(alerts, key);
|
|
36
|
+
const number = existsSync(path) ? Number(readFileSync(path, "utf8")) : Number.NaN;
|
|
37
|
+
return Number.isInteger(number) ? number : undefined;
|
|
38
|
+
},
|
|
39
|
+
remember: (key, issue) => {
|
|
40
|
+
mkdirSync(alerts, { recursive: true });
|
|
41
|
+
if (issue === undefined)
|
|
42
|
+
rmSync(join(alerts, key), { force: true });
|
|
43
|
+
else
|
|
44
|
+
writeFileSync(join(alerts, key), String(issue));
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
export const settings = (env) => {
|
|
49
|
+
const scripts = env["PLATFORM_SCRIPTS"] ?? "/opt/kayra/scripts/platform";
|
|
50
|
+
const platformDir = env["PLATFORM_DIR"] ?? "/opt/platform";
|
|
51
|
+
const strings = Object.fromEntries(Object.entries(env).flatMap(([key, value]) => typed(value === undefined ? [] : [[key, value]])));
|
|
52
|
+
return typed({
|
|
53
|
+
platformDir,
|
|
54
|
+
appsDir: env["APPS_DIR"] ?? "/opt/apps",
|
|
55
|
+
builder: env["BUILDER_URL"] ?? "http://builder:8081",
|
|
56
|
+
domain: env["DOMAIN"] ?? "localhost",
|
|
57
|
+
policyScript: join(scripts, "compose-policy.sh"),
|
|
58
|
+
gcScript: join(scripts, "registry-gc.sh"),
|
|
59
|
+
renovateImage: env["RENOVATE_IMAGE"] ?? "",
|
|
60
|
+
renovate: env["PLATFORM_RENOVATE"] === "true" ? must(parseCron(env["RENOVATE_SCHEDULE"] ?? "0 4 * * 1")) : undefined,
|
|
61
|
+
gc: must(parseCron("0 3 * * *")),
|
|
62
|
+
poll: must(parseCron(env["DEPLOY_POLL"] ?? "17 * * * *")),
|
|
63
|
+
env: strings,
|
|
64
|
+
server: env["SERVER"] ?? env["DOMAIN"] ?? "this server",
|
|
65
|
+
notifier: notifierFor(must(parseNotify(env["NOTIFIER"])), platformDir),
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
/** Where runs/ is: <owner>/<id>/{meta.json,log}. */
|
|
69
|
+
export const runsDir = (s) => join(s.platformDir, "runs");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { typed } from "./typed.js";
|
|
2
|
+
const kinds = { "https://github.com": "github", "https://gitlab.com": "gitlab" };
|
|
3
|
+
/**
|
|
4
|
+
* GitHub for https://github.com, GitLab for https://gitlab.com, a Forgejo for any other host; undefined for a URL none understands.
|
|
5
|
+
* The deployer (statuses, webhook signatures) and kayra (setting up those webhooks) read a repository the same way.
|
|
6
|
+
*/
|
|
7
|
+
export const forgeRepo = (repo) => {
|
|
8
|
+
const match = /^(https?:\/\/[^/]+)\/(.+)\/([^/]+?)(\.git)?\/?$/.exec(repo);
|
|
9
|
+
if (match === null)
|
|
10
|
+
return undefined;
|
|
11
|
+
const [, origin, owner, name] = match;
|
|
12
|
+
if (origin === undefined || owner === undefined || name === undefined)
|
|
13
|
+
return undefined;
|
|
14
|
+
return typed({ kind: kinds[origin] ?? "forgejo", origin, owner, name });
|
|
15
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules names follow on both sides: the fleet's schemas (core/fleet/brand.ts)
|
|
3
|
+
* and the deployer's constructors (deployer/brand.ts), which may not import zod.
|
|
4
|
+
*/
|
|
5
|
+
export const names = {
|
|
6
|
+
app: { pattern: /^[a-z][a-z0-9-]*$/, what: "an app name (lowercase letters, digits, dashes)" },
|
|
7
|
+
subdomain: { pattern: /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/, what: "a subdomain" },
|
|
8
|
+
/** A route's path prefix: no backtick, quote or `$`, so it cannot leave its Traefik rule or meet Compose's interpolation. */
|
|
9
|
+
routePath: { pattern: /^\/[A-Za-z0-9._~%/-]*$/, what: "a path (/, then letters, digits and ._~%/-)" },
|
|
10
|
+
serviceName: { pattern: /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/, what: "a compose service name" },
|
|
11
|
+
/** A Traefik duration. */
|
|
12
|
+
period: { pattern: /^[1-9][0-9]*(ms|s|m|h)$/, what: "a period such as 10s, 10m or 1h" },
|
|
13
|
+
};
|
package/cli/dist/main.js
CHANGED
|
@@ -82,7 +82,7 @@ const execute = async (steps, about, framing) => {
|
|
|
82
82
|
process.exitCode = interrupt.signal.aborted ? 130 : passed ? 0 : 1;
|
|
83
83
|
};
|
|
84
84
|
const found = flatMap(findFleetRoot(here.value), loadFleet);
|
|
85
|
-
// Outside a fleet only what works in an app's repository runs (app check).
|
|
85
|
+
// Outside a fleet only what works in an app's repository runs (app init, app check).
|
|
86
86
|
const fleet = found.ok ? found.value : { root: fleetRoot(here.value), servers: [] };
|
|
87
87
|
const args = run(parser(fleet), runOptions(version));
|
|
88
88
|
const short = shortener([
|
|
@@ -138,30 +138,51 @@ else {
|
|
|
138
138
|
else
|
|
139
139
|
await execute(steps.value, invocation(target), operation.bare !== true);
|
|
140
140
|
}
|
|
141
|
-
else if (call.name === "status") {
|
|
142
|
-
const { offline } = call.input;
|
|
143
|
-
const { initial, updates } = stream(context, "status", call.input);
|
|
144
|
-
// On a terminal the table is there at once, its cells filled in as the answers arrive; the report itself goes to stdout.
|
|
145
|
-
const draw = (looks, frame) => Object.freeze(statusView(looks, { frame, room: screens.err.columns - 1, offline }).map((line) => paint(truncate(line, screens.err.columns - 1), screens.err.colors)));
|
|
146
|
-
const looks = !json && screens.out.live && screens.err.live
|
|
147
|
-
? await watch((raw) => process.stderr.write(raw), initial, updates, draw)
|
|
148
|
-
: await settle(initial, updates);
|
|
149
|
-
(json
|
|
150
|
-
? [JSON.stringify(statusJson(looks), null, 2)]
|
|
151
|
-
: statusView(looks, { frame: "", room: screens.out.live ? screens.out.columns : Infinity, offline })).forEach(io.out);
|
|
152
|
-
}
|
|
153
|
-
else if (call.name === "validate") {
|
|
154
|
-
const reports = await query(context, "validate", call.input);
|
|
155
|
-
if (!reports.ok)
|
|
156
|
-
fail(reports.error);
|
|
157
|
-
else {
|
|
158
|
-
(json ? [JSON.stringify(validateJson(reports.value), null, 2)] : validateView(reports.value)).forEach(io.out);
|
|
159
|
-
// eslint-disable-next-line functional/immutable-data -- the exit status; process.exit() could cut piped output short
|
|
160
|
-
process.exitCode = reports.value.some((each) => overall(each.findings) === "problem") ? 1 : 0;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
141
|
else {
|
|
164
|
-
|
|
165
|
-
|
|
142
|
+
switch (call.name) {
|
|
143
|
+
case "status": {
|
|
144
|
+
const { offline } = call.input;
|
|
145
|
+
const { initial, updates } = stream(context, "status", call.input);
|
|
146
|
+
// On a terminal the table is there at once, its cells filled in as the answers arrive; the report itself goes to stdout.
|
|
147
|
+
const draw = (looks, frame) => Object.freeze(statusView(looks, { frame, room: screens.err.columns - 1, offline }).map((line) => paint(truncate(line, screens.err.columns - 1), screens.err.colors)));
|
|
148
|
+
const looks = !json && screens.out.live && screens.err.live
|
|
149
|
+
? await watch((raw) => process.stderr.write(raw), initial, updates, draw)
|
|
150
|
+
: await settle(initial, updates);
|
|
151
|
+
(json
|
|
152
|
+
? [JSON.stringify(statusJson(looks), null, 2)]
|
|
153
|
+
: statusView(looks, { frame: "", room: screens.out.live ? screens.out.columns : Infinity, offline })).forEach(io.out);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
case "app.values": {
|
|
157
|
+
const values = await query(context, "app.values", call.input);
|
|
158
|
+
if (!values.ok)
|
|
159
|
+
fail(values.error);
|
|
160
|
+
else if (json)
|
|
161
|
+
io.out(JSON.stringify(values.value, null, 2));
|
|
162
|
+
else {
|
|
163
|
+
io.out(`${values.value.app} on ${values.value.server} · cached contract: ${values.value.manifest}`);
|
|
164
|
+
values.value.config.forEach((each) => { io.out(`config ${each.key}: ${each.state}`); });
|
|
165
|
+
values.value.secrets.forEach((each) => { io.out(`secret ${each.key}: ${each.state}`); });
|
|
166
|
+
if (values.value.hint !== null)
|
|
167
|
+
io.out(values.value.hint);
|
|
168
|
+
}
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
case "validate": {
|
|
172
|
+
const reports = await query(context, "validate", call.input);
|
|
173
|
+
if (!reports.ok)
|
|
174
|
+
fail(reports.error);
|
|
175
|
+
else {
|
|
176
|
+
(json ? [JSON.stringify(validateJson(reports.value), null, 2)] : validateView(reports.value)).forEach(io.out);
|
|
177
|
+
// eslint-disable-next-line functional/immutable-data -- the exit status; process.exit() could cut piped output short
|
|
178
|
+
process.exitCode = reports.value.some((each) => overall(each.findings) === "problem") ? 1 : 0;
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case "version":
|
|
183
|
+
// Optique answers `kayra version` and `--version` itself, before this.
|
|
184
|
+
io.out(version);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
166
187
|
}
|
|
167
188
|
}
|
|
@@ -66,6 +66,7 @@ services:
|
|
|
66
66
|
command: ["builder"]
|
|
67
67
|
environment:
|
|
68
68
|
- WEBHOOK_SECRET=${WEBHOOK_SECRET:-}
|
|
69
|
+
- WEBHOOKS=${WEBHOOKS:-true}
|
|
69
70
|
- BUILDKIT_HOST=tcp://buildkitd:1234
|
|
70
71
|
- REGISTRY_PUSH_HOST=registry:5000
|
|
71
72
|
volumes:
|
|
@@ -122,6 +123,7 @@ services:
|
|
|
122
123
|
- PLATFORM_DIR=/opt/platform
|
|
123
124
|
- PLATFORM_RENOVATE=${PLATFORM_RENOVATE:-false}
|
|
124
125
|
- RENOVATE_SCHEDULE=${RENOVATE_SCHEDULE:-0 4 * * 1}
|
|
126
|
+
- DEPLOY_POLL=${DEPLOY_POLL:-17 * * * *}
|
|
125
127
|
- RENOVATE_PLATFORM=${RENOVATE_PLATFORM:-github}
|
|
126
128
|
- RENOVATE_ENDPOINT=${RENOVATE_ENDPOINT:-}
|
|
127
129
|
- RENOVATE_GIT_URL=${RENOVATE_GIT_URL:-}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yunuseon/kayra",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "A self-hosted app platform and the CLI that runs it: Traefik, Authelia, a registry, rootless BuildKit and a small deployer per server, set up with OpenTofu and Ansible.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Yunus Öztürk",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"build:web": "npm --prefix web ci --silent && npm --prefix web run build -- --outDir ../cli/dist/browser --emptyOutDir",
|
|
38
38
|
"prepack": "npm run build && npm run build:web",
|
|
39
39
|
"typecheck": "tsc -p cli --noEmit",
|
|
40
|
-
"lint": "cd cli && eslint --flag unstable_native_nodejs_ts_config .",
|
|
40
|
+
"lint": "cd cli && NODE_ENV=test eslint --flag unstable_native_nodejs_ts_config .",
|
|
41
41
|
"test": "node --test 'cli/test/**/*.test.ts'",
|
|
42
42
|
"schemas": "node cli/scripts/schemas.ts",
|
|
43
43
|
"contract": "node cli/scripts/contract.ts",
|
package/schema/app.json
CHANGED
|
@@ -69,6 +69,11 @@
|
|
|
69
69
|
"burst"
|
|
70
70
|
],
|
|
71
71
|
"additionalProperties": false
|
|
72
|
+
},
|
|
73
|
+
"check": {
|
|
74
|
+
"description": "A path that answers 2xx or 3xx once the app is ready; a deploy waits for it. Without one, the route's own path must answer below 500.",
|
|
75
|
+
"type": "string",
|
|
76
|
+
"pattern": "^\\/[A-Za-z0-9._~%/-]*$"
|
|
72
77
|
}
|
|
73
78
|
},
|
|
74
79
|
"required": [
|
package/schema/defaults.json
CHANGED
|
@@ -38,6 +38,14 @@
|
|
|
38
38
|
],
|
|
39
39
|
"description": "Certificates by DNS-01 instead of HTTP-01, for a server the internet never reaches: the DNS provider (hetzner)."
|
|
40
40
|
},
|
|
41
|
+
"webhooks": {
|
|
42
|
+
"type": "boolean",
|
|
43
|
+
"description": "Whether a push webhook may start a deploy at once: true (default) serves deploy.<domain>/hook/<app>; false serves no such endpoint, and pushes deploy by deploy_poll."
|
|
44
|
+
},
|
|
45
|
+
"deploy_poll": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "When the deployer looks for pushes no webhook brought, as a five-field cron spec in the server's time (default hourly: 17 * * * *)."
|
|
48
|
+
},
|
|
41
49
|
"renovate_repositories": {
|
|
42
50
|
"type": "array",
|
|
43
51
|
"items": {
|
|
@@ -38,6 +38,14 @@
|
|
|
38
38
|
],
|
|
39
39
|
"description": "Certificates by DNS-01 instead of HTTP-01, for a server the internet never reaches: the DNS provider (hetzner)."
|
|
40
40
|
},
|
|
41
|
+
"webhooks": {
|
|
42
|
+
"type": "boolean",
|
|
43
|
+
"description": "Whether a push webhook may start a deploy at once: true (default) serves deploy.<domain>/hook/<app>; false serves no such endpoint, and pushes deploy by deploy_poll."
|
|
44
|
+
},
|
|
45
|
+
"deploy_poll": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "When the deployer looks for pushes no webhook brought, as a five-field cron spec in the server's time (default hourly: 17 * * * *)."
|
|
48
|
+
},
|
|
41
49
|
"renovate_repositories": {
|
|
42
50
|
"type": "array",
|
|
43
51
|
"items": {
|
package/scripts/local/verify.sh
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
# browser to the login, not a 403 from rules Authelia never loaded
|
|
10
10
|
# - every certificate is a real one (Let's Encrypt or mkcert), never
|
|
11
11
|
# Traefik's default
|
|
12
|
-
# - an unsigned webhook is refused
|
|
12
|
+
# - an unsigned webhook is refused (with webhooks: false, /hook is not
|
|
13
|
+
# served at all); every app route answers, not 5xx
|
|
13
14
|
# On the server (one SSH call):
|
|
14
15
|
# - every app in server.yml is registered, and nothing else
|
|
15
16
|
# - every app's containers run, none unhealthy; its last run did not fail
|
|
@@ -37,6 +38,8 @@ pass() { echo " ✓ $*"; }
|
|
|
37
38
|
note() { echo " ! $*"; }
|
|
38
39
|
|
|
39
40
|
domain="$(yq -r '.domain' "${dir}/server.yml")"
|
|
41
|
+
# Not yq's `//`: it takes false for missing too.
|
|
42
|
+
webhooks="$( { [ -f "${dir}/vars.yml" ] && yq -r '.webhooks' "${dir}/vars.yml"; } || echo true)"
|
|
40
43
|
inventory="${dir}/inventory.ini"
|
|
41
44
|
[ -f "$inventory" ] || { fail "no inventory for ${name}: provision it first"; exit 1; }
|
|
42
45
|
field() { awk -v key="$1" '{for (i = 1; i <= NF; i++) if (index($i, key "=") == 1) {print substr($i, length(key) + 2); exit}}' "$inventory"; }
|
|
@@ -95,7 +98,11 @@ if [ -n "$first_app" ]; then
|
|
|
95
98
|
-w '%{http_code}' "https://deploy.${domain}/hook/${first_app}" 2>/dev/null || echo 000
|
|
96
99
|
}
|
|
97
100
|
code="$(hook)"
|
|
98
|
-
[ "$
|
|
101
|
+
if [ "$webhooks" = false ]; then
|
|
102
|
+
[ "$code" = 404 ] && pass "webhooks are off: /hook is not served" || fail "webhooks: false, yet /hook/${first_app} answers HTTP ${code}, not 404"
|
|
103
|
+
else
|
|
104
|
+
[ "$code" = 401 ] && pass "an unsigned webhook is refused" || fail "an unsigned webhook to /hook/${first_app}: HTTP ${code}, not 401"
|
|
105
|
+
fi
|
|
99
106
|
while read -r sub path; do
|
|
100
107
|
[ -z "$sub" ] || check "${sub}.${domain}${path%/} answers" "${sub}.${domain}" GET not_5xx "$path"
|
|
101
108
|
done < <(bash "${KAYRA_ROOT}/scripts/local/app-manifests.sh" --routes "$name")
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# A platform server's DNS: an A record for each host it serves, derived from
|
|
3
|
+
# the fleet, never listed by hand. The platform's own subdomains (kayra's
|
|
4
|
+
# hosts.conf) and every route host of every app in server.yml, as the app's
|
|
5
|
+
# app.yml in the fleet's clone (.cache/apps, which kayra doctor fills) says.
|
|
6
|
+
# A new route host in an app is a new record on the next apply.
|
|
7
|
+
# =============================================================================
|
|
8
|
+
|
|
9
|
+
terraform {
|
|
10
|
+
required_version = ">= 1.6.0"
|
|
11
|
+
|
|
12
|
+
required_providers {
|
|
13
|
+
hcloud = {
|
|
14
|
+
source = "hetznercloud/hcloud"
|
|
15
|
+
version = "~> 1.70"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
locals {
|
|
21
|
+
descriptor = yamldecode(file("${var.fleet_root}/servers/${var.server}/server.yml"))
|
|
22
|
+
domain = local.descriptor.domain
|
|
23
|
+
apps = try(local.descriptor.apps, [])
|
|
24
|
+
|
|
25
|
+
manifests = {
|
|
26
|
+
for app in local.apps :
|
|
27
|
+
app.name => "${var.fleet_root}/.cache/apps/${app.name}/${try(app.path, ".")}/app.yml"
|
|
28
|
+
}
|
|
29
|
+
uncloned = [for name, manifest in local.manifests : name if !fileexists(manifest)]
|
|
30
|
+
|
|
31
|
+
platform_subdomains = [
|
|
32
|
+
for line in split("\n", file("${path.module}/../../../hosts.conf")) :
|
|
33
|
+
split(" ", trimspace(line))[0] if trimspace(line) != "" && !startswith(trimspace(line), "#")
|
|
34
|
+
]
|
|
35
|
+
app_subdomains = flatten([
|
|
36
|
+
for name, manifest in local.manifests :
|
|
37
|
+
fileexists(manifest) ? [for route in try(yamldecode(file(manifest)).routes, []) : route.host] : []
|
|
38
|
+
])
|
|
39
|
+
subdomains = toset(concat(local.platform_subdomains, local.app_subdomains))
|
|
40
|
+
|
|
41
|
+
# A host's name in the zone: www under ippo-club.net in ippo-club.net is www;
|
|
42
|
+
# under shop.example.com in example.com it is www.shop.
|
|
43
|
+
suffix = local.domain == var.zone ? "" : trimsuffix(local.domain, ".${var.zone}")
|
|
44
|
+
names = { for sub in local.subdomains : sub => local.suffix == "" ? sub : "${sub}.${local.suffix}" }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
resource "hcloud_zone_rrset" "a" {
|
|
48
|
+
for_each = local.names
|
|
49
|
+
|
|
50
|
+
zone = var.zone
|
|
51
|
+
name = each.value
|
|
52
|
+
type = "A"
|
|
53
|
+
ttl = var.ttl
|
|
54
|
+
records = [{ value = var.address }]
|
|
55
|
+
|
|
56
|
+
lifecycle {
|
|
57
|
+
precondition {
|
|
58
|
+
condition = local.domain == var.zone || endswith(local.domain, ".${var.zone}")
|
|
59
|
+
error_message = "${var.server}'s domain ${local.domain} is not in the zone ${var.zone}."
|
|
60
|
+
}
|
|
61
|
+
precondition {
|
|
62
|
+
condition = length(local.uncloned) == 0
|
|
63
|
+
error_message = "No app.yml in .cache/apps for ${join(", ", local.uncloned)}: run kayra doctor in the fleet, which clones every app, then apply again."
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
output "records" {
|
|
2
|
+
description = "Every A record, its name in the zone => address"
|
|
3
|
+
value = { for sub, rrset in hcloud_zone_rrset.a : rrset.name => var.address }
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
output "hosts" {
|
|
7
|
+
description = "Every host this server serves, fully qualified"
|
|
8
|
+
value = sort([for sub in local.subdomains : "${sub}.${local.domain}"])
|
|
9
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
mock_provider "hcloud" {}
|
|
2
|
+
|
|
3
|
+
variables {
|
|
4
|
+
fleet_root = "./tests/fleet"
|
|
5
|
+
address = "192.0.2.10"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
# The platform's hosts and every app's route hosts, once each.
|
|
9
|
+
run "every_host_once" {
|
|
10
|
+
command = plan
|
|
11
|
+
|
|
12
|
+
variables {
|
|
13
|
+
server = "shop"
|
|
14
|
+
zone = "example.com"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
assert {
|
|
18
|
+
condition = output.hosts == sort(["api.example.com", "auth.example.com", "blog.example.com", "deploy.example.com", "traefik.example.com", "www.example.com"])
|
|
19
|
+
error_message = "Unexpected hosts: ${jsonencode(output.hosts)}"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
assert {
|
|
23
|
+
condition = hcloud_zone_rrset.a["www"].name == "www" && one(hcloud_zone_rrset.a["www"].records).value == "192.0.2.10"
|
|
24
|
+
error_message = "www is not an A record to the server"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
# A server under the zone: its names carry the rest of its domain.
|
|
29
|
+
run "domain_under_the_zone" {
|
|
30
|
+
command = plan
|
|
31
|
+
|
|
32
|
+
variables {
|
|
33
|
+
server = "nested"
|
|
34
|
+
zone = "example.com"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
assert {
|
|
38
|
+
condition = hcloud_zone_rrset.a["www"].name == "www.shop" && hcloud_zone_rrset.a["deploy"].name == "deploy.shop"
|
|
39
|
+
error_message = "Names under shop.example.com in example.com should end in .shop"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
run "domain_outside_the_zone" {
|
|
44
|
+
command = plan
|
|
45
|
+
|
|
46
|
+
variables {
|
|
47
|
+
server = "shop"
|
|
48
|
+
zone = "example.org"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
expect_failures = [hcloud_zone_rrset.a]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# An app the fleet has not cloned: no guessing its hosts, a pointer to kayra doctor.
|
|
55
|
+
run "app_not_cloned" {
|
|
56
|
+
command = plan
|
|
57
|
+
|
|
58
|
+
variables {
|
|
59
|
+
server = "uncloned"
|
|
60
|
+
zone = "example.com"
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
expect_failures = [hcloud_zone_rrset.a]
|
|
64
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
variable "fleet_root" {
|
|
2
|
+
description = "The fleet's directory (the one holding servers/): the module reads servers/<server>/server.yml and each app's app.yml from .cache/apps"
|
|
3
|
+
type = string
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
variable "server" {
|
|
7
|
+
description = "The platform server whose hosts these are"
|
|
8
|
+
type = string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
variable "zone" {
|
|
12
|
+
description = "The DNS zone the records go in: the server's domain, or a domain it is under"
|
|
13
|
+
type = string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
variable "address" {
|
|
17
|
+
description = "The server's IPv4 address, e.g. from its OpenTofu state"
|
|
18
|
+
type = string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
variable "ttl" {
|
|
22
|
+
description = "The records' TTL in seconds"
|
|
23
|
+
type = number
|
|
24
|
+
default = 300
|
|
25
|
+
}
|