mirror of
https://github.com/morten-olsen/homelab-operator.git
synced 2026-02-08 01:36:28 +01:00
simplify
This commit is contained in:
@@ -10,7 +10,7 @@ type AuthentikServerInfo = {
|
||||
|
||||
type UpsertClientRequest = {
|
||||
name: string;
|
||||
secret: string;
|
||||
secret?: string;
|
||||
scopes?: string[];
|
||||
flows?: {
|
||||
authorization: string;
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import type { V1Deployment } from '@kubernetes/client-node';
|
||||
|
||||
import type { Services } from '../../utils/service.ts';
|
||||
import { ResourceReference } from '../resources/resources.ref.ts';
|
||||
import type { Watcher } from '../watchers/watchers.watcher.ts';
|
||||
import { WatcherService } from '../watchers/watchers.ts';
|
||||
import type { Resource } from '../resources/resources.ts';
|
||||
|
||||
const ISTIO_APP_SELECTOR = 'istio=gateway-controller';
|
||||
|
||||
class IstioService {
|
||||
#gatewayResource: ResourceReference<V1Deployment>;
|
||||
#gatewayWatcher: Watcher<V1Deployment>;
|
||||
|
||||
constructor(services: Services) {
|
||||
this.#gatewayResource = new ResourceReference<V1Deployment>();
|
||||
const watcherService = services.get(WatcherService);
|
||||
this.#gatewayWatcher = watcherService.create({
|
||||
path: '/apis/apps/v1/deployments',
|
||||
list: async (k8s) => {
|
||||
return await k8s.apps.listDeploymentForAllNamespaces({
|
||||
labelSelector: ISTIO_APP_SELECTOR,
|
||||
});
|
||||
},
|
||||
transform: (manifest) => ({
|
||||
apiVersion: 'apps/v1',
|
||||
kind: 'Deployment',
|
||||
...manifest,
|
||||
}),
|
||||
verbs: ['add', 'update', 'delete'],
|
||||
});
|
||||
this.#gatewayWatcher.on('changed', this.#handleChange);
|
||||
}
|
||||
|
||||
#handleChange = (resource: Resource<V1Deployment>) => {
|
||||
this.#gatewayResource.current = resource;
|
||||
};
|
||||
|
||||
public get gateway() {
|
||||
return this.#gatewayResource;
|
||||
}
|
||||
|
||||
public start = async () => {
|
||||
await this.#gatewayWatcher.start();
|
||||
};
|
||||
}
|
||||
|
||||
export { IstioService };
|
||||
Reference in New Issue
Block a user