This commit is contained in:
Morten Olsen
2025-08-07 22:21:33 +02:00
parent cfb90f7c9f
commit 9cdbaf7929
25 changed files with 618 additions and 43 deletions

View File

@@ -89,20 +89,18 @@ abstract class CustomResource<TSpec extends ZodObject> extends EventEmitter<Cust
return this.resource.kind;
}
public get metadata() {
public get metadata(): KubernetesObject['metadata'] {
const metadata = this.resource.metadata;
if (!metadata) {
throw new Error('Custom resources needs metadata');
}
return metadata;
return (
metadata || {
name: this.name,
namespace: this.namespace,
}
);
}
public get name() {
const name = this.metadata.name;
if (!name) {
throw new Error('Custom resources needs a name');
}
return name;
return this.resource.specifier.name;
}
public get namespace() {
@@ -130,7 +128,7 @@ abstract class CustomResource<TSpec extends ZodObject> extends EventEmitter<Cust
}
public get isSeen() {
return this.metadata.generation === this.status?.observedGeneration;
return this.metadata?.generation === this.status?.observedGeneration;
}
public get isValidSpec() {
@@ -146,7 +144,7 @@ abstract class CustomResource<TSpec extends ZodObject> extends EventEmitter<Cust
return;
}
await this.patchStatus({
observedGeneration: this.metadata.generation,
observedGeneration: this.metadata?.generation,
});
};

View File

@@ -6,7 +6,7 @@ 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=ingress';
const ISTIO_APP_SELECTOR = 'istio=gateway-controller';
class IstioService {
#gatewayResource: ResourceReference<V1Deployment>;

View File

@@ -33,6 +33,14 @@ class EnsuredSecret<T extends ZodObject> {
this.#handleChanged();
}
public get name() {
return this.#options.name;
}
public get namespace() {
return this.#options.namespace;
}
public get resouce() {
return this.#resource;
}