@backstage-community/plugin-tekton 3.22.2 → 3.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/components/PipelineRunLogs/PipelineRunLogViewer.esm.js +15 -1
- package/dist/components/PipelineRunLogs/PipelineRunLogViewer.esm.js.map +1 -1
- package/dist/components/PipelineRunLogs/PipelineRunLogs.esm.js +2 -2
- package/dist/components/PipelineRunLogs/PipelineRunLogs.esm.js.map +1 -1
- package/dist/hooks/usePodLogsOfPipelineRun.esm.js +27 -48
- package/dist/hooks/usePodLogsOfPipelineRun.esm.js.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,7 @@ import React__default from 'react';
|
|
|
2
2
|
import { DismissableBanner, LogViewer } from '@backstage/core-components';
|
|
3
3
|
import { Paper } from '@material-ui/core';
|
|
4
4
|
import { Skeleton } from '@material-ui/lab';
|
|
5
|
+
import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
|
|
5
6
|
import { usePodLogsOfPipelineRun } from '../../hooks/usePodLogsOfPipelineRun.esm.js';
|
|
6
7
|
|
|
7
8
|
const PipelineRunLogViewer = ({ pod }) => {
|
|
@@ -48,6 +49,19 @@ ${value[idx].text}`
|
|
|
48
49
|
pod && !loading && /* @__PURE__ */ React__default.createElement(LogViewer, { text: text || "No Logs found" })
|
|
49
50
|
));
|
|
50
51
|
};
|
|
52
|
+
const queryClient = new QueryClient({
|
|
53
|
+
defaultOptions: {
|
|
54
|
+
queries: {
|
|
55
|
+
retry: 5,
|
|
56
|
+
refetchOnWindowFocus: false
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const PipelineRunLogViewerWithQueryClient = ({
|
|
61
|
+
pod
|
|
62
|
+
}) => {
|
|
63
|
+
return /* @__PURE__ */ React__default.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React__default.createElement(PipelineRunLogViewer, { pod }));
|
|
64
|
+
};
|
|
51
65
|
|
|
52
|
-
export { PipelineRunLogViewer };
|
|
66
|
+
export { PipelineRunLogViewerWithQueryClient as PipelineRunLogViewer };
|
|
53
67
|
//# sourceMappingURL=PipelineRunLogViewer.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PipelineRunLogViewer.esm.js","sources":["../../../src/components/PipelineRunLogs/PipelineRunLogViewer.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\
|
|
1
|
+
{"version":3,"file":"PipelineRunLogViewer.esm.js","sources":["../../../src/components/PipelineRunLogs/PipelineRunLogViewer.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { DismissableBanner, LogViewer } from '@backstage/core-components';\nimport { V1Container, V1Pod } from '@kubernetes/client-node';\nimport { Paper } from '@material-ui/core';\nimport { Skeleton } from '@material-ui/lab';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { usePodLogsOfPipelineRun } from '../../hooks/usePodLogsOfPipelineRun';\n\ntype PipelineRunLogViewerProps = { pod: V1Pod };\n\nconst PipelineRunLogViewer = ({ pod }: PipelineRunLogViewerProps) => {\n const { value, error, loading } = usePodLogsOfPipelineRun({\n pod,\n });\n\n const containersList = pod?.spec?.containers || [];\n let text = '';\n\n text = containersList.reduce(\n (acc: string, container: V1Container, idx: number) => {\n if (container?.name && value?.[idx]?.text) {\n return acc\n .concat(\n `${container.name.toLocaleUpperCase('en-US')}\\n${value[idx].text}`,\n )\n .concat(idx === containersList.length - 1 ? '' : '\\n');\n }\n return acc;\n },\n '',\n );\n\n return (\n <>\n {error && (\n <DismissableBanner\n message={error?.message}\n variant=\"error\"\n fixed={false}\n id=\"pod-logs\"\n />\n )}\n <Paper\n elevation={1}\n style={{ height: '100%', width: '100%', minHeight: '30rem' }}\n >\n {loading && (\n <Skeleton\n data-testid=\"logs-skeleton\"\n variant=\"rect\"\n width=\"100%\"\n height=\"100%\"\n />\n )}\n {pod && !loading && <LogViewer text={text || 'No Logs found'} />}\n </Paper>\n </>\n );\n};\n\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n retry: 5,\n refetchOnWindowFocus: false,\n },\n },\n});\n\nconst PipelineRunLogViewerWithQueryClient = ({\n pod,\n}: PipelineRunLogViewerProps) => {\n return (\n <QueryClientProvider client={queryClient}>\n <PipelineRunLogViewer pod={pod} />\n </QueryClientProvider>\n );\n};\n\nexport { PipelineRunLogViewerWithQueryClient as PipelineRunLogViewer };\n"],"names":["React"],"mappings":";;;;;;;AAyBA,MAAM,oBAAuB,GAAA,CAAC,EAAE,GAAA,EAAqC,KAAA;AACnE,EAAA,MAAM,EAAE,KAAA,EAAO,KAAO,EAAA,OAAA,KAAY,uBAAwB,CAAA;AAAA,IACxD;AAAA,GACD,CAAA;AAED,EAAA,MAAM,cAAiB,GAAA,GAAA,EAAK,IAAM,EAAA,UAAA,IAAc,EAAC;AACjD,EAAA,IAAI,IAAO,GAAA,EAAA;AAEX,EAAA,IAAA,GAAO,cAAe,CAAA,MAAA;AAAA,IACpB,CAAC,GAAa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AAA;AAAA,MACP,KAAO,EAAA,CAAA;AAAA,MACP,oBAAsB,EAAA;AAAA;AACxB;AAEJ,CAAC,CAAA;AAED,MAAM,sCAAsC,CAAC;AAAA,EAC3C;AACF,CAAiC,KAAA;AAC/B,EAAA,oDACG,mBAAoB,EAAA,EAAA,MAAA,EAAQ,+BAC1BA,cAAA,CAAA,aAAA,CAAA,oBAAA,EAAA,EAAqB,KAAU,CAClC,CAAA;AAEJ;;;;"}
|
|
@@ -4,7 +4,7 @@ import { Paper } from '@material-ui/core';
|
|
|
4
4
|
import Grid from '@material-ui/core/Grid';
|
|
5
5
|
import { getTaskRunsForPipelineRun, pipelineRunFilterReducer } from '@janus-idp/shared-react';
|
|
6
6
|
import { getSortedTaskRuns, getActiveTaskRun } from '../../utils/taskRun-utils.esm.js';
|
|
7
|
-
import { PipelineRunLogViewer } from './PipelineRunLogViewer.esm.js';
|
|
7
|
+
import { PipelineRunLogViewer as PipelineRunLogViewerWithQueryClient } from './PipelineRunLogViewer.esm.js';
|
|
8
8
|
import { TaskStatusStepper } from './TaskStatusStepper.esm.js';
|
|
9
9
|
|
|
10
10
|
const PipelineRunLogs = ({
|
|
@@ -62,7 +62,7 @@ const PipelineRunLogs = ({
|
|
|
62
62
|
style: { height: "100%", width: "100%", minHeight: "30rem" }
|
|
63
63
|
},
|
|
64
64
|
/* @__PURE__ */ React__default.createElement(LogViewer, { text: "No Logs found" })
|
|
65
|
-
) : /* @__PURE__ */ React__default.createElement(
|
|
65
|
+
) : /* @__PURE__ */ React__default.createElement(PipelineRunLogViewerWithQueryClient, { pod: podData }))));
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
export { PipelineRunLogs, PipelineRunLogs as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PipelineRunLogs.esm.js","sources":["../../../src/components/PipelineRunLogs/PipelineRunLogs.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport { LogViewer, Progress } from '@backstage/core-components';\n\nimport { V1Pod } from '@kubernetes/client-node';\nimport { Paper } from '@material-ui/core';\nimport Grid from '@material-ui/core/Grid';\n\nimport {\n getTaskRunsForPipelineRun,\n pipelineRunFilterReducer,\n PipelineRunKind,\n TaskRunKind,\n} from '@janus-idp/shared-react';\n\nimport { getActiveTaskRun, getSortedTaskRuns } from '../../utils/taskRun-utils';\nimport { PipelineRunLogViewer } from './PipelineRunLogViewer';\nimport { TaskStatusStepper } from './TaskStatusStepper';\n\ntype PipelineRunLogsProps = {\n pipelineRun: PipelineRunKind;\n taskRuns: TaskRunKind[];\n pods: V1Pod[];\n activeTask?: string;\n setActiveTask: (t: string) => void;\n};\nexport const PipelineRunLogs = ({\n pipelineRun,\n taskRuns,\n pods,\n activeTask,\n setActiveTask,\n}: PipelineRunLogsProps) => {\n const PLRTaskRuns = getTaskRunsForPipelineRun(pipelineRun, taskRuns);\n const sortedTaskRuns = getSortedTaskRuns(PLRTaskRuns);\n const taskRunFromYaml = PLRTaskRuns?.reduce(\n (acc: { [value: string]: TaskRunKind }, value) => {\n if (value?.metadata?.name) {\n acc[value.metadata.name] = value;\n }\n return acc;\n },\n {},\n );\n\n const completed = pipelineRunFilterReducer(pipelineRun);\n const [lastActiveStepId, setLastActiveStepId] = React.useState<string>('');\n\n React.useEffect(() => {\n const mostRecentFailedOrActiveStep = sortedTaskRuns.find(tr =>\n ['Failed', 'Running'].includes(tr.status),\n );\n\n if (completed && !mostRecentFailedOrActiveStep && !activeTask) {\n setLastActiveStepId(sortedTaskRuns[sortedTaskRuns.length - 1]?.id);\n return;\n }\n\n setLastActiveStepId(\n !activeTask ? (mostRecentFailedOrActiveStep?.id as string) : '',\n );\n }, [sortedTaskRuns, completed, activeTask]);\n\n const currentStepId = activeTask || lastActiveStepId;\n const activeItem = getActiveTaskRun(sortedTaskRuns, currentStepId);\n const podName =\n activeItem && taskRunFromYaml?.[currentStepId]?.status?.podName;\n const podData = React.useMemo(\n () =>\n pods.find(pod => {\n return pod?.metadata?.name === podName;\n }),\n [pods, podName],\n );\n\n return (\n <Grid container>\n <Grid item xs={3}>\n <Paper>\n <TaskStatusStepper\n steps={sortedTaskRuns}\n currentStepId={currentStepId}\n onUserStepChange={setActiveTask}\n />\n </Paper>\n </Grid>\n <Grid item xs={9}>\n {!currentStepId && <Progress />}\n <div style={{ height: '80vh' }}>\n {!podData ? (\n <Paper\n elevation={1}\n style={{ height: '100%', width: '100%', minHeight: '30rem' }}\n >\n <LogViewer text=\"No Logs found\" />\n </Paper>\n ) : (\n <PipelineRunLogViewer pod={podData} />\n )}\n </div>\n </Grid>\n </Grid>\n );\n};\n\nexport default PipelineRunLogs;\n"],"names":["React"],"mappings":";;;;;;;;;AAyCO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,WAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAA4B,KAAA;AAC1B,EAAM,MAAA,WAAA,GAAc,yBAA0B,CAAA,WAAA,EAAa,QAAQ,CAAA;AACnE,EAAM,MAAA,cAAA,GAAiB,kBAAkB,WAAW,CAAA;AACpD,EAAA,MAAM,kBAAkB,WAAa,EAAA,MAAA;AAAA,IACnC,CAAC,KAAuC,KAAU,KAAA;AAChD,MAAI,IAAA,KAAA,EAAO,UAAU,IAAM,EAAA;AACzB,QAAI,GAAA,CAAA,KAAA,CAAM,QAAS,CAAA,IAAI,CAAI,GAAA,KAAA;AAAA;AAE7B,MAAO,OAAA,GAAA;AAAA,KACT;AAAA,IACA;AAAC,GACH;AAEA,EAAM,MAAA,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AAA,cAAA,CAAA,aAAA,CAAC,KACC,EAAA,IAAA,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,iBAAA;AAAA,IAAA;AAAA,MACC,KAAO,EAAA,cAAA;AAAA,MACP,aAAA;AAAA,MACA,gBAAkB,EAAA;AAAA;AAAA,GAEtB,CACF,CACA,kBAAAA,cAAA,CAAA,aAAA,CAAC,QAAK,IAAI,EAAA,IAAA,EAAC,EAAI,EAAA,CAAA,EAAA,EACZ,CAAC,aAAA,iDAAkB,QAAS,EAAA,IAAA,CAAA,+CAC5B,KAAI,EAAA,EAAA,KAAA,EAAO,EAAE,MAAQ,EAAA,MAAA,EACnB,EAAA,EAAA,CAAC,OACA,mBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,CAAA;AAAA,MACX,OAAO,EAAE,MAAA,EAAQ,QAAQ,KAAO,EAAA,MAAA,EAAQ,WAAW,OAAQ;AAAA,KAAA;AAAA,oBAE3DA,cAAA,CAAA,aAAA,CAAC,SAAU,EAAA,EAAA,IAAA,EAAK,eAAgB,EAAA;AAAA,sBAGjCA,cAAA,CAAA,aAAA,
|
|
1
|
+
{"version":3,"file":"PipelineRunLogs.esm.js","sources":["../../../src/components/PipelineRunLogs/PipelineRunLogs.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport { LogViewer, Progress } from '@backstage/core-components';\n\nimport { V1Pod } from '@kubernetes/client-node';\nimport { Paper } from '@material-ui/core';\nimport Grid from '@material-ui/core/Grid';\n\nimport {\n getTaskRunsForPipelineRun,\n pipelineRunFilterReducer,\n PipelineRunKind,\n TaskRunKind,\n} from '@janus-idp/shared-react';\n\nimport { getActiveTaskRun, getSortedTaskRuns } from '../../utils/taskRun-utils';\nimport { PipelineRunLogViewer } from './PipelineRunLogViewer';\nimport { TaskStatusStepper } from './TaskStatusStepper';\n\ntype PipelineRunLogsProps = {\n pipelineRun: PipelineRunKind;\n taskRuns: TaskRunKind[];\n pods: V1Pod[];\n activeTask?: string;\n setActiveTask: (t: string) => void;\n};\nexport const PipelineRunLogs = ({\n pipelineRun,\n taskRuns,\n pods,\n activeTask,\n setActiveTask,\n}: PipelineRunLogsProps) => {\n const PLRTaskRuns = getTaskRunsForPipelineRun(pipelineRun, taskRuns);\n const sortedTaskRuns = getSortedTaskRuns(PLRTaskRuns);\n const taskRunFromYaml = PLRTaskRuns?.reduce(\n (acc: { [value: string]: TaskRunKind }, value) => {\n if (value?.metadata?.name) {\n acc[value.metadata.name] = value;\n }\n return acc;\n },\n {},\n );\n\n const completed = pipelineRunFilterReducer(pipelineRun);\n const [lastActiveStepId, setLastActiveStepId] = React.useState<string>('');\n\n React.useEffect(() => {\n const mostRecentFailedOrActiveStep = sortedTaskRuns.find(tr =>\n ['Failed', 'Running'].includes(tr.status),\n );\n\n if (completed && !mostRecentFailedOrActiveStep && !activeTask) {\n setLastActiveStepId(sortedTaskRuns[sortedTaskRuns.length - 1]?.id);\n return;\n }\n\n setLastActiveStepId(\n !activeTask ? (mostRecentFailedOrActiveStep?.id as string) : '',\n );\n }, [sortedTaskRuns, completed, activeTask]);\n\n const currentStepId = activeTask || lastActiveStepId;\n const activeItem = getActiveTaskRun(sortedTaskRuns, currentStepId);\n const podName =\n activeItem && taskRunFromYaml?.[currentStepId]?.status?.podName;\n const podData = React.useMemo(\n () =>\n pods.find(pod => {\n return pod?.metadata?.name === podName;\n }),\n [pods, podName],\n );\n\n return (\n <Grid container>\n <Grid item xs={3}>\n <Paper>\n <TaskStatusStepper\n steps={sortedTaskRuns}\n currentStepId={currentStepId}\n onUserStepChange={setActiveTask}\n />\n </Paper>\n </Grid>\n <Grid item xs={9}>\n {!currentStepId && <Progress />}\n <div style={{ height: '80vh' }}>\n {!podData ? (\n <Paper\n elevation={1}\n style={{ height: '100%', width: '100%', minHeight: '30rem' }}\n >\n <LogViewer text=\"No Logs found\" />\n </Paper>\n ) : (\n <PipelineRunLogViewer pod={podData} />\n )}\n </div>\n </Grid>\n </Grid>\n );\n};\n\nexport default PipelineRunLogs;\n"],"names":["React","PipelineRunLogViewer"],"mappings":";;;;;;;;;AAyCO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,WAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAA4B,KAAA;AAC1B,EAAM,MAAA,WAAA,GAAc,yBAA0B,CAAA,WAAA,EAAa,QAAQ,CAAA;AACnE,EAAM,MAAA,cAAA,GAAiB,kBAAkB,WAAW,CAAA;AACpD,EAAA,MAAM,kBAAkB,WAAa,EAAA,MAAA;AAAA,IACnC,CAAC,KAAuC,KAAU,KAAA;AAChD,MAAI,IAAA,KAAA,EAAO,UAAU,IAAM,EAAA;AACzB,QAAI,GAAA,CAAA,KAAA,CAAM,QAAS,CAAA,IAAI,CAAI,GAAA,KAAA;AAAA;AAE7B,MAAO,OAAA,GAAA;AAAA,KACT;AAAA,IACA;AAAC,GACH;AAEA,EAAM,MAAA,SAAA,GAAY,yBAAyB,WAAW,CAAA;AACtD,EAAA,MAAM,CAAC,gBAAkB,EAAA,mBAAmB,CAAI,GAAAA,cAAA,CAAM,SAAiB,EAAE,CAAA;AAEzE,EAAAA,cAAA,CAAM,UAAU,MAAM;AACpB,IAAA,MAAM,+BAA+B,cAAe,CAAA,IAAA;AAAA,MAAK,QACvD,CAAC,QAAA,EAAU,SAAS,CAAE,CAAA,QAAA,CAAS,GAAG,MAAM;AAAA,KAC1C;AAEA,IAAA,IAAI,SAAa,IAAA,CAA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A,CAAA,+CAC5B,KAAI,EAAA,EAAA,KAAA,EAAO,EAAE,MAAQ,EAAA,MAAA,EACnB,EAAA,EAAA,CAAC,OACA,mBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,CAAA;AAAA,MACX,OAAO,EAAE,MAAA,EAAQ,QAAQ,KAAO,EAAA,MAAA,EAAQ,WAAW,OAAQ;AAAA,KAAA;AAAA,oBAE3DA,cAAA,CAAA,aAAA,CAAC,SAAU,EAAA,EAAA,IAAA,EAAK,eAAgB,EAAA;AAAA,sBAGjCA,cAAA,CAAA,aAAA,CAAAC,mCAAA,EAAA,EAAqB,KAAK,OAAS,EAAA,CAExC,CACF,CACF,CAAA;AAEJ;;;;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import
|
|
3
|
-
import useInterval from 'react-use/lib/useInterval';
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
4
3
|
import { useApi } from '@backstage/core-plugin-api';
|
|
5
4
|
import { kubernetesProxyApiRef } from '../types/types.esm.js';
|
|
6
5
|
import { TektonResourcesContext } from './TektonResourcesContext.esm.js';
|
|
@@ -9,58 +8,38 @@ const usePodLogsOfPipelineRun = ({
|
|
|
9
8
|
pod,
|
|
10
9
|
intervalMs = 5e3
|
|
11
10
|
}) => {
|
|
12
|
-
const [loadingData, setLoadingData] = React__default.useState(true);
|
|
13
|
-
const [, setPodInfo] = React__default.useState(pod?.metadata?.name ?? "");
|
|
14
11
|
const kubernetesProxyApi = useApi(kubernetesProxyApiRef);
|
|
15
12
|
const { clusters, selectedCluster } = React__default.useContext(TektonResourcesContext);
|
|
16
13
|
const currCluster = clusters.length > 0 && clusters[selectedCluster || 0] || "";
|
|
17
14
|
const containersList = pod?.spec?.containers || [];
|
|
18
|
-
const
|
|
19
|
-
async (podScope) => {
|
|
20
|
-
const { podName, podNamespace, containerName, clusterName } = podScope;
|
|
21
|
-
return await kubernetesProxyApi.getPodLogs({
|
|
22
|
-
podName,
|
|
23
|
-
namespace: podNamespace,
|
|
24
|
-
containerName,
|
|
25
|
-
clusterName
|
|
26
|
-
});
|
|
27
|
-
},
|
|
28
|
-
[kubernetesProxyApi]
|
|
29
|
-
);
|
|
30
|
-
const { value, error, loading, retry } = useAsyncRetry(async () => {
|
|
31
|
-
const requests = [];
|
|
32
|
-
containersList.map((container, _idx) => {
|
|
33
|
-
if (pod?.metadata?.name && pod?.metadata?.namespace && container) {
|
|
34
|
-
const podScope = {
|
|
35
|
-
containerName: container.name,
|
|
36
|
-
podName: pod.metadata.name,
|
|
37
|
-
podNamespace: pod.metadata.namespace,
|
|
38
|
-
clusterName: currCluster
|
|
39
|
-
};
|
|
40
|
-
requests.push(getLogs(podScope));
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return requests.length > 0 ? Promise.all(requests) : [];
|
|
44
|
-
}, [containersList, pod, getLogs]);
|
|
15
|
+
const podKey = pod?.metadata?.name;
|
|
45
16
|
const stopPolling = pod?.status?.phase === "Succeeded" || pod?.status?.phase === "Failed";
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
17
|
+
const { data, error, isLoading, isFetching } = useQuery({
|
|
18
|
+
queryKey: ["podLogs", podKey, currCluster],
|
|
19
|
+
queryFn: async () => {
|
|
20
|
+
const requests = containersList.map((container) => {
|
|
21
|
+
if (pod?.metadata?.name && pod?.metadata?.namespace && container) {
|
|
22
|
+
return kubernetesProxyApi.getPodLogs({
|
|
23
|
+
podName: pod.metadata.name,
|
|
24
|
+
namespace: pod.metadata.namespace,
|
|
25
|
+
containerName: container.name,
|
|
26
|
+
clusterName: currCluster
|
|
27
|
+
});
|
|
54
28
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
29
|
+
return Promise.resolve({ text: "" });
|
|
30
|
+
}).filter(Boolean);
|
|
31
|
+
return Promise.all(requests);
|
|
32
|
+
},
|
|
33
|
+
enabled: !!pod?.metadata?.name && containersList.length > 0,
|
|
34
|
+
refetchInterval: stopPolling ? false : intervalMs,
|
|
35
|
+
staleTime: 6e4
|
|
36
|
+
// Keep the data fresh for 1 minute instead of constantly refetching.
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
value: data,
|
|
40
|
+
error,
|
|
41
|
+
loading: isLoading || isFetching
|
|
42
|
+
};
|
|
64
43
|
};
|
|
65
44
|
|
|
66
45
|
export { usePodLogsOfPipelineRun };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePodLogsOfPipelineRun.esm.js","sources":["../../src/hooks/usePodLogsOfPipelineRun.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport
|
|
1
|
+
{"version":3,"file":"usePodLogsOfPipelineRun.esm.js","sources":["../../src/hooks/usePodLogsOfPipelineRun.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { V1Container, V1Pod } from '@kubernetes/client-node';\n\nimport {\n kubernetesProxyApiRef,\n TektonResourcesContextData,\n} from '../types/types';\nimport { TektonResourcesContext } from './TektonResourcesContext';\n\nexport interface ContainerScope {\n podName: string;\n podNamespace: string;\n clusterName: string;\n containerName: string;\n}\n\ninterface PodLogsOptions {\n pod: V1Pod;\n intervalMs?: number;\n}\n\nexport const usePodLogsOfPipelineRun = ({\n pod,\n intervalMs = 5000,\n}: PodLogsOptions) => {\n const kubernetesProxyApi = useApi(kubernetesProxyApiRef);\n const { clusters, selectedCluster } =\n React.useContext<TektonResourcesContextData>(TektonResourcesContext);\n const currCluster =\n (clusters.length > 0 && clusters[selectedCluster || 0]) || '';\n const containersList = pod?.spec?.containers || [];\n\n const podKey = pod?.metadata?.name;\n const stopPolling =\n pod?.status?.phase === 'Succeeded' || pod?.status?.phase === 'Failed';\n\n const { data, error, isLoading, isFetching } = useQuery({\n queryKey: ['podLogs', podKey, currCluster],\n queryFn: async () => {\n const requests = containersList\n .map((container: V1Container) => {\n if (pod?.metadata?.name && pod?.metadata?.namespace && container) {\n return kubernetesProxyApi.getPodLogs({\n podName: pod.metadata.name,\n namespace: pod.metadata.namespace,\n containerName: container.name,\n clusterName: currCluster,\n });\n }\n\n return Promise.resolve({ text: '' });\n })\n .filter(Boolean);\n\n return Promise.all(requests);\n },\n enabled: !!pod?.metadata?.name && containersList.length > 0,\n refetchInterval: stopPolling ? false : intervalMs,\n staleTime: 60000, // Keep the data fresh for 1 minute instead of constantly refetching.\n });\n\n return {\n value: data,\n error,\n loading: isLoading || isFetching,\n };\n};\n"],"names":["React"],"mappings":";;;;;;AAsCO,MAAM,0BAA0B,CAAC;AAAA,EACtC,GAAA;AAAA,EACA,UAAa,GAAA;AACf,CAAsB,KAAA;AACpB,EAAM,MAAA,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AACvD,EAA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AS,GAAA,CAAA;AAAA,IAC1D,eAAA,EAAiB,cAAc,KAAQ,GAAA,UAAA;AAAA,IACvC,SAAW,EAAA;AAAA;AAAA,GACZ,CAAA;AAED,EAAO,OAAA;AAAA,IACL,KAAO,EAAA,IAAA;AAAA,IACP,KAAA;AAAA,IACA,SAAS,SAAa,IAAA;AAAA,GACxB;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-tekton",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.23.0",
|
|
4
4
|
"main": "dist/index.esm.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"@patternfly/react-core": "^6.0.0",
|
|
57
57
|
"@patternfly/react-tokens": "^6.0.0",
|
|
58
58
|
"@patternfly/react-topology": "^6.0.0",
|
|
59
|
+
"@tanstack/react-query": "^5.62.7",
|
|
59
60
|
"classnames": "^2.3.2",
|
|
60
61
|
"dagre": "^0.8.5",
|
|
61
62
|
"lodash": "^4.17.21",
|