feat: scaffold netbird-reconciler project
This commit is contained in:
parent
e2f8e5bd1f
commit
c0953b9ffc
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/data/
|
||||
*.log
|
||||
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
FROM denoland/deno:2.2.2 AS builder
|
||||
WORKDIR /app
|
||||
COPY deno.json .
|
||||
COPY src/ src/
|
||||
RUN deno compile --allow-net --allow-read --allow-write --allow-env --output reconciler src/main.ts
|
||||
|
||||
FROM gcr.io/distroless/cc-debian12
|
||||
COPY --from=builder /app/reconciler /usr/local/bin/reconciler
|
||||
ENTRYPOINT ["reconciler"]
|
||||
18
deno.json
Normal file
18
deno.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "@blastpilot/netbird-reconciler",
|
||||
"version": "0.1.0",
|
||||
"tasks": {
|
||||
"dev": "deno run --allow-net --allow-read --allow-write --allow-env --watch src/main.ts",
|
||||
"start": "deno run --allow-net --allow-read --allow-write --allow-env src/main.ts",
|
||||
"test": "deno test --allow-net --allow-read --allow-write --allow-env",
|
||||
"check": "deno check src/main.ts",
|
||||
"lint": "deno lint",
|
||||
"fmt": "deno fmt"
|
||||
},
|
||||
"imports": {
|
||||
"zod": "npm:zod@^3.23.0"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"strict": true
|
||||
}
|
||||
}
|
||||
16
deno.lock
generated
Normal file
16
deno.lock
generated
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"version": "5",
|
||||
"specifiers": {
|
||||
"npm:zod@^3.23.0": "3.25.76"
|
||||
},
|
||||
"npm": {
|
||||
"zod@3.25.76": {
|
||||
"integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="
|
||||
}
|
||||
},
|
||||
"workspace": {
|
||||
"dependencies": [
|
||||
"npm:zod@^3.23.0"
|
||||
]
|
||||
}
|
||||
}
|
||||
29
src/config.ts
Normal file
29
src/config.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const ConfigSchema = z.object({
|
||||
netbirdApiUrl: z.string().url(),
|
||||
netbirdApiToken: z.string().min(1),
|
||||
giteaUrl: z.string().url(),
|
||||
giteaToken: z.string().min(1),
|
||||
giteaRepo: z.string().regex(/^[^/]+\/[^/]+$/), // owner/repo
|
||||
reconcilerToken: z.string().min(1),
|
||||
pollIntervalSeconds: z.coerce.number().int().positive().default(30),
|
||||
port: z.coerce.number().int().positive().default(8080),
|
||||
dataDir: z.string().default("/data"),
|
||||
});
|
||||
|
||||
export type Config = z.infer<typeof ConfigSchema>;
|
||||
|
||||
export function loadConfig(): Config {
|
||||
return ConfigSchema.parse({
|
||||
netbirdApiUrl: Deno.env.get("NETBIRD_API_URL"),
|
||||
netbirdApiToken: Deno.env.get("NETBIRD_API_TOKEN"),
|
||||
giteaUrl: Deno.env.get("GITEA_URL"),
|
||||
giteaToken: Deno.env.get("GITEA_TOKEN"),
|
||||
giteaRepo: Deno.env.get("GITEA_REPO"),
|
||||
reconcilerToken: Deno.env.get("RECONCILER_TOKEN"),
|
||||
pollIntervalSeconds: Deno.env.get("POLL_INTERVAL_SECONDS"),
|
||||
port: Deno.env.get("PORT"),
|
||||
dataDir: Deno.env.get("DATA_DIR"),
|
||||
});
|
||||
}
|
||||
4
src/main.ts
Normal file
4
src/main.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { loadConfig } from "./config.ts";
|
||||
|
||||
const config = loadConfig();
|
||||
console.log(JSON.stringify({ msg: "starting", port: config.port }));
|
||||
Loading…
x
Reference in New Issue
Block a user