pass ClusterAttributes to pod components
Signed-off-by: Jamie Klassen <jamie.klassen@broadcom.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-kubernetes-react': patch
|
||||
---
|
||||
|
||||
The `PodAndErrors` type now includes the full `ClusterAttributes` rather than just the name.
|
||||
@@ -653,7 +653,7 @@ export interface PendingPodContentProps {
|
||||
// @public
|
||||
export interface PodAndErrors {
|
||||
// (undocumented)
|
||||
clusterName: string;
|
||||
cluster: ClusterAttributes;
|
||||
// (undocumented)
|
||||
errors: DetectedError[];
|
||||
// (undocumented)
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('ErrorList', () => {
|
||||
<ErrorList
|
||||
podAndErrors={[
|
||||
{
|
||||
clusterName: 'some-cluster',
|
||||
cluster: { name: 'some-cluster' },
|
||||
pod: {
|
||||
metadata: {
|
||||
name: 'some-pod',
|
||||
|
||||
@@ -82,7 +82,7 @@ export const ErrorList = ({ podAndErrors }: ErrorListProps) => {
|
||||
<FixDialog
|
||||
pod={onlyPodWithErrors.pod}
|
||||
error={error}
|
||||
clusterName={onlyPodWithErrors.clusterName}
|
||||
clusterName={onlyPodWithErrors.cluster.name}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('PodDrawer', () => {
|
||||
{...({
|
||||
open: true,
|
||||
podAndErrors: {
|
||||
clusterName: 'some-cluster-1',
|
||||
cluster: { name: 'some-cluster-1' },
|
||||
pod: {
|
||||
metadata: {
|
||||
name: 'some-pod',
|
||||
|
||||
@@ -79,7 +79,7 @@ export interface PodDrawerProps {
|
||||
*/
|
||||
export const PodDrawer = ({ podAndErrors, open }: PodDrawerProps) => {
|
||||
const classes = useDrawerContentStyles();
|
||||
const podMetrics = usePodMetrics(podAndErrors.clusterName, podAndErrors.pod);
|
||||
const podMetrics = usePodMetrics(podAndErrors.cluster.name, podAndErrors.pod);
|
||||
|
||||
return (
|
||||
<KubernetesDrawer
|
||||
@@ -161,7 +161,7 @@ export const PodDrawer = ({ podAndErrors, open }: PodDrawerProps) => {
|
||||
podName: podAndErrors.pod.metadata?.name ?? 'unknown',
|
||||
podNamespace:
|
||||
podAndErrors.pod.metadata?.namespace ?? 'unknown',
|
||||
clusterName: podAndErrors.clusterName,
|
||||
clusterName: podAndErrors.cluster.name,
|
||||
}}
|
||||
containerSpec={containerSpec}
|
||||
containerStatus={containerStatus}
|
||||
|
||||
+1
-2
@@ -80,7 +80,6 @@ const READY: TableColumn<Pod>[] = [
|
||||
];
|
||||
|
||||
const PodDrawerTrigger = ({ pod }: { pod: Pod }) => {
|
||||
const cluster = useContext(ClusterContext);
|
||||
const errors = useMatchingErrors({
|
||||
kind: 'Pod',
|
||||
apiVersion: 'v1',
|
||||
@@ -90,7 +89,7 @@ const PodDrawerTrigger = ({ pod }: { pod: Pod }) => {
|
||||
<PodDrawer
|
||||
podAndErrors={{
|
||||
pod: pod as any,
|
||||
clusterName: cluster.name,
|
||||
cluster: useContext(ClusterContext),
|
||||
errors: errors,
|
||||
}}
|
||||
/>
|
||||
|
||||
+6
-3
@@ -14,15 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Pod } from 'kubernetes-models/v1';
|
||||
import { DetectedError } from '@backstage/plugin-kubernetes-common';
|
||||
import {
|
||||
ClusterAttributes,
|
||||
DetectedError,
|
||||
} from '@backstage/plugin-kubernetes-common';
|
||||
|
||||
/**
|
||||
* Wraps a pod with the associated detected errors and cluster name
|
||||
* Wraps a pod with the associated detected errors and cluster
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface PodAndErrors {
|
||||
clusterName: string;
|
||||
cluster: ClusterAttributes;
|
||||
pod: Pod;
|
||||
errors: DetectedError[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user