mirror of
https://github.com/morten-olsen/homelab-operator.git
synced 2026-02-08 01:36:28 +01:00
lot more stuff
This commit is contained in:
37
src/services/watchers/watchers.ts
Normal file
37
src/services/watchers/watchers.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import type { Services } from '../../utils/service.ts';
|
||||
|
||||
import { Watcher, type WatcherOptions } from './watchers.watcher.ts';
|
||||
|
||||
class WatcherService {
|
||||
#services: Services;
|
||||
|
||||
constructor(services: Services) {
|
||||
this.#services = services;
|
||||
}
|
||||
|
||||
public create = (options: Omit<WatcherOptions, 'services'>) => {
|
||||
const instance = new Watcher({
|
||||
...options,
|
||||
services: this.#services,
|
||||
});
|
||||
return instance;
|
||||
};
|
||||
|
||||
public watchCustomGroup = async (group: string, version: string, plurals: string[]) => {
|
||||
for (const plural of plurals) {
|
||||
await this.create({
|
||||
path: `/apis/${group}/${version}/${plural}`,
|
||||
list: async (k8s) => {
|
||||
return await k8s.customObjectsApi.listCustomObjectForAllNamespaces({
|
||||
group,
|
||||
version,
|
||||
plural,
|
||||
});
|
||||
},
|
||||
verbs: ['add', 'update', 'delete'],
|
||||
}).start();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export { WatcherService, Watcher };
|
||||
Reference in New Issue
Block a user