forked from vscode-kubernetes-tools/vscode-kubernetes-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkuberesources.objectmodel.ts
54 lines (42 loc) · 1.18 KB
/
kuberesources.objectmodel.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
export interface KubernetesResource {
readonly kind: string;
readonly metadata: ObjectMeta;
}
export interface KubernetesCollection<T extends KubernetesResource> {
readonly items: T[];
}
export interface ObjectMeta {
readonly name: string;
readonly namespace?: string;
readonly labels?: KeyValuePairs;
}
export interface KeyValuePairs {
readonly [key: string]: string;
}
export interface DataResource extends KubernetesResource {
readonly data: KeyValuePairs;
}
export interface Namespace extends KubernetesResource {
}
export interface Container {
readonly name: string;
readonly image: string;
}
export interface Pod extends KubernetesResource {
readonly spec: PodSpec;
}
export interface Node extends KubernetesResource {
}
export interface PodSpec {
readonly containers: Container[];
readonly nodeName: string;
}
function isObjectMeta(obj: any): obj is ObjectMeta {
return obj && obj.name;
}
export function isKubernetesResource(obj: any): obj is KubernetesResource {
return obj && obj.kind && isObjectMeta(obj.metadata);
}
export function isPod(obj: any): obj is Pod {
return isKubernetesResource(obj) && obj.kind === 'Pod';
}