mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Show object reference for all objects (#399)
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
parent
00defdd631
commit
65900e728d
@ -27,6 +27,14 @@ export interface IKubeObjectMetadata {
|
|||||||
annotations?: {
|
annotations?: {
|
||||||
[annotation: string]: string;
|
[annotation: string]: string;
|
||||||
};
|
};
|
||||||
|
ownerReferences?: {
|
||||||
|
apiVersion: string;
|
||||||
|
kind: string;
|
||||||
|
name: string;
|
||||||
|
uid: string;
|
||||||
|
controller: boolean;
|
||||||
|
blockOwnerDeletion: boolean;
|
||||||
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export type IKubeMetaField = keyof KubeObject["metadata"];
|
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() {
|
getSearchFields() {
|
||||||
const { getName, getId, getNs, getAnnotations, getLabels } = this
|
const { getName, getId, getNs, getAnnotations, getLabels } = this
|
||||||
return [
|
return [
|
||||||
|
|||||||
@ -47,28 +47,10 @@ export interface IAffinity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class WorkloadKubeObject extends KubeObject {
|
export class WorkloadKubeObject extends KubeObject {
|
||||||
metadata: IKubeObjectMetadata & {
|
|
||||||
ownerReferences?: {
|
|
||||||
apiVersion: string;
|
|
||||||
kind: string;
|
|
||||||
name: string;
|
|
||||||
uid: string;
|
|
||||||
controller: boolean;
|
|
||||||
blockOwnerDeletion: boolean;
|
|
||||||
}[];
|
|
||||||
}
|
|
||||||
|
|
||||||
// fixme: add type
|
// fixme: add type
|
||||||
spec: any;
|
spec: any;
|
||||||
|
|
||||||
getOwnerRefs() {
|
|
||||||
const refs = this.metadata.ownerReferences || [];
|
|
||||||
return refs.map(ownerRef => ({
|
|
||||||
...ownerRef,
|
|
||||||
namespace: this.getNs(),
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
getSelectors(): string[] {
|
getSelectors(): string[] {
|
||||||
const selector = this.spec.selector;
|
const selector = this.spec.selector;
|
||||||
return KubeObject.stringifyLabels(selector ? selector.matchLabels : null);
|
return KubeObject.stringifyLabels(selector ? selector.matchLabels : null);
|
||||||
|
|||||||
@ -64,7 +64,6 @@ export class PodDetails extends React.Component<Props> {
|
|||||||
const { status, spec } = pod;
|
const { status, spec } = pod;
|
||||||
const { conditions, podIP } = status;
|
const { conditions, podIP } = status;
|
||||||
const { nodeName } = spec;
|
const { nodeName } = spec;
|
||||||
const ownerRefs = pod.getOwnerRefs();
|
|
||||||
const nodeSelector = pod.getNodeSelectors();
|
const nodeSelector = pod.getNodeSelectors();
|
||||||
const volumes = pod.getVolumes();
|
const volumes = pod.getVolumes();
|
||||||
const labels = pod.getLabels();
|
const labels = pod.getLabels();
|
||||||
@ -123,21 +122,6 @@ export class PodDetails extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
</DrawerItem>
|
</DrawerItem>
|
||||||
}
|
}
|
||||||
{ownerRefs.length > 0 &&
|
|
||||||
<DrawerItem name={<Trans>Controlled By</Trans>}>
|
|
||||||
{
|
|
||||||
ownerRefs.map(ref => {
|
|
||||||
const { name, kind } = ref;
|
|
||||||
const ownerDetailsUrl = getDetailsUrl(lookupApiLink(ref, pod));
|
|
||||||
return (
|
|
||||||
<p key={name}>
|
|
||||||
{kind} <Link to={ownerDetailsUrl}>{name}</Link>
|
|
||||||
</p>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</DrawerItem>
|
|
||||||
}
|
|
||||||
<PodDetailsTolerations workload={pod}/>
|
<PodDetailsTolerations workload={pod}/>
|
||||||
<PodDetailsAffinities workload={pod}/>
|
<PodDetailsAffinities workload={pod}/>
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,10 @@ import React from "react";
|
|||||||
import { Trans } from "@lingui/macro";
|
import { Trans } from "@lingui/macro";
|
||||||
import { IKubeMetaField, KubeObject } from "../../api/kube-object";
|
import { IKubeMetaField, KubeObject } from "../../api/kube-object";
|
||||||
import { DrawerItem, DrawerItemLabels } from "../drawer";
|
import { DrawerItem, DrawerItemLabels } from "../drawer";
|
||||||
|
import { WorkloadKubeObject } from "../../api/workload-kube-object";
|
||||||
|
import { getDetailsUrl } from "../../navigation";
|
||||||
|
import { lookupApiLink } from "../../api/kube-api";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
object: KubeObject;
|
object: KubeObject;
|
||||||
@ -19,11 +23,14 @@ export class KubeObjectMeta extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const object = this.props.object
|
||||||
const {
|
const {
|
||||||
getName, getNs, getLabels, getResourceVersion, selfLink,
|
getName, getNs, getLabels, getResourceVersion, selfLink,
|
||||||
getAnnotations, getFinalizers, getId, getAge,
|
getAnnotations, getFinalizers, getId, getAge,
|
||||||
metadata: { creationTimestamp },
|
metadata: { creationTimestamp },
|
||||||
} = this.props.object;
|
} = object;
|
||||||
|
|
||||||
|
const ownerRefs = object.getOwnerRefs();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DrawerItem name={<Trans>Created</Trans>} hidden={this.isHidden("creationTimestamp")}>
|
<DrawerItem name={<Trans>Created</Trans>} hidden={this.isHidden("creationTimestamp")}>
|
||||||
@ -59,6 +66,21 @@ export class KubeObjectMeta extends React.Component<Props> {
|
|||||||
labels={getFinalizers()}
|
labels={getFinalizers()}
|
||||||
hidden={this.isHidden("finalizers")}
|
hidden={this.isHidden("finalizers")}
|
||||||
/>
|
/>
|
||||||
|
{ownerRefs && ownerRefs.length > 0 &&
|
||||||
|
<DrawerItem name={<Trans>Controlled By</Trans>} hidden={this.isHidden("ownerReferences")}>
|
||||||
|
{
|
||||||
|
ownerRefs.map(ref => {
|
||||||
|
const { name, kind } = ref;
|
||||||
|
const ownerDetailsUrl = getDetailsUrl(lookupApiLink(ref, object));
|
||||||
|
return (
|
||||||
|
<p key={name}>
|
||||||
|
{kind} <Link to={ownerDetailsUrl}>{name}</Link>
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</DrawerItem>
|
||||||
|
}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user