This commit is contained in:
Morten Olsen
2025-10-23 13:47:07 +02:00
commit b851dc3006
91 changed files with 7578 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
/node_modules/
/dist/
/coverage/
/.env

View File

@@ -0,0 +1,30 @@
{
"type": "module",
"main": "dist/exports.js",
"scripts": {
"build": "tsc --build",
"test:unit": "vitest --run --passWithNoTests",
"test": "pnpm run \"/^test:/\""
},
"packageManager": "pnpm@10.6.0",
"files": [
"dist"
],
"exports": {
".": "./dist/exports.js"
},
"devDependencies": {
"@types/node": "catalog:",
"@vitest/coverage-v8": "catalog:",
"typescript": "catalog:",
"vitest": "catalog:",
"@morten-olsen/box-configs": "workspace:*",
"@morten-olsen/box-tests": "workspace:*"
},
"dependencies": {
"@morten-olsen/box-k8s": "workspace:*",
"@morten-olsen/box-utils": "workspace:*"
},
"name": "@morten-olsen/box-resource-authentik",
"version": "1.0.0"
}

View File

@@ -0,0 +1,2 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare type ExplicitAny = any;

View File

@@ -0,0 +1,24 @@
import { z } from "@morten-olsen/box-k8s";
const valueOrSecret = z.object({
value: z.string().optional(),
secret: z.string().optional(),
key: z.string().optional(),
});
const serverSpec = z.object({
allowedNamespaces: z.array(z.string()).optional(),
domain: z.string(),
storageClass: z.string().optional(),
redis: z.object({
url: valueOrSecret,
}),
database: z.object({
url: valueOrSecret,
}),
clients: z.object({
substitutions: z.record(z.string(), z.string()).optional()
}).optional(),
});
export { serverSpec };

View File

@@ -0,0 +1,27 @@
import { CustomResource, Secret, type CustomResourceOptions } from "@morten-olsen/box-k8s";
import { serverSpec } from "./server.schemas.js";
import { API_VERSION } from '@morten-olsen/box-utils/consts';
type SecretData = {
secret: string;
};
class AuthentikServer extends CustomResource<typeof serverSpec> {
public static readonly apiVersion = API_VERSION;
public static readonly kind = 'AuthentikServer';
public static readonly spec = serverSpec;
public static readonly scope = 'Namespaced';
#secret: Secret<SecretData>;
constructor(options: CustomResourceOptions<typeof serverSpec>) {
super(options);
this.#secret = this.resources.get(Secret<SecretData>, `${this.name}-secret`, this.namespace);
this.#secret.on('changed', this.queueReconcile);
}
public reconcile = async () => {
};
}
export { AuthentikServer }

View File

@@ -0,0 +1,10 @@
{
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": [
"src/**/*.ts"
],
"extends": "@morten-olsen/box-configs/tsconfig.json"
}

View File

@@ -0,0 +1,12 @@
import { defineConfig } from 'vitest/config';
import { getAliases } from '@morten-olsen/box-tests/vitest';
// eslint-disable-next-line import/no-default-export
export default defineConfig(async () => {
const aliases = await getAliases();
return {
resolve: {
alias: aliases,
},
};
});