@backstage-community/plugin-tekton 3.16.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 +801 -0
- package/README.md +369 -0
- package/app-config.dynamic.yaml +12 -0
- package/dist/components/Charts/PipelineBars.esm.js +49 -0
- package/dist/components/Charts/PipelineBars.esm.js.map +1 -0
- package/dist/components/Icons/CriticalRiskIcon.esm.js +22 -0
- package/dist/components/Icons/CriticalRiskIcon.esm.js.map +1 -0
- package/dist/components/Icons/EqualsIcon.esm.js +22 -0
- package/dist/components/Icons/EqualsIcon.esm.js.map +1 -0
- package/dist/components/Icons/LinkToSbomIcon.esm.js +37 -0
- package/dist/components/Icons/LinkToSbomIcon.esm.js.map +1 -0
- package/dist/components/Icons/OutputIcon.esm.js +36 -0
- package/dist/components/Icons/OutputIcon.esm.js.map +1 -0
- package/dist/components/Icons/SignedBadge.esm.js +16 -0
- package/dist/components/Icons/SignedBadge.esm.js.map +1 -0
- package/dist/components/Icons/ViewLogsIcon.esm.js +35 -0
- package/dist/components/Icons/ViewLogsIcon.esm.js.map +1 -0
- package/dist/components/PipelineRunList/PipelineRunColumnHeader.esm.js +43 -0
- package/dist/components/PipelineRunList/PipelineRunColumnHeader.esm.js.map +1 -0
- package/dist/components/PipelineRunList/PipelineRunList.esm.js +185 -0
- package/dist/components/PipelineRunList/PipelineRunList.esm.js.map +1 -0
- package/dist/components/PipelineRunList/PipelineRunListSearchBar.esm.js +42 -0
- package/dist/components/PipelineRunList/PipelineRunListSearchBar.esm.js.map +1 -0
- package/dist/components/PipelineRunList/PipelineRunOutput.esm.js +70 -0
- package/dist/components/PipelineRunList/PipelineRunOutput.esm.js.map +1 -0
- package/dist/components/PipelineRunList/PipelineRunRow.css.esm.js +7 -0
- package/dist/components/PipelineRunList/PipelineRunRow.css.esm.js.map +1 -0
- package/dist/components/PipelineRunList/PipelineRunRow.esm.js +110 -0
- package/dist/components/PipelineRunList/PipelineRunRow.esm.js.map +1 -0
- package/dist/components/PipelineRunList/PipelineRunRowActions.esm.js +137 -0
- package/dist/components/PipelineRunList/PipelineRunRowActions.esm.js.map +1 -0
- package/dist/components/PipelineRunList/PipelineRunSBOMLink.esm.js +25 -0
- package/dist/components/PipelineRunList/PipelineRunSBOMLink.esm.js.map +1 -0
- package/dist/components/PipelineRunList/PipelineRunTableBody.esm.js +32 -0
- package/dist/components/PipelineRunList/PipelineRunTableBody.esm.js.map +1 -0
- package/dist/components/PipelineRunList/PipelineRunTaskStatus.esm.js +11 -0
- package/dist/components/PipelineRunList/PipelineRunTaskStatus.esm.js.map +1 -0
- package/dist/components/PipelineRunList/PipelineRunVulnerabilities.esm.js +81 -0
- package/dist/components/PipelineRunList/PipelineRunVulnerabilities.esm.js.map +1 -0
- package/dist/components/PipelineRunList/PipelineTableHeader.esm.js +53 -0
- package/dist/components/PipelineRunList/PipelineTableHeader.esm.js.map +1 -0
- package/dist/components/PipelineRunList/PlrStatus.css.esm.js +7 -0
- package/dist/components/PipelineRunList/PlrStatus.css.esm.js.map +1 -0
- package/dist/components/PipelineRunList/PlrStatus.esm.js +11 -0
- package/dist/components/PipelineRunList/PlrStatus.esm.js.map +1 -0
- package/dist/components/PipelineRunList/ResourceBadge.css.esm.js +7 -0
- package/dist/components/PipelineRunList/ResourceBadge.css.esm.js.map +1 -0
- package/dist/components/PipelineRunList/ResourceBadge.esm.js +15 -0
- package/dist/components/PipelineRunList/ResourceBadge.esm.js.map +1 -0
- package/dist/components/PipelineRunLogs/PipelineRunLogDialog.esm.js +82 -0
- package/dist/components/PipelineRunLogs/PipelineRunLogDialog.esm.js.map +1 -0
- package/dist/components/PipelineRunLogs/PipelineRunLogDownloader.esm.js +47 -0
- package/dist/components/PipelineRunLogs/PipelineRunLogDownloader.esm.js.map +1 -0
- package/dist/components/PipelineRunLogs/PipelineRunLogViewer.esm.js +53 -0
- package/dist/components/PipelineRunLogs/PipelineRunLogViewer.esm.js.map +1 -0
- package/dist/components/PipelineRunLogs/PipelineRunLogs.esm.js +69 -0
- package/dist/components/PipelineRunLogs/PipelineRunLogs.esm.js.map +1 -0
- package/dist/components/PipelineRunLogs/PodLogsDownloadLink.esm.js +69 -0
- package/dist/components/PipelineRunLogs/PodLogsDownloadLink.esm.js.map +1 -0
- package/dist/components/PipelineRunLogs/TaskStatusStepper.esm.js +128 -0
- package/dist/components/PipelineRunLogs/TaskStatusStepper.esm.js.map +1 -0
- package/dist/components/PipelineRunOutput/PipelineRunOutputDialog.esm.js +62 -0
- package/dist/components/PipelineRunOutput/PipelineRunOutputDialog.esm.js.map +1 -0
- package/dist/components/Router.esm.js +16 -0
- package/dist/components/Router.esm.js.map +1 -0
- package/dist/components/Tekton/TektonCIComponent.esm.js +53 -0
- package/dist/components/Tekton/TektonCIComponent.esm.js.map +1 -0
- package/dist/components/common/ClusterSelector.css.esm.js +7 -0
- package/dist/components/common/ClusterSelector.css.esm.js.map +1 -0
- package/dist/components/common/ClusterSelector.esm.js +46 -0
- package/dist/components/common/ClusterSelector.esm.js.map +1 -0
- package/dist/components/common/ErrorPanel.esm.js +33 -0
- package/dist/components/common/ErrorPanel.esm.js.map +1 -0
- package/dist/components/common/PermissionAlert.esm.js +9 -0
- package/dist/components/common/PermissionAlert.esm.js.map +1 -0
- package/dist/components/common/ResourceStatus.css.esm.js +7 -0
- package/dist/components/common/ResourceStatus.css.esm.js.map +1 -0
- package/dist/components/common/StatusSelector.css.esm.js +7 -0
- package/dist/components/common/StatusSelector.css.esm.js.map +1 -0
- package/dist/components/common/StatusSelector.esm.js +48 -0
- package/dist/components/common/StatusSelector.esm.js.map +1 -0
- package/dist/components/common/TableExpandCollapse.esm.js +44 -0
- package/dist/components/common/TableExpandCollapse.esm.js.map +1 -0
- package/dist/components/pipeline-topology/PipelineLayout.esm.js +126 -0
- package/dist/components/pipeline-topology/PipelineLayout.esm.js.map +1 -0
- package/dist/components/pipeline-topology/PipelineRunVisualization.esm.js +13 -0
- package/dist/components/pipeline-topology/PipelineRunVisualization.esm.js.map +1 -0
- package/dist/components/pipeline-topology/PipelineTaskNode.css.esm.js +7 -0
- package/dist/components/pipeline-topology/PipelineTaskNode.css.esm.js.map +1 -0
- package/dist/components/pipeline-topology/PipelineTaskNode.esm.js +132 -0
- package/dist/components/pipeline-topology/PipelineTaskNode.esm.js.map +1 -0
- package/dist/components/pipeline-topology/PipelineVisualization.css.esm.js +7 -0
- package/dist/components/pipeline-topology/PipelineVisualization.css.esm.js.map +1 -0
- package/dist/components/pipeline-topology/PipelineVisualization.esm.js +24 -0
- package/dist/components/pipeline-topology/PipelineVisualization.esm.js.map +1 -0
- package/dist/components/pipeline-topology/PipelineVisualizationStepList.css.esm.js +7 -0
- package/dist/components/pipeline-topology/PipelineVisualizationStepList.css.esm.js.map +1 -0
- package/dist/components/pipeline-topology/PipelineVisualizationStepList.esm.js +39 -0
- package/dist/components/pipeline-topology/PipelineVisualizationStepList.esm.js.map +1 -0
- package/dist/components/pipeline-topology/PipelineVisualizationView.esm.js +41 -0
- package/dist/components/pipeline-topology/PipelineVisualizationView.esm.js.map +1 -0
- package/dist/components/pipeline-topology/TaskGroupEdge.esm.js +16 -0
- package/dist/components/pipeline-topology/TaskGroupEdge.esm.js.map +1 -0
- package/dist/components/pipeline-topology/dag.esm.js +119 -0
- package/dist/components/pipeline-topology/dag.esm.js.map +1 -0
- package/dist/components/pipeline-topology/pipelineComponentFactory.esm.js +60 -0
- package/dist/components/pipeline-topology/pipelineComponentFactory.esm.js.map +1 -0
- package/dist/consts/pipeline-topology-const.esm.js +66 -0
- package/dist/consts/pipeline-topology-const.esm.js.map +1 -0
- package/dist/consts/tekton-const.esm.js +7 -0
- package/dist/consts/tekton-const.esm.js.map +1 -0
- package/dist/hooks/TektonResourcesContext.esm.js +16 -0
- package/dist/hooks/TektonResourcesContext.esm.js.map +1 -0
- package/dist/hooks/useAllWatchResources.esm.js +35 -0
- package/dist/hooks/useAllWatchResources.esm.js.map +1 -0
- package/dist/hooks/useDarkTheme.esm.js +21 -0
- package/dist/hooks/useDarkTheme.esm.js.map +1 -0
- package/dist/hooks/usePipelineRunScanResults.esm.js +35 -0
- package/dist/hooks/usePipelineRunScanResults.esm.js.map +1 -0
- package/dist/hooks/usePodLogsOfPipelineRun.esm.js +67 -0
- package/dist/hooks/usePodLogsOfPipelineRun.esm.js.map +1 -0
- package/dist/hooks/useResourcesClusters.esm.js +24 -0
- package/dist/hooks/useResourcesClusters.esm.js.map +1 -0
- package/dist/hooks/useTektonObjectsResponse.esm.js +78 -0
- package/dist/hooks/useTektonObjectsResponse.esm.js.map +1 -0
- package/dist/hooks/useTektonViewPermission.esm.js +12 -0
- package/dist/hooks/useTektonViewPermission.esm.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.esm.js +3 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/models.esm.js +21 -0
- package/dist/models.esm.js.map +1 -0
- package/dist/plugin.esm.js +72 -0
- package/dist/plugin.esm.js.map +1 -0
- package/dist/types/types.esm.js +15 -0
- package/dist/types/types.esm.js.map +1 -0
- package/dist/utils/isTektonCIAvailable.esm.js +7 -0
- package/dist/utils/isTektonCIAvailable.esm.js.map +1 -0
- package/dist/utils/log-downloader-utils.esm.js +33 -0
- package/dist/utils/log-downloader-utils.esm.js.map +1 -0
- package/dist/utils/pipeline-step-utils.esm.js +53 -0
- package/dist/utils/pipeline-step-utils.esm.js.map +1 -0
- package/dist/utils/pipeline-topology-utils.esm.js +250 -0
- package/dist/utils/pipeline-topology-utils.esm.js.map +1 -0
- package/dist/utils/pipelineRun-utils.esm.js +128 -0
- package/dist/utils/pipelineRun-utils.esm.js.map +1 -0
- package/dist/utils/taskRun-utils.esm.js +50 -0
- package/dist/utils/taskRun-utils.esm.js.map +1 -0
- package/dist/utils/tekton-utils.esm.js +191 -0
- package/dist/utils/tekton-utils.esm.js.map +1 -0
- package/package.json +114 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import useAsyncRetry from 'react-use/lib/useAsyncRetry';
|
|
3
|
+
import useInterval from 'react-use/lib/useInterval';
|
|
4
|
+
import { useApi } from '@backstage/core-plugin-api';
|
|
5
|
+
import { kubernetesProxyApiRef } from '../types/types.esm.js';
|
|
6
|
+
import { TektonResourcesContext } from './TektonResourcesContext.esm.js';
|
|
7
|
+
|
|
8
|
+
const usePodLogsOfPipelineRun = ({
|
|
9
|
+
pod,
|
|
10
|
+
intervalMs = 5e3
|
|
11
|
+
}) => {
|
|
12
|
+
const [loadingData, setLoadingData] = React__default.useState(true);
|
|
13
|
+
const [, setPodInfo] = React__default.useState(pod?.metadata?.name ?? "");
|
|
14
|
+
const kubernetesProxyApi = useApi(kubernetesProxyApiRef);
|
|
15
|
+
const { clusters, selectedCluster } = React__default.useContext(TektonResourcesContext);
|
|
16
|
+
const currCluster = clusters.length > 0 && clusters[selectedCluster || 0] || "";
|
|
17
|
+
const containersList = pod?.spec?.containers || [];
|
|
18
|
+
const getLogs = React__default.useCallback(
|
|
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]);
|
|
45
|
+
const stopPolling = pod?.status?.phase === "Succeeded" || pod?.status?.phase === "Failed";
|
|
46
|
+
useInterval(() => retry(), stopPolling ? null : intervalMs);
|
|
47
|
+
React__default.useEffect(() => {
|
|
48
|
+
let mounted = true;
|
|
49
|
+
if (!loading && mounted) {
|
|
50
|
+
setPodInfo((prevState) => {
|
|
51
|
+
if (prevState === pod?.metadata?.name) {
|
|
52
|
+
setLoadingData(false);
|
|
53
|
+
return prevState;
|
|
54
|
+
}
|
|
55
|
+
setLoadingData(true);
|
|
56
|
+
return pod?.metadata?.name || "";
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return () => {
|
|
60
|
+
mounted = false;
|
|
61
|
+
};
|
|
62
|
+
}, [loading, pod]);
|
|
63
|
+
return { value, error, loading: loadingData };
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { usePodLogsOfPipelineRun };
|
|
67
|
+
//# sourceMappingURL=usePodLogsOfPipelineRun.esm.js.map
|
|
@@ -0,0 +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 useAsyncRetry from 'react-use/lib/useAsyncRetry';\nimport useInterval from 'react-use/lib/useInterval';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\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 [loadingData, setLoadingData] = React.useState<boolean>(true);\n const [, setPodInfo] = React.useState<string>(pod?.metadata?.name ?? '');\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 const getLogs = React.useCallback(\n async (podScope: ContainerScope): Promise<{ text: string }> => {\n const { podName, podNamespace, containerName, clusterName } = podScope;\n return await kubernetesProxyApi.getPodLogs({\n podName: podName,\n namespace: podNamespace,\n containerName: containerName,\n clusterName: clusterName,\n });\n },\n [kubernetesProxyApi],\n );\n\n const { value, error, loading, retry } = useAsyncRetry(async () => {\n const requests: Promise<{\n text: string;\n }>[] = [];\n containersList.map((container: V1Container, _idx: any) => {\n if (pod?.metadata?.name && pod?.metadata?.namespace && container) {\n const podScope = {\n containerName: container.name,\n podName: pod.metadata.name,\n podNamespace: pod.metadata.namespace,\n clusterName: currCluster,\n };\n requests.push(getLogs(podScope));\n }\n });\n return requests.length > 0 ? Promise.all(requests) : [];\n }, [containersList, pod, getLogs]);\n\n const stopPolling =\n pod?.status?.phase === 'Succeeded' || pod?.status?.phase === 'Failed';\n\n useInterval(() => retry(), stopPolling ? null : intervalMs);\n\n React.useEffect(() => {\n let mounted = true;\n if (!loading && mounted) {\n setPodInfo(prevState => {\n if (prevState === pod?.metadata?.name) {\n setLoadingData(false);\n return prevState;\n }\n setLoadingData(true);\n return pod?.metadata?.name || '';\n });\n }\n return () => {\n mounted = false;\n };\n }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O,KAAO,EAAA,OAAA,EAAS,WAAY,EAAA;AAC9C;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { useDeepCompareMemoize } from '@janus-idp/shared-react';
|
|
3
|
+
import { getClusters } from '../utils/tekton-utils.esm.js';
|
|
4
|
+
|
|
5
|
+
const useResourcesClusters = (k8sObjectsResponse) => {
|
|
6
|
+
const { kubernetesObjects, loading, error } = k8sObjectsResponse;
|
|
7
|
+
const [clusters, setClusters] = useState({ clusters: [], errors: [] });
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
let isMounted = true;
|
|
10
|
+
if (isMounted && !loading && kubernetesObjects && !error) {
|
|
11
|
+
const k8sResourcesClusters = getClusters(kubernetesObjects);
|
|
12
|
+
if (k8sResourcesClusters) {
|
|
13
|
+
setClusters(k8sResourcesClusters);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return () => {
|
|
17
|
+
isMounted = false;
|
|
18
|
+
};
|
|
19
|
+
}, [loading, kubernetesObjects, error]);
|
|
20
|
+
return useDeepCompareMemoize(clusters);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { useResourcesClusters };
|
|
24
|
+
//# sourceMappingURL=useResourcesClusters.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResourcesClusters.esm.js","sources":["../../src/hooks/useResourcesClusters.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 { useEffect, useState } from 'react';\n\nimport { KubernetesObjects } from '@backstage/plugin-kubernetes-react';\n\nimport { useDeepCompareMemoize } from '@janus-idp/shared-react';\n\nimport { ClusterErrors } from '../types/types';\nimport { getClusters } from '../utils/tekton-utils';\n\nexport const useResourcesClusters = (k8sObjectsResponse: KubernetesObjects) => {\n const { kubernetesObjects, loading, error } = k8sObjectsResponse;\n const [clusters, setClusters] = useState<{\n clusters: string[];\n errors: ClusterErrors[];\n }>({ clusters: [], errors: [] });\n\n useEffect(() => {\n let isMounted = true;\n if (isMounted && !loading && kubernetesObjects && !error) {\n const k8sResourcesClusters = getClusters(kubernetesObjects);\n if (k8sResourcesClusters) {\n setClusters(k8sResourcesClusters);\n }\n }\n return () => {\n isMounted = false;\n };\n }, [loading, kubernetesObjects, error]);\n\n return useDeepCompareMemoize(clusters);\n};\n"],"names":[],"mappings":";;;;AAwBa,MAAA,oBAAA,GAAuB,CAAC,kBAA0C,KAAA;AAC7E,EAAA,MAAM,EAAE,iBAAA,EAAmB,OAAS,EAAA,KAAA,EAAU,GAAA,kBAAA;AAC9C,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,QAG7B,CAAA,EAAE,QAAU,EAAA,EAAI,EAAA,MAAA,EAAQ,EAAC,EAAG,CAAA;AAE/B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,SAAY,GAAA,IAAA;AAChB,IAAA,IAAI,SAAa,IAAA,CAAC,OAAW,IAAA,iBAAA,IAAqB,CAAC,KAAO,EAAA;AACxD,MAAM,MAAA,oBAAA,GAAuB,YAAY,iBAAiB,CAAA;AAC1D,MAAA,IAAI,oBAAsB,EAAA;AACxB,QAAA,WAAA,CAAY,oBAAoB,CAAA;AAAA;AAClC;AAEF,IAAA,OAAO,MAAM;AACX,MAAY,SAAA,GAAA,KAAA;AAAA,KACd;AAAA,GACC,EAAA,CAAC,OAAS,EAAA,iBAAA,EAAmB,KAAK,CAAC,CAAA;AAEtC,EAAA,OAAO,sBAAsB,QAAQ,CAAA;AACvC;;;;"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { useEntity } from '@backstage/plugin-catalog-react';
|
|
3
|
+
import { isEqual } from 'lodash';
|
|
4
|
+
import { useKubernetesObjects, useDebounceCallback, useDeepCompareMemoize } from '@janus-idp/shared-react';
|
|
5
|
+
import { kubernetesApiRef, kubernetesAuthProvidersApiRef } from '../types/types.esm.js';
|
|
6
|
+
import { useAllWatchResources } from './useAllWatchResources.esm.js';
|
|
7
|
+
import { useResourcesClusters } from './useResourcesClusters.esm.js';
|
|
8
|
+
|
|
9
|
+
const useTektonObjectsResponse = (watchedResource) => {
|
|
10
|
+
const { entity } = useEntity();
|
|
11
|
+
const { kubernetesObjects, loading, error } = useKubernetesObjects(
|
|
12
|
+
entity,
|
|
13
|
+
kubernetesApiRef,
|
|
14
|
+
kubernetesAuthProvidersApiRef
|
|
15
|
+
);
|
|
16
|
+
const [selectedCluster, setSelectedCluster] = React__default.useState(0);
|
|
17
|
+
const [selectedStatus, setSelectedStatus] = React__default.useState(
|
|
18
|
+
"All"
|
|
19
|
+
);
|
|
20
|
+
const [isExpanded, setIsExpanded] = React__default.useState(false);
|
|
21
|
+
const [loaded, setLoaded] = React__default.useState(false);
|
|
22
|
+
const [errorState, setErrorState] = React__default.useState();
|
|
23
|
+
const [pipelinesData, setPipelinesData] = React__default.useState();
|
|
24
|
+
const mounted = React__default.useRef(false);
|
|
25
|
+
React__default.useEffect(() => {
|
|
26
|
+
mounted.current = true;
|
|
27
|
+
return () => {
|
|
28
|
+
mounted.current = false;
|
|
29
|
+
};
|
|
30
|
+
}, []);
|
|
31
|
+
const watchResourcesData = useAllWatchResources(
|
|
32
|
+
{ kubernetesObjects, loading, error },
|
|
33
|
+
selectedCluster,
|
|
34
|
+
watchedResource
|
|
35
|
+
);
|
|
36
|
+
const resourcesClusters = useResourcesClusters({
|
|
37
|
+
kubernetesObjects,
|
|
38
|
+
loading,
|
|
39
|
+
error
|
|
40
|
+
});
|
|
41
|
+
const updateResults = React__default.useCallback(
|
|
42
|
+
(resData, isLoading, errorData) => {
|
|
43
|
+
if (!isLoading && !errorData && mounted.current) {
|
|
44
|
+
setLoaded(true);
|
|
45
|
+
setPipelinesData((prevPipelinesData) => {
|
|
46
|
+
if (isEqual(prevPipelinesData, resData)) {
|
|
47
|
+
return prevPipelinesData;
|
|
48
|
+
}
|
|
49
|
+
return resData;
|
|
50
|
+
});
|
|
51
|
+
} else if (errorData && mounted.current) {
|
|
52
|
+
setLoaded(true);
|
|
53
|
+
setErrorState(errorData);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
[setLoaded, setPipelinesData, setErrorState]
|
|
57
|
+
);
|
|
58
|
+
const debouncedUpdateResources = useDebounceCallback(updateResults, 250);
|
|
59
|
+
React__default.useEffect(() => {
|
|
60
|
+
debouncedUpdateResources?.(watchResourcesData, loading, error);
|
|
61
|
+
}, [debouncedUpdateResources, watchResourcesData, loading, error]);
|
|
62
|
+
return useDeepCompareMemoize({
|
|
63
|
+
watchResourcesData: pipelinesData,
|
|
64
|
+
loaded,
|
|
65
|
+
responseError: errorState,
|
|
66
|
+
selectedClusterErrors: resourcesClusters?.errors?.[selectedCluster] ?? [],
|
|
67
|
+
clusters: resourcesClusters?.clusters || [],
|
|
68
|
+
selectedCluster,
|
|
69
|
+
setSelectedCluster,
|
|
70
|
+
selectedStatus,
|
|
71
|
+
setSelectedStatus,
|
|
72
|
+
isExpanded,
|
|
73
|
+
setIsExpanded
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { useTektonObjectsResponse };
|
|
78
|
+
//# sourceMappingURL=useTektonObjectsResponse.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTektonObjectsResponse.esm.js","sources":["../../src/hooks/useTektonObjectsResponse.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';\n\nimport { useEntity } from '@backstage/plugin-catalog-react';\n\nimport { isEqual } from 'lodash';\n\nimport {\n ComputedStatus,\n useDebounceCallback,\n useDeepCompareMemoize,\n useKubernetesObjects,\n} from '@janus-idp/shared-react';\n\nimport {\n kubernetesApiRef,\n kubernetesAuthProvidersApiRef,\n TektonResourcesContextData,\n TektonResponseData,\n} from '../types/types';\nimport { useAllWatchResources } from './useAllWatchResources';\nimport { useResourcesClusters } from './useResourcesClusters';\n\nexport const useTektonObjectsResponse = (\n watchedResource: string[],\n): TektonResourcesContextData => {\n const { entity } = useEntity();\n const { kubernetesObjects, loading, error } = useKubernetesObjects(\n entity,\n kubernetesApiRef,\n kubernetesAuthProvidersApiRef,\n );\n const [selectedCluster, setSelectedCluster] = React.useState<number>(0);\n const [selectedStatus, setSelectedStatus] = React.useState<ComputedStatus>(\n 'All' as ComputedStatus,\n );\n const [isExpanded, setIsExpanded] = React.useState<boolean>(false);\n const [loaded, setLoaded] = React.useState<boolean>(false);\n const [errorState, setErrorState] = React.useState<string>();\n const [pipelinesData, setPipelinesData] = React.useState<\n TektonResponseData | undefined\n >();\n\n const mounted = React.useRef(false);\n\n React.useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n\n const watchResourcesData = useAllWatchResources(\n { kubernetesObjects, loading, error },\n selectedCluster,\n watchedResource,\n );\n\n const resourcesClusters = useResourcesClusters({\n kubernetesObjects,\n loading,\n error,\n });\n\n const updateResults = React.useCallback(\n (\n resData: TektonResponseData,\n isLoading: boolean,\n errorData: string | undefined,\n ) => {\n if (!isLoading && !errorData && mounted.current) {\n setLoaded(true);\n setPipelinesData(prevPipelinesData => {\n if (isEqual(prevPipelinesData, resData)) {\n return prevPipelinesData;\n }\n return resData;\n });\n } else if (errorData && mounted.current) {\n setLoaded(true);\n setErrorState(errorData);\n }\n },\n [setLoaded, setPipelinesData, setErrorState],\n );\n\n const debouncedUpdateResources = useDebounceCallback(updateResults, 250);\n\n React.useEffect(() => {\n debouncedUpdateResources?.(watchResourcesData, loading, error);\n }, [debouncedUpdateResources, watchResourcesData, loading, error]);\n\n return useDeepCompareMemoize({\n watchResourcesData: pipelinesData,\n loaded,\n responseError: errorState,\n selectedClusterErrors: resourcesClusters?.errors?.[selectedCluster] ?? [],\n clusters: resourcesClusters?.clusters || [],\n selectedCluster,\n setSelectedCluster,\n selectedStatus,\n setSelectedStatus,\n isExpanded,\n setIsExpanded,\n });\n};\n"],"names":["React"],"mappings":";;;;;;;;AAqCa,MAAA,wBAAA,GAA2B,CACtC,eAC+B,KAAA;AAC/B,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA;AAC7B,EAAA,MAAM,EAAE,iBAAA,EAAmB,OAAS,EAAA,KAAA,EAAU,GAAA,oBAAA;AAAA,IAC5C,MAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,MAAM,CAAC,eAAiB,EAAA,kBAAkB,CAAI,GAAAA,cAAA,CAAM,SAAiB,CAAC,CAAA;AACtE,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAIA,cAAM,CAAA,QAAA;AAAA,IAChD;AAAA,GACF;AACA,EAAA,MAAM,CAAC,UAAY,EAAA,aAAa,CAAI,GAAAA,cAAA,CAAM,SAAkB,KAAK,CAAA;AACjE,EAAA,MAAM,CAAC,MAAQ,EAAA,SAAS,CAAI,GAAAA,cAAA,CAAM,SAAkB,KAAK,CAAA;AACzD,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAIA,eAAM,QAAiB,EAAA;AAC3D,EAAA,MAAM,CAAC,aAAA,EAAe,gBAA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MAAM;AACpB,IAA2B,wBAAA,GAAA,kBAAA,EAAoB,SAAS,KAAK,CAAA;AAAA,KAC5D,CAAC,wBAAA,EAA0B,kBAAoB,EAAA,OAAA,EAAS,KAAK,CAAC,CAAA;AAEjE,EAAA,OAAO,qBAAsB,CAAA;AAAA,IAC3B,kBAAoB,EAAA,aAAA;AAAA,IACpB,MAAA;AAAA,IACA,aAAe,EAAA,UAAA;AAAA,IACf,qBAAuB,EAAA,iBAAA,EAAmB,MAAS,GAAA,eAAe,KAAK,EAAC;AAAA,IACxE,QAAA,EAAU,iBAAmB,EAAA,QAAA,IAAY,EAAC;AAAA,IAC1C,eAAA;AAAA,IACA,kBAAA;AAAA,IACA,cAAA;AAAA,IACA,iBAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { usePermission } from '@backstage/plugin-permission-react';
|
|
2
|
+
import { tektonViewPermission } from '@backstage-community/plugin-tekton-common';
|
|
3
|
+
|
|
4
|
+
const useTektonViewPermission = () => {
|
|
5
|
+
const tektonViewPermissionResult = usePermission({
|
|
6
|
+
permission: tektonViewPermission
|
|
7
|
+
});
|
|
8
|
+
return tektonViewPermissionResult.allowed;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { useTektonViewPermission };
|
|
12
|
+
//# sourceMappingURL=useTektonViewPermission.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTektonViewPermission.esm.js","sources":["../../src/hooks/useTektonViewPermission.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 { usePermission } from '@backstage/plugin-permission-react';\n\nimport { tektonViewPermission } from '@backstage-community/plugin-tekton-common';\n\nexport const useTektonViewPermission = () => {\n const tektonViewPermissionResult = usePermission({\n permission: tektonViewPermission,\n });\n\n return tektonViewPermissionResult.allowed;\n};\n"],"names":[],"mappings":";;;AAmBO,MAAM,0BAA0B,MAAM;AAC3C,EAAA,MAAM,6BAA6B,aAAc,CAAA;AAAA,IAC/C,UAAY,EAAA;AAAA,GACb,CAAA;AAED,EAAA,OAAO,0BAA2B,CAAA,OAAA;AACpC;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
4
|
+
import { Entity } from '@backstage/catalog-model';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A Tekton plugin.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
declare const tektonPlugin: _backstage_core_plugin_api.BackstagePlugin<{}, {}, {}>;
|
|
12
|
+
/**
|
|
13
|
+
* Component for the catalog entity CI/CD tab.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
declare const TektonCI: () => react.JSX.Element | null;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Returns true if the entity supports the Tekton CI/CD feature and
|
|
21
|
+
* the Tekton CI/CD card should be shown on the CI/CD tab.
|
|
22
|
+
*
|
|
23
|
+
* This means that the catalog entity has one of this annotations set:
|
|
24
|
+
*
|
|
25
|
+
* 1. `tekton.dev/ci-cd: "true"` or
|
|
26
|
+
* 2. `janus-idp.io/tekton` is defined (any value is accepted).
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
declare const isTektonCIAvailable: (entity: Entity) => boolean;
|
|
31
|
+
|
|
32
|
+
export { TektonCI, isTektonCIAvailable, tektonPlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import './types/types.esm.js';
|
|
2
|
+
|
|
3
|
+
const PipelineRunGVK = {
|
|
4
|
+
apiVersion: "v1",
|
|
5
|
+
apiGroup: "tekton.dev",
|
|
6
|
+
kind: "PipelineRun"
|
|
7
|
+
};
|
|
8
|
+
const TaskRunGVK = {
|
|
9
|
+
apiVersion: "v1",
|
|
10
|
+
apiGroup: "tekton.dev",
|
|
11
|
+
kind: "TaskRun"
|
|
12
|
+
};
|
|
13
|
+
var ModelsPlural = /* @__PURE__ */ ((ModelsPlural2) => {
|
|
14
|
+
ModelsPlural2["pipelineruns"] = "pipelineruns";
|
|
15
|
+
ModelsPlural2["taskruns"] = "taskruns";
|
|
16
|
+
ModelsPlural2["pods"] = "pods";
|
|
17
|
+
return ModelsPlural2;
|
|
18
|
+
})(ModelsPlural || {});
|
|
19
|
+
|
|
20
|
+
export { ModelsPlural, PipelineRunGVK, TaskRunGVK };
|
|
21
|
+
//# sourceMappingURL=models.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.esm.js","sources":["../src/models.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 { GroupVersionKind, tektonGroupColor } from './types/types';\n\nexport const PipelineRunGVK: GroupVersionKind = {\n apiVersion: 'v1',\n apiGroup: 'tekton.dev',\n kind: 'PipelineRun',\n};\n\nexport const PipelineRunModel = {\n ...PipelineRunGVK,\n abbr: 'PLR',\n color: tektonGroupColor,\n};\n\nexport const TaskRunGVK: GroupVersionKind = {\n apiVersion: 'v1',\n apiGroup: 'tekton.dev',\n kind: 'TaskRun',\n};\n\nexport enum ModelsPlural {\n pipelineruns = 'pipelineruns',\n taskruns = 'taskruns',\n pods = 'pods',\n}\n\nexport const tektonResourceModels: { [key: string]: GroupVersionKind } = {\n [ModelsPlural.pipelineruns]: PipelineRunGVK,\n [ModelsPlural.taskruns]: TaskRunGVK,\n};\n"],"names":["ModelsPlural"],"mappings":";;AAiBO,MAAM,cAAmC,GAAA;AAAA,EAC9C,UAAY,EAAA,IAAA;AAAA,EACZ,QAAU,EAAA,YAAA;AAAA,EACV,IAAM,EAAA;AACR;AAQO,MAAM,UAA+B,GAAA;AAAA,EAC1C,UAAY,EAAA,IAAA;AAAA,EACZ,QAAU,EAAA,YAAA;AAAA,EACV,IAAM,EAAA;AACR;AAEY,IAAA,YAAA,qBAAAA,aAAL,KAAA;AACL,EAAAA,cAAA,cAAe,CAAA,GAAA,cAAA;AACf,EAAAA,cAAA,UAAW,CAAA,GAAA,UAAA;AACX,EAAAA,cAAA,MAAO,CAAA,GAAA,MAAA;AAHG,EAAAA,OAAAA,aAAAA;AAAA,CAAA,EAAA,YAAA,IAAA,EAAA;;;;"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createPlugin, createApiFactory, gitlabAuthApiRef, googleAuthApiRef, microsoftAuthApiRef, oktaAuthApiRef, oneloginAuthApiRef, discoveryApiRef, fetchApiRef, createComponentExtension } from '@backstage/core-plugin-api';
|
|
2
|
+
import { KubernetesAuthProviders, KubernetesBackendClient, KubernetesProxyClient } from '@backstage/plugin-kubernetes-react';
|
|
3
|
+
import { kubernetesAuthProvidersApiRef, kubernetesApiRef, kubernetesProxyApiRef } from './types/types.esm.js';
|
|
4
|
+
|
|
5
|
+
const tektonPlugin = createPlugin({
|
|
6
|
+
id: "tekton",
|
|
7
|
+
apis: [
|
|
8
|
+
createApiFactory({
|
|
9
|
+
api: kubernetesAuthProvidersApiRef,
|
|
10
|
+
deps: {
|
|
11
|
+
gitlabAuthApi: gitlabAuthApiRef,
|
|
12
|
+
googleAuthApi: googleAuthApiRef,
|
|
13
|
+
microsoftAuthApi: microsoftAuthApiRef,
|
|
14
|
+
oktaAuthApi: oktaAuthApiRef,
|
|
15
|
+
oneloginAuthApi: oneloginAuthApiRef
|
|
16
|
+
},
|
|
17
|
+
factory: ({
|
|
18
|
+
gitlabAuthApi,
|
|
19
|
+
googleAuthApi,
|
|
20
|
+
microsoftAuthApi,
|
|
21
|
+
oktaAuthApi,
|
|
22
|
+
oneloginAuthApi
|
|
23
|
+
}) => {
|
|
24
|
+
const oidcProviders = {
|
|
25
|
+
gitlab: gitlabAuthApi,
|
|
26
|
+
google: googleAuthApi,
|
|
27
|
+
microsoft: microsoftAuthApi,
|
|
28
|
+
okta: oktaAuthApi,
|
|
29
|
+
onelogin: oneloginAuthApi
|
|
30
|
+
};
|
|
31
|
+
return new KubernetesAuthProviders({
|
|
32
|
+
microsoftAuthApi,
|
|
33
|
+
googleAuthApi,
|
|
34
|
+
oidcProviders
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
createApiFactory({
|
|
39
|
+
api: kubernetesApiRef,
|
|
40
|
+
deps: {
|
|
41
|
+
discoveryApi: discoveryApiRef,
|
|
42
|
+
fetchApi: fetchApiRef,
|
|
43
|
+
kubernetesAuthProvidersApi: kubernetesAuthProvidersApiRef
|
|
44
|
+
},
|
|
45
|
+
factory: ({ discoveryApi, fetchApi, kubernetesAuthProvidersApi }) => new KubernetesBackendClient({
|
|
46
|
+
discoveryApi,
|
|
47
|
+
fetchApi,
|
|
48
|
+
kubernetesAuthProvidersApi
|
|
49
|
+
})
|
|
50
|
+
}),
|
|
51
|
+
createApiFactory({
|
|
52
|
+
api: kubernetesProxyApiRef,
|
|
53
|
+
deps: {
|
|
54
|
+
kubernetesApi: kubernetesApiRef
|
|
55
|
+
},
|
|
56
|
+
factory: ({ kubernetesApi }) => new KubernetesProxyClient({
|
|
57
|
+
kubernetesApi
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
const TektonCI = tektonPlugin.provide(
|
|
63
|
+
createComponentExtension({
|
|
64
|
+
name: "TektonCI",
|
|
65
|
+
component: {
|
|
66
|
+
lazy: () => import('./components/Router.esm.js').then((m) => m.Router)
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
export { TektonCI, tektonPlugin };
|
|
72
|
+
//# sourceMappingURL=plugin.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.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 {\n createApiFactory,\n createComponentExtension,\n createPlugin,\n discoveryApiRef,\n fetchApiRef,\n gitlabAuthApiRef,\n googleAuthApiRef,\n microsoftAuthApiRef,\n oktaAuthApiRef,\n oneloginAuthApiRef,\n} from '@backstage/core-plugin-api';\nimport {\n KubernetesAuthProviders,\n KubernetesBackendClient,\n KubernetesProxyClient,\n} from '@backstage/plugin-kubernetes-react';\n\nimport {\n kubernetesApiRef,\n kubernetesAuthProvidersApiRef,\n kubernetesProxyApiRef,\n} from './types/types';\n\n/**\n * A Tekton plugin.\n *\n * @public\n */\nexport const tektonPlugin = createPlugin({\n id: 'tekton',\n apis: [\n createApiFactory({\n api: kubernetesAuthProvidersApiRef,\n deps: {\n gitlabAuthApi: gitlabAuthApiRef,\n googleAuthApi: googleAuthApiRef,\n microsoftAuthApi: microsoftAuthApiRef,\n oktaAuthApi: oktaAuthApiRef,\n oneloginAuthApi: oneloginAuthApiRef,\n },\n factory: ({\n gitlabAuthApi,\n googleAuthApi,\n microsoftAuthApi,\n oktaAuthApi,\n oneloginAuthApi,\n }) => {\n const oidcProviders = {\n gitlab: gitlabAuthApi,\n google: googleAuthApi,\n microsoft: microsoftAuthApi,\n okta: oktaAuthApi,\n onelogin: oneloginAuthApi,\n };\n\n return new KubernetesAuthProviders({\n microsoftAuthApi,\n googleAuthApi,\n oidcProviders,\n });\n },\n }),\n createApiFactory({\n api: kubernetesApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n fetchApi: fetchApiRef,\n kubernetesAuthProvidersApi: kubernetesAuthProvidersApiRef,\n },\n factory: ({ discoveryApi, fetchApi, kubernetesAuthProvidersApi }) =>\n new KubernetesBackendClient({\n discoveryApi,\n fetchApi,\n kubernetesAuthProvidersApi,\n }),\n }),\n createApiFactory({\n api: kubernetesProxyApiRef,\n deps: {\n kubernetesApi: kubernetesApiRef,\n },\n factory: ({ kubernetesApi }) =>\n new KubernetesProxyClient({\n kubernetesApi,\n }),\n }),\n ],\n});\n\n/**\n * Component for the catalog entity CI/CD tab.\n *\n * @public\n */\nexport const TektonCI = tektonPlugin.provide(\n createComponentExtension({\n name: 'TektonCI',\n component: {\n lazy: () => import('./components/Router').then(m => m.Router),\n },\n }),\n);\n"],"names":[],"mappings":";;;;AA4CO,MAAM,eAAe,YAAa,CAAA;AAAA,EACvC,EAAI,EAAA,QAAA;AAAA,EACJ,IAAM,EAAA;AAAA,IACJ,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,6BAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,aAAe,EAAA,gBAAA;AAAA,QACf,aAAe,EAAA,gBAAA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MACT,IAAA,EAAM,MAAM,OAAO,4BAAqB,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,MAAM;AAAA;AAC9D,GACD;AACH;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createApiRef } from '@backstage/core-plugin-api';
|
|
2
|
+
|
|
3
|
+
const tektonGroupColor = "#38812f";
|
|
4
|
+
const kubernetesAuthProvidersApiRef = createApiRef({
|
|
5
|
+
id: "plugin.tekton-kubernetes-auth-providers.service"
|
|
6
|
+
});
|
|
7
|
+
const kubernetesApiRef = createApiRef({
|
|
8
|
+
id: "plugin.tekton-kubernetes.service"
|
|
9
|
+
});
|
|
10
|
+
const kubernetesProxyApiRef = createApiRef({
|
|
11
|
+
id: "plugin.tekton-kubernetes.proxy-service"
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export { kubernetesApiRef, kubernetesAuthProvidersApiRef, kubernetesProxyApiRef, tektonGroupColor };
|
|
15
|
+
//# sourceMappingURL=types.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.esm.js","sources":["../../src/types/types.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 { createApiRef } from '@backstage/core-plugin-api';\nimport {\n KubernetesApi,\n KubernetesAuthProvidersApi,\n KubernetesProxyApi,\n} from '@backstage/plugin-kubernetes-react';\n\nimport { ComputedStatus } from '@janus-idp/shared-react';\n\nexport const tektonGroupColor = '#38812f';\n\nexport type GroupVersionKind = {\n kind: string;\n apiVersion: string;\n apiGroup?: string;\n};\n\nexport type TektonResponseData = {\n [key: string]: { data: any[] };\n};\n\nexport type ClusterError = {\n errorType?: string;\n message?: string;\n resourcePath?: string;\n statusCode?: number;\n};\n\nexport type ClusterErrors = ClusterError[];\n\nexport type TektonResourcesContextData = {\n watchResourcesData?: TektonResponseData;\n loaded?: boolean;\n responseError?: string;\n selectedClusterErrors?: ClusterErrors;\n clusters: string[];\n selectedCluster?: number;\n setSelectedCluster: React.Dispatch<React.SetStateAction<number>>;\n selectedStatus: ComputedStatus;\n setSelectedStatus: React.Dispatch<React.SetStateAction<ComputedStatus>>;\n isExpanded?: boolean;\n setIsExpanded: React.Dispatch<React.SetStateAction<boolean>>;\n};\n\nexport type Order = 'asc' | 'desc';\n\nexport type OpenRowStatus = {\n [x: string]: boolean;\n};\n\nexport type PipelineRunScanResults = {\n vulnerabilities?: {\n critical: number;\n high: number;\n medium: number;\n low: number;\n };\n};\n\nexport const kubernetesAuthProvidersApiRef =\n createApiRef<KubernetesAuthProvidersApi>({\n id: 'plugin.tekton-kubernetes-auth-providers.service',\n });\n\nexport const kubernetesApiRef = createApiRef<KubernetesApi>({\n id: 'plugin.tekton-kubernetes.service',\n});\n\nexport const kubernetesProxyApiRef = createApiRef<KubernetesProxyApi>({\n id: 'plugin.tekton-kubernetes.proxy-service',\n});\n"],"names":[],"mappings":";;AAwBO,MAAM,gBAAmB,GAAA;AAkDzB,MAAM,gCACX,YAAyC,CAAA;AAAA,EACvC,EAAI,EAAA;AACN,CAAC;AAEI,MAAM,mBAAmB,YAA4B,CAAA;AAAA,EAC1D,EAAI,EAAA;AACN,CAAC;AAEM,MAAM,wBAAwB,YAAiC,CAAA;AAAA,EACpE,EAAI,EAAA;AACN,CAAC;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TektonAnnotations } from '@backstage-community/plugin-tekton-common';
|
|
2
|
+
|
|
3
|
+
const DEPRECATED_JANUS_IDP_ANNOTATION = "janus-idp.io/tekton";
|
|
4
|
+
const isTektonCIAvailable = (entity) => entity.metadata.annotations?.[TektonAnnotations.CICD] === "true" || Boolean(entity.metadata.annotations?.[DEPRECATED_JANUS_IDP_ANNOTATION]);
|
|
5
|
+
|
|
6
|
+
export { isTektonCIAvailable };
|
|
7
|
+
//# sourceMappingURL=isTektonCIAvailable.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isTektonCIAvailable.esm.js","sources":["../../src/utils/isTektonCIAvailable.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 { Entity } from '@backstage/catalog-model';\n\nimport { TektonAnnotations } from '@backstage-community/plugin-tekton-common';\n\n/** @deprecated */\nconst DEPRECATED_JANUS_IDP_ANNOTATION = 'janus-idp.io/tekton';\n\n/**\n * Returns true if the entity supports the Tekton CI/CD feature and\n * the Tekton CI/CD card should be shown on the CI/CD tab.\n *\n * This means that the catalog entity has one of this annotations set:\n *\n * 1. `tekton.dev/ci-cd: \"true\"` or\n * 2. `janus-idp.io/tekton` is defined (any value is accepted).\n *\n * @public\n */\nexport const isTektonCIAvailable = (entity: Entity): boolean =>\n entity.metadata.annotations?.[TektonAnnotations.CICD] === 'true' ||\n Boolean(entity.metadata.annotations?.[DEPRECATED_JANUS_IDP_ANNOTATION]);\n"],"names":[],"mappings":";;AAoBA,MAAM,+BAAkC,GAAA,qBAAA;AAajC,MAAM,mBAAsB,GAAA,CAAC,MAClC,KAAA,MAAA,CAAO,SAAS,WAAc,GAAA,iBAAA,CAAkB,IAAI,CAAA,KAAM,UAC1D,OAAQ,CAAA,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,+BAA+B,CAAC;;;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
async function getPodLogs(pods, podLogsGetter, currentClusterName) {
|
|
2
|
+
const containersList = pods.map((pod) => pod?.spec?.containers ?? []);
|
|
3
|
+
const isPodAndContainerAvailable = (pod, container) => !!(pod && container);
|
|
4
|
+
const requests = [];
|
|
5
|
+
containersList.forEach((containers, _idx) => {
|
|
6
|
+
containers.forEach((container) => {
|
|
7
|
+
const pod = pods[_idx];
|
|
8
|
+
if (isPodAndContainerAvailable(pod, container)) {
|
|
9
|
+
const podScope = {
|
|
10
|
+
containerName: container.name,
|
|
11
|
+
podName: pod.metadata?.name ?? "",
|
|
12
|
+
podNamespace: pod.metadata?.namespace ?? "",
|
|
13
|
+
clusterName: currentClusterName
|
|
14
|
+
};
|
|
15
|
+
requests.push(podLogsGetter(podScope));
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
return Promise.all(requests).then((response) => {
|
|
20
|
+
const containerFlatList = containersList.flat(1);
|
|
21
|
+
return response.reduce(
|
|
22
|
+
(acc, r, idx) => {
|
|
23
|
+
const container = containerFlatList[idx];
|
|
24
|
+
return acc.concat(`${container?.name.toLocaleUpperCase("en-US")}
|
|
25
|
+
${r?.text}`).concat(idx === containersList.length - 1 ? "" : "\n");
|
|
26
|
+
},
|
|
27
|
+
""
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { getPodLogs };
|
|
33
|
+
//# sourceMappingURL=log-downloader-utils.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-downloader-utils.esm.js","sources":["../../src/utils/log-downloader-utils.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 { V1Container, V1Pod } from '@kubernetes/client-node';\n\nimport { ContainerScope } from '../hooks/usePodLogsOfPipelineRun';\n\nexport async function getPodLogs(\n pods: V1Pod[] | [],\n podLogsGetter: (podScope: ContainerScope) => Promise<{ text: string }>,\n currentClusterName: string,\n): Promise<string> {\n const containersList = pods.map((pod: V1Pod) => pod?.spec?.containers ?? []);\n const isPodAndContainerAvailable = (\n pod: V1Pod,\n container: V1Container,\n ): boolean => !!(pod && container);\n\n const requests: Promise<{ text: string }>[] = [];\n containersList.forEach((containers: V1Container[], _idx: number) => {\n containers.forEach((container: V1Container) => {\n const pod: V1Pod = pods[_idx];\n if (isPodAndContainerAvailable(pod, container)) {\n const podScope: ContainerScope = {\n containerName: container.name,\n podName: pod.metadata?.name ?? '',\n podNamespace: pod.metadata?.namespace ?? '',\n clusterName: currentClusterName,\n };\n\n requests.push(podLogsGetter(podScope));\n }\n });\n });\n return Promise.all(requests).then(response => {\n const containerFlatList = containersList.flat(1);\n return response.reduce(\n (acc: string, r: { text: string }, idx) => {\n const container: V1Container = containerFlatList[idx];\n return acc\n .concat(`${container?.name.toLocaleUpperCase('en-US')}\\n${r?.text}`)\n .concat(idx === containersList.length - 1 ? '' : '\\n');\n },\n\n '',\n );\n });\n}\n"],"names":[],"mappings":"AAmBsB,eAAA,UAAA,CACpB,IACA,EAAA,aAAA,EACA,kBACiB,EAAA;AACjB,EAAM,MAAA,cAAA,GAAiB,KAAK,GAAI,CAAA,CAAC,QAAe,GAAK,EAAA,IAAA,EAAM,UAAc,IAAA,EAAE,CAAA;AAC3E,EAAA,MAAM,6BAA6B,CACjC,GAAA,EACA,SACY,KAAA,CAAC,EAAE,GAAO,IAAA,SAAA,CAAA;AAExB,EAAA,MAAM,WAAwC,EAAC;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edReasons } from '@janus-idp/shared-react';
|
|
2
|
+
import { calculateDuration } from './tekton-utils.esm.js';
|
|
3
|
+
|
|
4
|
+
const getMatchingStepDuration = (matchingStep) => {
|
|
5
|
+
if (!matchingStep) return "";
|
|
6
|
+
if (matchingStep.terminated) {
|
|
7
|
+
return calculateDuration(
|
|
8
|
+
matchingStep.terminated.startedAt,
|
|
9
|
+
matchingStep.terminated.finishedAt
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
if (matchingStep.running) {
|
|
13
|
+
return calculateDuration(matchingStep.running.startedAt);
|
|
14
|
+
}
|
|
15
|
+
return "";
|
|
16
|
+
};
|
|
17
|
+
const getMatchingStep = (step, status) => {
|
|
18
|
+
const statusSteps = status.steps || [];
|
|
19
|
+
return statusSteps.find((statusStep) => {
|
|
20
|
+
return statusStep.name === step.name || statusStep.name === `step-${step.name}`;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const createStepStatus = (step, status) => {
|
|
24
|
+
let stepRunStatus = ComputedStatus.PipelineNotStarted;
|
|
25
|
+
let duration = null;
|
|
26
|
+
if (!status?.reason) {
|
|
27
|
+
stepRunStatus = ComputedStatus.Cancelled;
|
|
28
|
+
} else if (status.reason === ComputedStatus["In Progress"]) {
|
|
29
|
+
const matchingStep = getMatchingStep(step, status);
|
|
30
|
+
if (!matchingStep) {
|
|
31
|
+
stepRunStatus = ComputedStatus.Pending;
|
|
32
|
+
} else if (matchingStep.terminated) {
|
|
33
|
+
stepRunStatus = matchingStep.terminated.reason === TerminatedReasons.Completed ? ComputedStatus.Succeeded : ComputedStatus.Failed;
|
|
34
|
+
duration = getMatchingStepDuration(matchingStep);
|
|
35
|
+
} else if (matchingStep.running) {
|
|
36
|
+
stepRunStatus = ComputedStatus["In Progress"];
|
|
37
|
+
duration = getMatchingStepDuration(matchingStep);
|
|
38
|
+
} else if (matchingStep.waiting) {
|
|
39
|
+
stepRunStatus = ComputedStatus.Pending;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
stepRunStatus = status.reason;
|
|
43
|
+
duration = getMatchingStepDuration(getMatchingStep(step, status)) || status.duration;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
duration,
|
|
47
|
+
name: step.name,
|
|
48
|
+
status: stepRunStatus
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { createStepStatus };
|
|
53
|
+
//# sourceMappingURL=pipeline-step-utils.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-step-utils.esm.js","sources":["../../src/utils/pipeline-step-utils.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 { ComputedStatus, TerminatedReasons } from '@janus-idp/shared-react';\n\nimport { StepStatus, TaskStatus, TaskStatusStep } from '../types/taskRun';\nimport { calculateDuration } from './tekton-utils';\n\nconst getMatchingStepDuration = (matchingStep?: TaskStatusStep) => {\n if (!matchingStep) return '';\n\n if (matchingStep.terminated) {\n return calculateDuration(\n matchingStep.terminated.startedAt,\n matchingStep.terminated.finishedAt,\n );\n }\n\n if (matchingStep.running) {\n return calculateDuration(matchingStep.running.startedAt);\n }\n\n return '';\n};\n\nconst getMatchingStep = (\n step: { name: string },\n status: TaskStatus,\n): TaskStatusStep | undefined => {\n const statusSteps: TaskStatusStep[] = status.steps || [];\n return statusSteps.find(statusStep => {\n // In rare occasions the status step name is prefixed with `step-`\n // This is likely a bug but this workaround will be temporary as it's investigated separately\n return (\n statusStep.name === step.name || statusStep.name === `step-${step.name}`\n );\n });\n};\n\nexport const createStepStatus = (\n step: { name: string },\n status: TaskStatus,\n): StepStatus => {\n let stepRunStatus = ComputedStatus.PipelineNotStarted;\n let duration = null;\n\n if (!status?.reason) {\n stepRunStatus = ComputedStatus.Cancelled;\n } else if (status.reason === ComputedStatus['In Progress']) {\n // In progress, try to get granular statuses\n const matchingStep = getMatchingStep(step, status);\n\n if (!matchingStep) {\n stepRunStatus = ComputedStatus.Pending;\n } else if (matchingStep.terminated) {\n stepRunStatus =\n matchingStep.terminated.reason === TerminatedReasons.Completed\n ? ComputedStatus.Succeeded\n : ComputedStatus.Failed;\n duration = getMatchingStepDuration(matchingStep);\n } else if (matchingStep.running) {\n stepRunStatus = ComputedStatus['In Progress'];\n duration = getMatchingStepDuration(matchingStep);\n } else if (matchingStep.waiting) {\n stepRunStatus = ComputedStatus.Pending;\n }\n } else {\n // Not in progress, just use the run status reason\n stepRunStatus = status.reason;\n\n duration =\n getMatchingStepDuration(getMatchingStep(step, status)) || status.duration;\n }\n\n return {\n duration,\n name: step.name,\n status: stepRunStatus as any,\n };\n};\n"],"names":[],"mappings":";;;AAoBA,MAAM,uBAAA,GAA0B,CAAC,YAAkC,KAAA;AACjE,EAAI,IAAA,CAAC,cAAqB,OAAA,EAAA;AAE1B,EAAA,IAAI,aAAa,UAAY,EAAA;AAC3B,IAAO,OAAA,iBAAA;AAAA,MACL,aAAa,UAAW,CAAA,SAAA;AAAA,MACxB,aAAa,UAAW,CAAA;AAAA,KAC1B;AAAA;AAGF,EAAA,IAAI,aAAa,OAAS,EAAA;AACxB,IAAO,OAAA,iBAAA,CAAkB,YAAa,CAAA,OAAA,CAAQ,SAAS,CAAA;AAAA;AAGzD,EAAO,OAAA,EAAA;AACT,CAAA;AAEA,MAAM,eAAA,GAAkB,CACtB,IAAA,EACA,MAC+B,KAAA;AAC/B,EAAM,MAAA,WAAA,GAAgC,MAAO,CAAA,KAAA,IAAS,EAAC;AACvD,EAAO,OAAA,WAAA,CAAY,KAAK,CAAc,UAAA,KAAA;AAGp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