Show object reference for all objects (#399)

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala authored and GitHub committed 2020-06-04 14:46:43 +03:00
1 parent 00defdd631
commit 65900e728d
4 files changed
+39 -35

No files matched your search

+16
View File
@@ -27,6 +27,14 @@ export interface IKubeObjectMetadata {
annotations?: {
[annotation: string]: string;
};
ownerReferences?: {
apiVersion: string;
kind: string;
name: string;
uid: string;
controller: boolean;
blockOwnerDeletion: boolean;
}[];
}
export type IKubeMetaField = keyof KubeObject["metadata"];
@@ -113,6 +121,14 @@ export class KubeObject implements ItemObject {
})
}
getOwnerRefs() {
const refs = this.metadata.ownerReferences || [];
return refs.map(ownerRef => ({
...ownerRef,
namespace: this.getNs(),
}))
}
getSearchFields() {
const { getName, getId, getNs, getAnnotations, getLabels } = this
return [
@@ -47,28 +47,10 @@ export interface IAffinity {
}
export class WorkloadKubeObject extends KubeObject {
metadata: IKubeObjectMetadata & {
ownerReferences?: {
apiVersion: string;
kind: string;
name: string;
uid: string;
controller: boolean;
blockOwnerDeletion: boolean;
}[];
}
// fixme: add type
spec: any;
getOwnerRefs() {
const refs = this.metadata.ownerReferences || [];
return refs.map(ownerRef => ({
...ownerRef,
namespace: this.getNs(),
}))
}
getSelectors(): string[] {
const selector = this.spec.selector;
return KubeObject.stringifyLabels(selector ? selector.matchLabels : null);