init
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { z } from "@morten-olsen/box-k8s";
|
||||
import { z } from '@morten-olsen/box-k8s';
|
||||
|
||||
const valueOrSecret = z.object({
|
||||
value: z.string().optional(),
|
||||
@@ -16,9 +16,11 @@ const serverSpec = z.object({
|
||||
database: z.object({
|
||||
url: valueOrSecret,
|
||||
}),
|
||||
clients: z.object({
|
||||
substitutions: z.record(z.string(), z.string()).optional()
|
||||
}).optional(),
|
||||
clients: z
|
||||
.object({
|
||||
substitutions: z.record(z.string(), z.string()).optional(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export { serverSpec };
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { CustomResource, Secret, type CustomResourceOptions } from "@morten-olsen/box-k8s";
|
||||
import { serverSpec } from "./server.schemas.js";
|
||||
import { CustomResource, NotReadyError, Secret, type CustomResourceOptions } from '@morten-olsen/box-k8s';
|
||||
import { API_VERSION } from '@morten-olsen/box-utils/consts';
|
||||
|
||||
type SecretData = {
|
||||
secret: string;
|
||||
};
|
||||
import { serverSpec } from './server.schemas.js';
|
||||
|
||||
class AuthentikServer extends CustomResource<typeof serverSpec> {
|
||||
public static readonly apiVersion = API_VERSION;
|
||||
@@ -12,16 +9,30 @@ class AuthentikServer extends CustomResource<typeof serverSpec> {
|
||||
public static readonly spec = serverSpec;
|
||||
public static readonly scope = 'Namespaced';
|
||||
|
||||
#secret: Secret<SecretData>;
|
||||
#secret: Secret;
|
||||
|
||||
constructor(options: CustomResourceOptions<typeof serverSpec>) {
|
||||
super(options);
|
||||
this.#secret = this.resources.get(Secret<SecretData>, `${this.name}-secret`, this.namespace);
|
||||
this.#secret = this.resources.get(Secret, `${this.name}-secret`, this.namespace);
|
||||
this.#secret.on('changed', this.queueReconcile);
|
||||
}
|
||||
|
||||
public reconcile = async () => {
|
||||
if (!this.#secret.value?.secret) {
|
||||
await this.#secret.set(
|
||||
{
|
||||
secret: crypto.randomUUID(),
|
||||
},
|
||||
{
|
||||
metadata: {
|
||||
ownerReferences: [this.ref],
|
||||
},
|
||||
},
|
||||
);
|
||||
throw new NotReadyError();
|
||||
}
|
||||
const { secret } = this.#secret.value;
|
||||
};
|
||||
}
|
||||
|
||||
export { AuthentikServer }
|
||||
export { AuthentikServer };
|
||||
|
||||
1
packages/resource-authentik/tsconfig.tsbuildinfo
Normal file
1
packages/resource-authentik/tsconfig.tsbuildinfo
Normal file
@@ -0,0 +1 @@
|
||||
{"root":["./src/exports.ts","./src/global.d.ts","./src/resources/oidc-client/oidc-client.ts","./src/resources/server/server.schemas.ts","./src/resources/server/server.ts"],"version":"5.9.3"}
|
||||
Reference in New Issue
Block a user