@backstage-community/plugin-tekton 3.27.3 → 3.27.5
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 +12 -0
- package/dist/components/Charts/PipelineBars.esm.js.map +1 -1
- package/dist/components/Icons/CriticalRiskIcon.esm.js.map +1 -1
- package/dist/components/Icons/EqualsIcon.esm.js.map +1 -1
- package/dist/components/Icons/LinkToSbomIcon.esm.js.map +1 -1
- package/dist/components/Icons/OutputIcon.esm.js.map +1 -1
- package/dist/components/Icons/SignedBadge.esm.js.map +1 -1
- package/dist/components/Icons/ViewLogsIcon.esm.js.map +1 -1
- package/dist/components/PipelineRunList/PipelineRunColumnHeader.esm.js.map +1 -1
- package/dist/components/PipelineRunList/PipelineRunList.esm.js.map +1 -1
- package/dist/components/PipelineRunList/PipelineRunListSearchBar.esm.js.map +1 -1
- package/dist/components/PipelineRunList/PipelineRunOutput.esm.js +1 -1
- package/dist/components/PipelineRunList/PipelineRunOutput.esm.js.map +1 -1
- package/dist/components/PipelineRunList/PipelineRunRow.esm.js.map +1 -1
- package/dist/components/PipelineRunList/PipelineRunRowActions.esm.js.map +1 -1
- package/dist/components/PipelineRunList/PipelineRunSBOMLink.esm.js.map +1 -1
- package/dist/components/PipelineRunList/PipelineRunTableBody.esm.js.map +1 -1
- package/dist/components/PipelineRunList/PipelineRunTaskStatus.esm.js.map +1 -1
- package/dist/components/PipelineRunList/PipelineRunVulnerabilities.esm.js.map +1 -1
- package/dist/components/PipelineRunList/PipelineTableHeader.esm.js.map +1 -1
- package/dist/components/PipelineRunList/PlrStatus.esm.js.map +1 -1
- package/dist/components/PipelineRunList/ResourceBadge.esm.js.map +1 -1
- package/dist/components/PipelineRunLogs/PipelineRunLogDialog.esm.js.map +1 -1
- package/dist/components/PipelineRunLogs/PipelineRunLogDownloader.esm.js.map +1 -1
- package/dist/components/PipelineRunLogs/PipelineRunLogViewer.esm.js.map +1 -1
- package/dist/components/PipelineRunLogs/PipelineRunLogs.esm.js.map +1 -1
- package/dist/components/PipelineRunLogs/PodLogsDownloadLink.esm.js +1 -1
- package/dist/components/PipelineRunLogs/PodLogsDownloadLink.esm.js.map +1 -1
- package/dist/components/PipelineRunLogs/TaskStatusStepper.esm.js.map +1 -1
- package/dist/components/PipelineRunOutput/PipelineRunOutputDialog.esm.js.map +1 -1
- package/dist/components/Router.esm.js.map +1 -1
- package/dist/components/Tekton/TektonCIComponent.esm.js.map +1 -1
- package/dist/components/common/ClusterSelector.esm.js.map +1 -1
- package/dist/components/common/ErrorPanel.esm.js.map +1 -1
- package/dist/components/common/PermissionAlert.esm.js.map +1 -1
- package/dist/components/common/StatusSelector.esm.js.map +1 -1
- package/dist/components/common/TableExpandCollapse.esm.js.map +1 -1
- package/dist/components/pipeline-topology/PipelineLayout.esm.js.map +1 -1
- package/dist/components/pipeline-topology/PipelineRunVisualization.esm.js.map +1 -1
- package/dist/components/pipeline-topology/PipelineTaskNode.esm.js.map +1 -1
- package/dist/components/pipeline-topology/PipelineVisualization.esm.js.map +1 -1
- package/dist/components/pipeline-topology/PipelineVisualizationStepList.esm.js.map +1 -1
- package/dist/components/pipeline-topology/PipelineVisualizationView.esm.js.map +1 -1
- package/dist/components/pipeline-topology/TaskGroupEdge.esm.js.map +1 -1
- package/dist/components/pipeline-topology/dag.esm.js.map +1 -1
- package/dist/components/pipeline-topology/pipelineComponentFactory.esm.js.map +1 -1
- package/dist/consts/pipeline-topology-const.esm.js.map +1 -1
- package/dist/consts/tekton-const.esm.js.map +1 -1
- package/dist/hooks/TektonResourcesContext.esm.js.map +1 -1
- package/dist/hooks/useAllWatchResources.esm.js.map +1 -1
- package/dist/hooks/useDarkTheme.esm.js.map +1 -1
- package/dist/hooks/usePipelineRunScanResults.esm.js.map +1 -1
- package/dist/hooks/usePodLogsOfPipelineRun.esm.js +1 -1
- package/dist/hooks/usePodLogsOfPipelineRun.esm.js.map +1 -1
- package/dist/hooks/useResourcesClusters.esm.js.map +1 -1
- package/dist/hooks/useTektonObjectsResponse.esm.js +3 -7
- package/dist/hooks/useTektonObjectsResponse.esm.js.map +1 -1
- package/dist/hooks/useTektonViewPermission.esm.js.map +1 -1
- package/dist/models.esm.js +0 -2
- package/dist/models.esm.js.map +1 -1
- package/dist/node_modules_dist/style-inject/dist/style-inject.es.esm.js.map +1 -1
- package/dist/plugin.esm.js +2 -58
- package/dist/plugin.esm.js.map +1 -1
- package/dist/translation.esm.js.map +1 -1
- package/dist/types/types.esm.js +1 -12
- package/dist/types/types.esm.js.map +1 -1
- package/dist/utils/download-log-file-utils.esm.js.map +1 -1
- package/dist/utils/isTektonCIAvailable.esm.js.map +1 -1
- package/dist/utils/log-downloader-utils.esm.js.map +1 -1
- package/dist/utils/pipeline-step-utils.esm.js.map +1 -1
- package/dist/utils/pipeline-topology-utils.esm.js.map +1 -1
- package/dist/utils/pipelineRun-utils.esm.js.map +1 -1
- package/dist/utils/taskRun-utils.esm.js.map +1 -1
- package/dist/utils/tekton-utils.esm.js.map +1 -1
- package/package.json +2 -8
package/dist/plugin.esm.js.map
CHANGED
|
@@ -1 +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
|
|
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 createComponentExtension,\n createPlugin,\n} from '@backstage/core-plugin-api';\n\n/**\n * A Tekton plugin.\n *\n * @public\n */\nexport const tektonPlugin = createPlugin({\n id: 'tekton',\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":";;AAyBO,MAAM,eAAe,YAAA,CAAa;AAAA,EACvC,EAAA,EAAI;AACN,CAAC;AAOM,MAAM,WAAW,YAAA,CAAa,OAAA;AAAA,EACnC,wBAAA,CAAyB;AAAA,IACvB,IAAA,EAAM,UAAA;AAAA,IACN,SAAA,EAAW;AAAA,MACT,IAAA,EAAM,MAAM,OAAO,4BAAqB,EAAE,IAAA,CAAK,CAAA,CAAA,KAAK,EAAE,MAAM;AAAA;AAC9D,GACD;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation.esm.js","sources":["../src/translation.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\n\nimport { createTranslationRef } from '@backstage/core-plugin-api/alpha';\n\n/**\n * Tekton translation reference.\n * @public\n */\nexport const tektonTranslationRef = createTranslationRef({\n id: 'tekton',\n messages: {\n errorPanel: {\n title: 'There was a problem retrieving Kubernetes objects',\n description:\n 'There was a problem retrieving some Kubernetes resources for the entity: {{entityName}}. This could mean that the Error Reporting card is not completely accurate.',\n },\n permissionAlert: {\n title: 'Permission required',\n description:\n 'To view Tekton Pipeline Runs, contact your administrator to give you the following permission(s): {{permissions}}.',\n },\n statusSelector: {\n label: 'Status',\n },\n tableExpandCollapse: {\n collapseAll: 'Collapse all',\n expandAll: 'Expand all',\n },\n pipelineVisualization: {\n emptyState: {\n description: 'No Pipeline Run to visualize',\n },\n noTasksDescription: 'This Pipeline Run has no tasks to visualize',\n stepList: {\n finallyTaskTitle: 'Finally Task',\n },\n },\n pipelineRunList: {\n title: 'Pipeline Runs',\n noPipelineRuns: 'No Pipeline Runs found',\n searchBarPlaceholder: 'Search',\n rowActions: {\n viewLogs: 'View logs',\n unauthorizedViewLogs: 'Unauthorized to view logs',\n viewSBOM: 'View SBOM',\n SBOMNotApplicable: 'View SBOM is not applicable for this PipelineRun',\n viewOutput: 'View output',\n outputNotApplicable:\n 'View Output is not applicable for this PipelineRun',\n },\n vulnerabilitySeverityTitle: {\n critical: 'Critical',\n high: 'High',\n medium: 'Medium',\n low: 'Low',\n },\n tableHeaderTitle: {\n name: 'NAME',\n vulnerabilities: 'VULNERABILITIES',\n status: 'STATUS',\n taskStatus: 'TASK STATUS',\n startTime: 'STARTED',\n duration: 'DURATION',\n actions: 'ACTIONS',\n },\n },\n pipelineRunLogs: {\n title: 'PipelineRun Logs',\n noLogs: 'No logs found',\n downloader: {\n downloadTaskLogs: 'Download',\n downloadPipelineRunLogs: 'Download all tasks logs',\n },\n podLogsDownloadLink: {\n title: 'Download',\n downloading: 'downloading logs',\n },\n taskStatusStepper: {\n skipped: 'Skipped',\n },\n },\n pipelineRunOutput: {\n title: 'PipelineRun Output',\n noOutput: 'No output',\n },\n pipelineRunStatus: {\n All: 'All',\n Cancelling: 'Cancelling',\n Succeeded: 'Succeeded',\n Failed: 'Failed',\n Running: 'Running',\n 'In Progress': 'In Progress',\n FailedToStart: 'FailedToStart',\n PipelineNotStarted: 'PipelineNotStarted',\n Skipped: 'Skipped',\n Cancelled: 'Cancelled',\n Pending: 'Pending',\n Idle: 'Idle',\n Other: 'Other',\n },\n pipelineRunDuration: {\n lessThanSec: 'less than a sec',\n hour_one: '{{count}} hour',\n hour_other: '{{count}} hours',\n minute_one: '{{count}} minute',\n minute_other: '{{count}} minutes',\n second_one: '{{count}} second',\n second_other: '{{count}} seconds',\n },\n },\n});\n"],"names":[],"mappings":";;AAsBO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"translation.esm.js","sources":["../src/translation.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\n\nimport { createTranslationRef } from '@backstage/core-plugin-api/alpha';\n\n/**\n * Tekton translation reference.\n * @public\n */\nexport const tektonTranslationRef = createTranslationRef({\n id: 'tekton',\n messages: {\n errorPanel: {\n title: 'There was a problem retrieving Kubernetes objects',\n description:\n 'There was a problem retrieving some Kubernetes resources for the entity: {{entityName}}. This could mean that the Error Reporting card is not completely accurate.',\n },\n permissionAlert: {\n title: 'Permission required',\n description:\n 'To view Tekton Pipeline Runs, contact your administrator to give you the following permission(s): {{permissions}}.',\n },\n statusSelector: {\n label: 'Status',\n },\n tableExpandCollapse: {\n collapseAll: 'Collapse all',\n expandAll: 'Expand all',\n },\n pipelineVisualization: {\n emptyState: {\n description: 'No Pipeline Run to visualize',\n },\n noTasksDescription: 'This Pipeline Run has no tasks to visualize',\n stepList: {\n finallyTaskTitle: 'Finally Task',\n },\n },\n pipelineRunList: {\n title: 'Pipeline Runs',\n noPipelineRuns: 'No Pipeline Runs found',\n searchBarPlaceholder: 'Search',\n rowActions: {\n viewLogs: 'View logs',\n unauthorizedViewLogs: 'Unauthorized to view logs',\n viewSBOM: 'View SBOM',\n SBOMNotApplicable: 'View SBOM is not applicable for this PipelineRun',\n viewOutput: 'View output',\n outputNotApplicable:\n 'View Output is not applicable for this PipelineRun',\n },\n vulnerabilitySeverityTitle: {\n critical: 'Critical',\n high: 'High',\n medium: 'Medium',\n low: 'Low',\n },\n tableHeaderTitle: {\n name: 'NAME',\n vulnerabilities: 'VULNERABILITIES',\n status: 'STATUS',\n taskStatus: 'TASK STATUS',\n startTime: 'STARTED',\n duration: 'DURATION',\n actions: 'ACTIONS',\n },\n },\n pipelineRunLogs: {\n title: 'PipelineRun Logs',\n noLogs: 'No logs found',\n downloader: {\n downloadTaskLogs: 'Download',\n downloadPipelineRunLogs: 'Download all tasks logs',\n },\n podLogsDownloadLink: {\n title: 'Download',\n downloading: 'downloading logs',\n },\n taskStatusStepper: {\n skipped: 'Skipped',\n },\n },\n pipelineRunOutput: {\n title: 'PipelineRun Output',\n noOutput: 'No output',\n },\n pipelineRunStatus: {\n All: 'All',\n Cancelling: 'Cancelling',\n Succeeded: 'Succeeded',\n Failed: 'Failed',\n Running: 'Running',\n 'In Progress': 'In Progress',\n FailedToStart: 'FailedToStart',\n PipelineNotStarted: 'PipelineNotStarted',\n Skipped: 'Skipped',\n Cancelled: 'Cancelled',\n Pending: 'Pending',\n Idle: 'Idle',\n Other: 'Other',\n },\n pipelineRunDuration: {\n lessThanSec: 'less than a sec',\n hour_one: '{{count}} hour',\n hour_other: '{{count}} hours',\n minute_one: '{{count}} minute',\n minute_other: '{{count}} minutes',\n second_one: '{{count}} second',\n second_other: '{{count}} seconds',\n },\n },\n});\n"],"names":[],"mappings":";;AAsBO,MAAM,uBAAuB,oBAAA,CAAqB;AAAA,EACvD,EAAA,EAAI,QAAA;AAAA,EACJ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GroupColor = "#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
2
|
|
|
14
|
-
export {
|
|
3
|
+
export { tektonGroupColor };
|
|
15
4
|
//# sourceMappingURL=types.esm.js.map
|
|
@@ -1 +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 {
|
|
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 */\n\nimport { Dispatch, SetStateAction } from '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: Dispatch<SetStateAction<number>>;\n selectedStatus: ComputedStatus;\n setSelectedStatus: Dispatch<SetStateAction<ComputedStatus>>;\n isExpanded?: boolean;\n setIsExpanded: Dispatch<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"],"names":[],"mappings":"AAoBO,MAAM,gBAAA,GAAmB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download-log-file-utils.esm.js","sources":["../../src/utils/download-log-file-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 */\n/**\n * Triggers a download of the given string data as a file with the specified filename.\n *\n * @param data - The content to download\n * @param filename - The name of the file to save as\n */\nexport const downloadLogFile = (data: string, filename: string) => {\n const blob = new Blob([data], { type: 'text/plain;charset=utf-8' });\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = filename;\n link.click();\n URL.revokeObjectURL(url);\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"download-log-file-utils.esm.js","sources":["../../src/utils/download-log-file-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 */\n/**\n * Triggers a download of the given string data as a file with the specified filename.\n *\n * @param data - The content to download\n * @param filename - The name of the file to save as\n */\nexport const downloadLogFile = (data: string, filename: string) => {\n const blob = new Blob([data], { type: 'text/plain;charset=utf-8' });\n const url = URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = filename;\n link.click();\n URL.revokeObjectURL(url);\n};\n"],"names":[],"mappings":"AAqBO,MAAM,eAAA,GAAkB,CAAC,IAAA,EAAc,QAAA,KAAqB;AACjE,EAAA,MAAM,IAAA,GAAO,IAAI,IAAA,CAAK,CAAC,IAAI,CAAA,EAAG,EAAE,IAAA,EAAM,0BAAA,EAA4B,CAAA;AAClE,EAAA,MAAM,GAAA,GAAM,GAAA,CAAI,eAAA,CAAgB,IAAI,CAAA;AACpC,EAAA,MAAM,IAAA,GAAO,QAAA,CAAS,aAAA,CAAc,GAAG,CAAA;AACvC,EAAA,IAAA,CAAK,IAAA,GAAO,GAAA;AACZ,EAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAChB,EAAA,IAAA,CAAK,KAAA,EAAM;AACX,EAAA,GAAA,CAAI,gBAAgB,GAAG,CAAA;AACzB;;;;"}
|
|
@@ -1 +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,+
|
|
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,+BAAA,GAAkC,qBAAA;AAajC,MAAM,mBAAA,GAAsB,CAAC,MAAA,KAClC,MAAA,CAAO,SAAS,WAAA,GAAc,iBAAA,CAAkB,IAAI,CAAA,KAAM,UAC1D,OAAA,CAAQ,MAAA,CAAO,QAAA,CAAS,WAAA,GAAc,+BAA+B,CAAC;;;;"}
|
|
@@ -1 +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":"
|
|
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":"AAmBA,eAAsB,UAAA,CACpB,IAAA,EACA,aAAA,EACA,kBAAA,EACiB;AACjB,EAAA,MAAM,cAAA,GAAiB,KAAK,GAAA,CAAI,CAAC,QAAe,GAAA,EAAK,IAAA,EAAM,UAAA,IAAc,EAAE,CAAA;AAC3E,EAAA,MAAM,6BAA6B,CACjC,GAAA,EACA,SAAA,KACY,CAAC,EAAE,GAAA,IAAO,SAAA,CAAA;AAExB,EAAA,MAAM,WAAwC,EAAC;AAC/C,EAAA,cAAA,CAAe,OAAA,CAAQ,CAAC,UAAA,EAA2B,IAAA,KAAiB;AAClE,IAAA,UAAA,CAAW,OAAA,CAAQ,CAAC,SAAA,KAA2B;AAC7C,MAAA,MAAM,GAAA,GAAa,KAAK,IAAI,CAAA;AAC5B,MAAA,IAAI,0BAAA,CAA2B,GAAA,EAAK,SAAS,CAAA,EAAG;AAC9C,QAAA,MAAM,QAAA,GAA2B;AAAA,UAC/B,eAAe,SAAA,CAAU,IAAA;AAAA,UACzB,OAAA,EAAS,GAAA,CAAI,QAAA,EAAU,IAAA,IAAQ,EAAA;AAAA,UAC/B,YAAA,EAAc,GAAA,CAAI,QAAA,EAAU,SAAA,IAAa,EAAA;AAAA,UACzC,WAAA,EAAa;AAAA,SACf;AAEA,QAAA,QAAA,CAAS,IAAA,CAAK,aAAA,CAAc,QAAQ,CAAC,CAAA;AAAA,MACvC;AAAA,IACF,CAAC,CAAA;AAAA,EACH,CAAC,CAAA;AACD,EAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,QAAQ,CAAA,CAAE,KAAK,CAAA,QAAA,KAAY;AAC5C,IAAA,MAAM,iBAAA,GAAoB,cAAA,CAAe,IAAA,CAAK,CAAC,CAAA;AAC/C,IAAA,OAAO,QAAA,CAAS,MAAA;AAAA,MACd,CAAC,GAAA,EAAa,CAAA,EAAqB,GAAA,KAAQ;AACzC,QAAA,MAAM,SAAA,GAAyB,kBAAkB,GAAG,CAAA;AACpD,QAAA,OAAO,IACJ,MAAA,CAAO,CAAA,EAAG,WAAW,IAAA,CAAK,iBAAA,CAAkB,OAAO,CAAC;AAAA,EAAK,CAAA,EAAG,IAAI,CAAA,CAAE,CAAA,CAClE,MAAA,CAAO,QAAQ,cAAA,CAAe,MAAA,GAAS,CAAA,GAAI,EAAA,GAAK,IAAI,CAAA;AAAA,MACzD,CAAA;AAAA,MAEA;AAAA,KACF;AAAA,EACF,CAAC,CAAA;AACH;;;;"}
|
|
@@ -1 +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';\nimport { TranslationFunction } from '@backstage/core-plugin-api/alpha';\nimport { tektonTranslationRef } from '../translation';\n\nconst getMatchingStepDuration = (\n t: TranslationFunction<typeof tektonTranslationRef.T>,\n matchingStep?: TaskStatusStep,\n) => {\n if (!matchingStep) return '';\n\n if (matchingStep.terminated) {\n return calculateDuration(\n t,\n matchingStep.terminated.startedAt,\n matchingStep.terminated.finishedAt,\n );\n }\n\n if (matchingStep.running) {\n return calculateDuration(t, 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 t: TranslationFunction<typeof tektonTranslationRef.T>,\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(t, matchingStep);\n } else if (matchingStep.running) {\n stepRunStatus = ComputedStatus['In Progress'];\n duration = getMatchingStepDuration(t, 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(t, getMatchingStep(step, status)) ||\n status.duration;\n }\n\n return {\n duration,\n name: step.name,\n status: stepRunStatus as any,\n };\n};\n"],"names":[],"mappings":";;;AAsBA,MAAM,uBAAA,GAA0B,CAC9B,CAAA,EACA,
|
|
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';\nimport { TranslationFunction } from '@backstage/core-plugin-api/alpha';\nimport { tektonTranslationRef } from '../translation';\n\nconst getMatchingStepDuration = (\n t: TranslationFunction<typeof tektonTranslationRef.T>,\n matchingStep?: TaskStatusStep,\n) => {\n if (!matchingStep) return '';\n\n if (matchingStep.terminated) {\n return calculateDuration(\n t,\n matchingStep.terminated.startedAt,\n matchingStep.terminated.finishedAt,\n );\n }\n\n if (matchingStep.running) {\n return calculateDuration(t, 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 t: TranslationFunction<typeof tektonTranslationRef.T>,\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(t, matchingStep);\n } else if (matchingStep.running) {\n stepRunStatus = ComputedStatus['In Progress'];\n duration = getMatchingStepDuration(t, 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(t, getMatchingStep(step, status)) ||\n status.duration;\n }\n\n return {\n duration,\n name: step.name,\n status: stepRunStatus as any,\n };\n};\n"],"names":[],"mappings":";;;AAsBA,MAAM,uBAAA,GAA0B,CAC9B,CAAA,EACA,YAAA,KACG;AACH,EAAA,IAAI,CAAC,cAAc,OAAO,EAAA;AAE1B,EAAA,IAAI,aAAa,UAAA,EAAY;AAC3B,IAAA,OAAO,iBAAA;AAAA,MACL,CAAA;AAAA,MACA,aAAa,UAAA,CAAW,SAAA;AAAA,MACxB,aAAa,UAAA,CAAW;AAAA,KAC1B;AAAA,EACF;AAEA,EAAA,IAAI,aAAa,OAAA,EAAS;AACxB,IAAA,OAAO,iBAAA,CAAkB,CAAA,EAAG,YAAA,CAAa,OAAA,CAAQ,SAAS,CAAA;AAAA,EAC5D;AAEA,EAAA,OAAO,EAAA;AACT,CAAA;AAEA,MAAM,eAAA,GAAkB,CACtB,IAAA,EACA,MAAA,KAC+B;AAC/B,EAAA,MAAM,WAAA,GAAgC,MAAA,CAAO,KAAA,IAAS,EAAC;AACvD,EAAA,OAAO,WAAA,CAAY,KAAK,CAAA,UAAA,KAAc;AAGpC,IAAA,OACE,UAAA,CAAW,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AAA,EACX;AAEA,EAAA,OAAO;AAAA,IACL,QAAA;AAAA,IACA,MAAM,IAAA,CAAK,IAAA;AAAA,IACX,MAAA,EAAQ;AAAA,GACV;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-topology-utils.esm.js","sources":["../../src/utils/pipeline-topology-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 {\n EdgeModel,\n getEdgesFromNodes,\n getSpacerNodes,\n GraphModel,\n ModelKind,\n RunStatus,\n WhenStatus,\n} from '@patternfly/react-topology';\nimport * as dagre from 'dagre';\nimport { minBy, uniq } from 'lodash';\n\nimport {\n ComputedStatus,\n PipelineRunKind,\n PipelineTask,\n PipelineTaskParam,\n PipelineTaskWithStatus,\n TaskRunKind,\n} from '@janus-idp/shared-react';\n\nimport { DAG, Vertex } from '../components/pipeline-topology/dag';\nimport {\n DAGRE_BUILDER_PROPS,\n DAGRE_BUILDER_SPACED_PROPS,\n DAGRE_VIEWER_PROPS,\n DAGRE_VIEWER_SPACED_PROPS,\n DEFAULT_BADGE_WIDTH,\n DEFAULT_FINALLLY_GROUP_PADDING,\n DEFAULT_NODE_HEIGHT,\n DEFAULT_NODE_ICON_WIDTH,\n FINALLY_NODE_PADDING,\n NODE_HEIGHT,\n NODE_PADDING,\n NODE_WIDTH,\n NodeType,\n PipelineLayout,\n REGEX_EXTRACT_DEPS,\n WHEN_EXPRESSION_SPACING,\n} from '../consts/pipeline-topology-const';\nimport {\n FinallyNodeModel,\n LoadingNodeModel,\n NodeCreator,\n NodeCreatorSetup,\n PipelineEdgeModel,\n PipelineMixedNodeModel,\n PipelineRunAfterNodeModelData,\n} from '../types/pipeline-topology-types';\nimport { appendPipelineRunStatus, getPLRTaskRuns } from './pipelineRun-utils';\n\nconst createGenericNode: NodeCreatorSetup =\n (type, width?, height?) => (name, data) => ({\n id: name,\n label: data?.label || name,\n runAfterTasks: data?.runAfterTasks || [],\n ...(data && { data }),\n height: height ?? NODE_HEIGHT,\n width: width ?? NODE_WIDTH,\n type,\n });\n\nconst getMaxFinallyNode = (finallyTaskList: PipelineTaskWithStatus[]) => {\n const sortedFinallyTaskList = [...finallyTaskList].sort(\n (a, b) => b.name.length - a.name.length,\n );\n return sortedFinallyTaskList[0]?.name || '';\n};\n\nexport const createFinallyNode = (\n height: number,\n): NodeCreator<FinallyNodeModel> =>\n createGenericNode(\n NodeType.FINALLY_NODE,\n NODE_WIDTH + WHEN_EXPRESSION_SPACING + FINALLY_NODE_PADDING * 2,\n height,\n );\n\nexport const createLoadingNode: NodeCreator<LoadingNodeModel> =\n createGenericNode(NodeType.LOADING_NODE);\n\nconst createPipelineTaskNode = (\n type: NodeType,\n data: PipelineRunAfterNodeModelData,\n) => createGenericNode(type, data.width, data.height)(data.id ?? '', data);\n\nexport const getTextWidth = (\n text: string,\n font: string = '0.8rem RedHatText',\n): number => {\n if (!text || text.length === 0) {\n return 0;\n }\n const canvas = document.createElement('canvas');\n const context = canvas.getContext('2d');\n if (!context) {\n return text.length;\n }\n context.font = font;\n const { width } = context.measureText(text);\n return width;\n};\n\nexport const extractDepsFromContextVariables = (\n contextVariable: string | null | undefined,\n) => {\n let matches;\n const deps: string[] = [];\n if (!contextVariable) {\n return deps;\n }\n // eslint-disable-next-line no-cond-assign\n while ((matches = REGEX_EXTRACT_DEPS.exec(contextVariable)) !== null) {\n // This is necessary to avoid infinite loops with zero-width matches\n if (matches.index === REGEX_EXTRACT_DEPS.lastIndex) {\n REGEX_EXTRACT_DEPS.lastIndex++;\n }\n if (matches) {\n if (!deps.includes(matches[1])) {\n deps.push(matches[1]);\n }\n }\n }\n return deps;\n};\n\nexport const getSpacerNode = (\n node: PipelineMixedNodeModel,\n): PipelineMixedNodeModel => ({\n ...node,\n height: 1,\n width: 1,\n});\n\nexport const getWhenStatus = (\n status: ComputedStatus,\n): WhenStatus | undefined => {\n switch (status) {\n case ComputedStatus.Succeeded:\n case ComputedStatus.Failed:\n return WhenStatus.Met;\n case ComputedStatus.Skipped:\n case ComputedStatus['In Progress']:\n case ComputedStatus.Idle:\n return WhenStatus.Unmet;\n default:\n return undefined;\n }\n};\n\nexport const getTaskWhenStatus = (\n task: PipelineTaskWithStatus,\n): WhenStatus | undefined => {\n if (!task.when) {\n return undefined;\n }\n return getWhenStatus(task.status?.reason as ComputedStatus);\n};\n\nconst getDepsFromContextVariables = (task: PipelineTask) => {\n const depsFromContextVariables: string[] = [];\n if (task.params) {\n task.params.forEach((p: PipelineTaskParam) => {\n if (Array.isArray(p.value)) {\n p.value.forEach(paramValue => {\n depsFromContextVariables.push(\n ...extractDepsFromContextVariables(paramValue),\n );\n });\n } else {\n depsFromContextVariables.push(\n ...extractDepsFromContextVariables(p.value),\n );\n }\n });\n }\n if (task?.when) {\n task.when.forEach(({ input, values }) => {\n depsFromContextVariables.push(...extractDepsFromContextVariables(input));\n values.forEach((whenValue: string) => {\n depsFromContextVariables.push(\n ...extractDepsFromContextVariables(whenValue),\n );\n });\n });\n }\n return depsFromContextVariables;\n};\n\nconst getRunAfterTasks = (task: PipelineTask, dag: DAG, vertex: Vertex) => {\n const runAfterTasks: string[] = [];\n const depsFromContextVariables = getDepsFromContextVariables(task);\n\n const dependancies = uniq([...vertex.dependancyNames]);\n if (dependancies) {\n dependancies.forEach(dep => {\n const depObj = dag.vertices.get(dep) as Vertex;\n if (\n depObj.level - vertex.level <= 1 ||\n vertex.data.runAfter?.includes(depObj.name)\n ) {\n runAfterTasks.push(dep);\n }\n });\n }\n if (depsFromContextVariables.length > 0) {\n const v = depsFromContextVariables.map(d => {\n return dag.vertices.get(d) as Vertex;\n });\n const minLevelDep = minBy(v, (d: Vertex) => d.level) as Vertex;\n const nearestDeps = v.filter(v1 => v1.level === minLevelDep.level);\n nearestDeps.forEach(nd => {\n if (nd.level - vertex.level <= 1 || vertex.dependancyNames.length === 0) {\n runAfterTasks.push(nd.name);\n }\n });\n }\n return runAfterTasks;\n};\n\nexport const getGraphDataModel = (\n pipelineRun: PipelineRunKind | undefined,\n taskRuns: TaskRunKind[],\n): {\n graph: GraphModel;\n nodes: PipelineMixedNodeModel[];\n edges: EdgeModel[];\n} | null => {\n if (!pipelineRun) {\n return null;\n }\n\n const plrTaskRuns = getPLRTaskRuns(taskRuns, pipelineRun?.metadata?.name);\n\n const taskList = appendPipelineRunStatus(pipelineRun, plrTaskRuns);\n\n const dag = new DAG();\n taskList?.forEach((task: PipelineTask) => {\n dag.addEdges(task.name, task, '', task.runAfter || []);\n });\n\n const nodes: PipelineMixedNodeModel[] = [];\n const maxWidthForLevel: { [key: string]: number } = {};\n dag.topologicalSort((v: Vertex) => {\n if (!maxWidthForLevel[v.level]) {\n maxWidthForLevel[v.level] = getTextWidth(v.name);\n } else {\n maxWidthForLevel[v.level] = Math.max(\n maxWidthForLevel[v.level],\n getTextWidth(v.name),\n );\n }\n });\n dag.topologicalSort((vertex: Vertex) => {\n const task = vertex.data as PipelineTask;\n const runAfterTasks = getRunAfterTasks(task, dag, vertex);\n const badgePadding =\n Object.keys(pipelineRun.spec)?.length > 0 ? DEFAULT_BADGE_WIDTH : 0;\n const isTaskSkipped = pipelineRun?.status?.skippedTasks?.some(\n t => t.name === task.name,\n );\n nodes.push(\n createPipelineTaskNode(NodeType.TASK_NODE, {\n id: vertex.name,\n label: vertex.name,\n width:\n maxWidthForLevel[vertex.level] +\n NODE_PADDING * 2 +\n DEFAULT_NODE_ICON_WIDTH +\n badgePadding,\n runAfterTasks,\n status: isTaskSkipped ? RunStatus.Skipped : vertex.data.status?.reason,\n whenStatus: getTaskWhenStatus(vertex.data),\n task: vertex.data,\n pipelineRun,\n }),\n );\n });\n\n const finallyTaskList = appendPipelineRunStatus(\n pipelineRun,\n plrTaskRuns,\n true,\n );\n\n const finallyNodes = finallyTaskList.map(fTask => {\n const isTaskSkipped = pipelineRun?.status?.skippedTasks?.some(\n t => t.name === fTask.name,\n );\n\n return createPipelineTaskNode(NodeType.FINALLY_NODE, {\n id: fTask.name,\n label: fTask.name,\n width:\n getTextWidth(getMaxFinallyNode(finallyTaskList)) +\n NODE_PADDING * 2 +\n DEFAULT_FINALLLY_GROUP_PADDING * 2,\n height: DEFAULT_NODE_HEIGHT,\n runAfterTasks: [],\n status: isTaskSkipped\n ? RunStatus.Skipped\n : (fTask.status?.reason as RunStatus),\n whenStatus: getTaskWhenStatus(fTask),\n task: fTask,\n pipelineRun,\n });\n });\n\n const finallyGroup = finallyNodes.length\n ? [\n {\n id: 'finally-group-id',\n type: NodeType.FINALLY_GROUP,\n children: finallyNodes.map(n => n.id),\n group: true,\n style: { padding: DEFAULT_FINALLLY_GROUP_PADDING },\n },\n ]\n : [];\n const spacerNodes: PipelineMixedNodeModel[] = (\n getSpacerNodes([...nodes, ...finallyNodes], NodeType.SPACER_NODE, [\n NodeType.FINALLY_NODE,\n ]) as PipelineMixedNodeModel[]\n ).map(getSpacerNode);\n\n const edges: PipelineEdgeModel[] = getEdgesFromNodes(\n [...nodes, ...spacerNodes, ...finallyNodes],\n NodeType.SPACER_NODE,\n NodeType.EDGE,\n NodeType.EDGE,\n [NodeType.FINALLY_NODE],\n NodeType.EDGE,\n );\n\n return {\n graph: {\n id: `${pipelineRun?.metadata?.name}-graph`,\n type: ModelKind.graph,\n layout: PipelineLayout.DAGRE_VIEWER,\n scaleExtent: [0.5, 1],\n },\n nodes: [\n ...nodes,\n ...spacerNodes,\n ...finallyNodes,\n ...finallyGroup,\n ] as PipelineMixedNodeModel[],\n edges,\n };\n};\n\nexport const getLayoutData = (\n layout: PipelineLayout,\n): dagre.GraphLabel | null => {\n switch (layout) {\n case PipelineLayout.DAGRE_BUILDER:\n return DAGRE_BUILDER_PROPS;\n case PipelineLayout.DAGRE_VIEWER:\n return DAGRE_VIEWER_PROPS;\n case PipelineLayout.DAGRE_VIEWER_SPACED:\n return DAGRE_VIEWER_SPACED_PROPS;\n case PipelineLayout.DAGRE_BUILDER_SPACED:\n return DAGRE_BUILDER_SPACED_PROPS;\n default:\n return null;\n }\n};\n"],"names":[],"mappings":";;;;;;;AAkEA,MAAM,oBACJ,CAAC,IAAA,EAAM,OAAQ,MAAY,KAAA,CAAC,MAAM,IAAU,MAAA;AAAA,EAC1C,EAAI,EAAA,IAAA;AAAA,EACJ,KAAA,EAAO,MAAM,KAAS,IAAA,IAAA;AAAA,EACtB,aAAA,EAAe,IAAM,EAAA,aAAA,IAAiB,EAAC;AAAA,EACvC,GAAI,IAAQ,IAAA,EAAE,IAAK,EAAA;AAAA,EACnB,QAAQ,MAAU,IAAA,WAAA;AAAA,EAClB,OAAO,KAAS,IAAA,UAAA;AAAA,EAChB;AACF,CAAA,CAAA;AAEF,MAAM,iBAAA,GAAoB,CAAC,eAA8C,KAAA;AACvE,EAAA,MAAM,qBAAwB,GAAA,CAAC,GAAG,eAAe,CAAE,CAAA,IAAA;AAAA,IACjD,CAAC,CAAG,EAAA,CAAA,KAAM,EAAE,IAAK,CAAA,MAAA,GAAS,EAAE,IAAK,CAAA;AAAA,GACnC;AACA,EAAO,OAAA,qBAAA,CAAsB,CAAC,CAAA,EAAG,IAAQ,IAAA,EAAA;AAC3C,CAAA;AAYE,iBAAkB,CAAA,QAAA,CAAS,YAAY;AAEzC,MAAM,sBAAyB,GAAA,CAC7B,IACA,EAAA,IAAA,KACG,kBAAkB,IAAM,EAAA,IAAA,CAAK,KAAO,EAAA,IAAA,CAAK,MAAM,CAAA,CAAE,IAAK,CAAA,EAAA,IAAM,IAAI,IAAI,CAAA;AAElE,MAAM,YAAe,GAAA,CAC1B,IACA,EAAA,IAAA,GAAe,mBACJ,KAAA;AACX,EAAA,IAAI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;AAAA,IACT,QAAS,CAAA,IAAA;AAAA,IACT,CAAC,SAAS,YAAY,CAAA;AAAA,IACtB,QAAS,CAAA;AAAA,GACX;AAEA,EAAO,OAAA;AAAA,IACL,KAAO,EAAA;AAAA,MACL,EAAI,EAAA,CAAA,EAAG,WAAa,EAAA,QAAA,EAAU,IAAI,CAAA,MAAA,CAAA;AAAA,MAClC,MAAM,SAAU,CAAA,KAAA;AAAA,MAChB,QAAQ,cAAe,CAAA,YAAA;AAAA,MACvB,WAAA,EAAa,CAAC,GAAA,EAAK,CAAC;AAAA,KACtB;AAAA,IACA,KAAO,EAAA;AAAA,MACL,GAAG,KAAA;AAAA,MACH,GAAG,WAAA;AAAA,MACH,GAAG,YAAA;AAAA,MACH,GAAG;AAAA,KACL;AAAA,IACA;AAAA,GACF;AACF;AAEa,MAAA,aAAA,GAAgB,CAC3B,MAC4B,KAAA;AAC5B,EAAA,QAAQ,MAAQ;AAAA,IACd,KAAK,cAAe,CAAA,aAAA;AAClB,MAAO,OAAA,mBAAA;AAAA,IACT,KAAK,cAAe,CAAA,YAAA;AAClB,MAAO,OAAA,kBAAA;AAAA,IACT,KAAK,cAAe,CAAA,mBAAA;AAClB,MAAO,OAAA,yBAAA;AAAA,IACT,KAAK,cAAe,CAAA,oBAAA;AAClB,MAAO,OAAA,0BAAA;AAAA,IACT;AACE,MAAO,OAAA,IAAA;AAAA;AAEb;;;;"}
|
|
1
|
+
{"version":3,"file":"pipeline-topology-utils.esm.js","sources":["../../src/utils/pipeline-topology-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 {\n EdgeModel,\n getEdgesFromNodes,\n getSpacerNodes,\n GraphModel,\n ModelKind,\n RunStatus,\n WhenStatus,\n} from '@patternfly/react-topology';\nimport * as dagre from 'dagre';\nimport { minBy, uniq } from 'lodash';\n\nimport {\n ComputedStatus,\n PipelineRunKind,\n PipelineTask,\n PipelineTaskParam,\n PipelineTaskWithStatus,\n TaskRunKind,\n} from '@janus-idp/shared-react';\n\nimport { DAG, Vertex } from '../components/pipeline-topology/dag';\nimport {\n DAGRE_BUILDER_PROPS,\n DAGRE_BUILDER_SPACED_PROPS,\n DAGRE_VIEWER_PROPS,\n DAGRE_VIEWER_SPACED_PROPS,\n DEFAULT_BADGE_WIDTH,\n DEFAULT_FINALLLY_GROUP_PADDING,\n DEFAULT_NODE_HEIGHT,\n DEFAULT_NODE_ICON_WIDTH,\n FINALLY_NODE_PADDING,\n NODE_HEIGHT,\n NODE_PADDING,\n NODE_WIDTH,\n NodeType,\n PipelineLayout,\n REGEX_EXTRACT_DEPS,\n WHEN_EXPRESSION_SPACING,\n} from '../consts/pipeline-topology-const';\nimport {\n FinallyNodeModel,\n LoadingNodeModel,\n NodeCreator,\n NodeCreatorSetup,\n PipelineEdgeModel,\n PipelineMixedNodeModel,\n PipelineRunAfterNodeModelData,\n} from '../types/pipeline-topology-types';\nimport { appendPipelineRunStatus, getPLRTaskRuns } from './pipelineRun-utils';\n\nconst createGenericNode: NodeCreatorSetup =\n (type, width?, height?) => (name, data) => ({\n id: name,\n label: data?.label || name,\n runAfterTasks: data?.runAfterTasks || [],\n ...(data && { data }),\n height: height ?? NODE_HEIGHT,\n width: width ?? NODE_WIDTH,\n type,\n });\n\nconst getMaxFinallyNode = (finallyTaskList: PipelineTaskWithStatus[]) => {\n const sortedFinallyTaskList = [...finallyTaskList].sort(\n (a, b) => b.name.length - a.name.length,\n );\n return sortedFinallyTaskList[0]?.name || '';\n};\n\nexport const createFinallyNode = (\n height: number,\n): NodeCreator<FinallyNodeModel> =>\n createGenericNode(\n NodeType.FINALLY_NODE,\n NODE_WIDTH + WHEN_EXPRESSION_SPACING + FINALLY_NODE_PADDING * 2,\n height,\n );\n\nexport const createLoadingNode: NodeCreator<LoadingNodeModel> =\n createGenericNode(NodeType.LOADING_NODE);\n\nconst createPipelineTaskNode = (\n type: NodeType,\n data: PipelineRunAfterNodeModelData,\n) => createGenericNode(type, data.width, data.height)(data.id ?? '', data);\n\nexport const getTextWidth = (\n text: string,\n font: string = '0.8rem RedHatText',\n): number => {\n if (!text || text.length === 0) {\n return 0;\n }\n const canvas = document.createElement('canvas');\n const context = canvas.getContext('2d');\n if (!context) {\n return text.length;\n }\n context.font = font;\n const { width } = context.measureText(text);\n return width;\n};\n\nexport const extractDepsFromContextVariables = (\n contextVariable: string | null | undefined,\n) => {\n let matches;\n const deps: string[] = [];\n if (!contextVariable) {\n return deps;\n }\n // eslint-disable-next-line no-cond-assign\n while ((matches = REGEX_EXTRACT_DEPS.exec(contextVariable)) !== null) {\n // This is necessary to avoid infinite loops with zero-width matches\n if (matches.index === REGEX_EXTRACT_DEPS.lastIndex) {\n REGEX_EXTRACT_DEPS.lastIndex++;\n }\n if (matches) {\n if (!deps.includes(matches[1])) {\n deps.push(matches[1]);\n }\n }\n }\n return deps;\n};\n\nexport const getSpacerNode = (\n node: PipelineMixedNodeModel,\n): PipelineMixedNodeModel => ({\n ...node,\n height: 1,\n width: 1,\n});\n\nexport const getWhenStatus = (\n status: ComputedStatus,\n): WhenStatus | undefined => {\n switch (status) {\n case ComputedStatus.Succeeded:\n case ComputedStatus.Failed:\n return WhenStatus.Met;\n case ComputedStatus.Skipped:\n case ComputedStatus['In Progress']:\n case ComputedStatus.Idle:\n return WhenStatus.Unmet;\n default:\n return undefined;\n }\n};\n\nexport const getTaskWhenStatus = (\n task: PipelineTaskWithStatus,\n): WhenStatus | undefined => {\n if (!task.when) {\n return undefined;\n }\n return getWhenStatus(task.status?.reason as ComputedStatus);\n};\n\nconst getDepsFromContextVariables = (task: PipelineTask) => {\n const depsFromContextVariables: string[] = [];\n if (task.params) {\n task.params.forEach((p: PipelineTaskParam) => {\n if (Array.isArray(p.value)) {\n p.value.forEach(paramValue => {\n depsFromContextVariables.push(\n ...extractDepsFromContextVariables(paramValue),\n );\n });\n } else {\n depsFromContextVariables.push(\n ...extractDepsFromContextVariables(p.value),\n );\n }\n });\n }\n if (task?.when) {\n task.when.forEach(({ input, values }) => {\n depsFromContextVariables.push(...extractDepsFromContextVariables(input));\n values.forEach((whenValue: string) => {\n depsFromContextVariables.push(\n ...extractDepsFromContextVariables(whenValue),\n );\n });\n });\n }\n return depsFromContextVariables;\n};\n\nconst getRunAfterTasks = (task: PipelineTask, dag: DAG, vertex: Vertex) => {\n const runAfterTasks: string[] = [];\n const depsFromContextVariables = getDepsFromContextVariables(task);\n\n const dependancies = uniq([...vertex.dependancyNames]);\n if (dependancies) {\n dependancies.forEach(dep => {\n const depObj = dag.vertices.get(dep) as Vertex;\n if (\n depObj.level - vertex.level <= 1 ||\n vertex.data.runAfter?.includes(depObj.name)\n ) {\n runAfterTasks.push(dep);\n }\n });\n }\n if (depsFromContextVariables.length > 0) {\n const v = depsFromContextVariables.map(d => {\n return dag.vertices.get(d) as Vertex;\n });\n const minLevelDep = minBy(v, (d: Vertex) => d.level) as Vertex;\n const nearestDeps = v.filter(v1 => v1.level === minLevelDep.level);\n nearestDeps.forEach(nd => {\n if (nd.level - vertex.level <= 1 || vertex.dependancyNames.length === 0) {\n runAfterTasks.push(nd.name);\n }\n });\n }\n return runAfterTasks;\n};\n\nexport const getGraphDataModel = (\n pipelineRun: PipelineRunKind | undefined,\n taskRuns: TaskRunKind[],\n): {\n graph: GraphModel;\n nodes: PipelineMixedNodeModel[];\n edges: EdgeModel[];\n} | null => {\n if (!pipelineRun) {\n return null;\n }\n\n const plrTaskRuns = getPLRTaskRuns(taskRuns, pipelineRun?.metadata?.name);\n\n const taskList = appendPipelineRunStatus(pipelineRun, plrTaskRuns);\n\n const dag = new DAG();\n taskList?.forEach((task: PipelineTask) => {\n dag.addEdges(task.name, task, '', task.runAfter || []);\n });\n\n const nodes: PipelineMixedNodeModel[] = [];\n const maxWidthForLevel: { [key: string]: number } = {};\n dag.topologicalSort((v: Vertex) => {\n if (!maxWidthForLevel[v.level]) {\n maxWidthForLevel[v.level] = getTextWidth(v.name);\n } else {\n maxWidthForLevel[v.level] = Math.max(\n maxWidthForLevel[v.level],\n getTextWidth(v.name),\n );\n }\n });\n dag.topologicalSort((vertex: Vertex) => {\n const task = vertex.data as PipelineTask;\n const runAfterTasks = getRunAfterTasks(task, dag, vertex);\n const badgePadding =\n Object.keys(pipelineRun.spec)?.length > 0 ? DEFAULT_BADGE_WIDTH : 0;\n const isTaskSkipped = pipelineRun?.status?.skippedTasks?.some(\n t => t.name === task.name,\n );\n nodes.push(\n createPipelineTaskNode(NodeType.TASK_NODE, {\n id: vertex.name,\n label: vertex.name,\n width:\n maxWidthForLevel[vertex.level] +\n NODE_PADDING * 2 +\n DEFAULT_NODE_ICON_WIDTH +\n badgePadding,\n runAfterTasks,\n status: isTaskSkipped ? RunStatus.Skipped : vertex.data.status?.reason,\n whenStatus: getTaskWhenStatus(vertex.data),\n task: vertex.data,\n pipelineRun,\n }),\n );\n });\n\n const finallyTaskList = appendPipelineRunStatus(\n pipelineRun,\n plrTaskRuns,\n true,\n );\n\n const finallyNodes = finallyTaskList.map(fTask => {\n const isTaskSkipped = pipelineRun?.status?.skippedTasks?.some(\n t => t.name === fTask.name,\n );\n\n return createPipelineTaskNode(NodeType.FINALLY_NODE, {\n id: fTask.name,\n label: fTask.name,\n width:\n getTextWidth(getMaxFinallyNode(finallyTaskList)) +\n NODE_PADDING * 2 +\n DEFAULT_FINALLLY_GROUP_PADDING * 2,\n height: DEFAULT_NODE_HEIGHT,\n runAfterTasks: [],\n status: isTaskSkipped\n ? RunStatus.Skipped\n : (fTask.status?.reason as RunStatus),\n whenStatus: getTaskWhenStatus(fTask),\n task: fTask,\n pipelineRun,\n });\n });\n\n const finallyGroup = finallyNodes.length\n ? [\n {\n id: 'finally-group-id',\n type: NodeType.FINALLY_GROUP,\n children: finallyNodes.map(n => n.id),\n group: true,\n style: { padding: DEFAULT_FINALLLY_GROUP_PADDING },\n },\n ]\n : [];\n const spacerNodes: PipelineMixedNodeModel[] = (\n getSpacerNodes([...nodes, ...finallyNodes], NodeType.SPACER_NODE, [\n NodeType.FINALLY_NODE,\n ]) as PipelineMixedNodeModel[]\n ).map(getSpacerNode);\n\n const edges: PipelineEdgeModel[] = getEdgesFromNodes(\n [...nodes, ...spacerNodes, ...finallyNodes],\n NodeType.SPACER_NODE,\n NodeType.EDGE,\n NodeType.EDGE,\n [NodeType.FINALLY_NODE],\n NodeType.EDGE,\n );\n\n return {\n graph: {\n id: `${pipelineRun?.metadata?.name}-graph`,\n type: ModelKind.graph,\n layout: PipelineLayout.DAGRE_VIEWER,\n scaleExtent: [0.5, 1],\n },\n nodes: [\n ...nodes,\n ...spacerNodes,\n ...finallyNodes,\n ...finallyGroup,\n ] as PipelineMixedNodeModel[],\n edges,\n };\n};\n\nexport const getLayoutData = (\n layout: PipelineLayout,\n): dagre.GraphLabel | null => {\n switch (layout) {\n case PipelineLayout.DAGRE_BUILDER:\n return DAGRE_BUILDER_PROPS;\n case PipelineLayout.DAGRE_VIEWER:\n return DAGRE_VIEWER_PROPS;\n case PipelineLayout.DAGRE_VIEWER_SPACED:\n return DAGRE_VIEWER_SPACED_PROPS;\n case PipelineLayout.DAGRE_BUILDER_SPACED:\n return DAGRE_BUILDER_SPACED_PROPS;\n default:\n return null;\n }\n};\n"],"names":[],"mappings":";;;;;;;AAkEA,MAAM,oBACJ,CAAC,IAAA,EAAM,OAAQ,MAAA,KAAY,CAAC,MAAM,IAAA,MAAU;AAAA,EAC1C,EAAA,EAAI,IAAA;AAAA,EACJ,KAAA,EAAO,MAAM,KAAA,IAAS,IAAA;AAAA,EACtB,aAAA,EAAe,IAAA,EAAM,aAAA,IAAiB,EAAC;AAAA,EACvC,GAAI,IA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A,KACtB;AAAA,IACA,KAAA,EAAO;AAAA,MACL,GAAG,KAAA;AAAA,MACH,GAAG,WAAA;AAAA,MACH,GAAG,YAAA;AAAA,MACH,GAAG;AAAA,KACL;AAAA,IACA;AAAA,GACF;AACF;AAEO,MAAM,aAAA,GAAgB,CAC3B,MAAA,KAC4B;AAC5B,EAAA,QAAQ,MAAA;AAAQ,IACd,KAAK,cAAA,CAAe,aAAA;AAClB,MAAA,OAAO,mBAAA;AAAA,IACT,KAAK,cAAA,CAAe,YAAA;AAClB,MAAA,OAAO,kBAAA;AAAA,IACT,KAAK,cAAA,CAAe,mBAAA;AAClB,MAAA,OAAO,yBAAA;AAAA,IACT,KAAK,cAAA,CAAe,oBAAA;AAClB,MAAA,OAAO,0BAAA;AAAA,IACT;AACE,MAAA,OAAO,IAAA;AAAA;AAEb;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipelineRun-utils.esm.js","sources":["../../src/utils/pipelineRun-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 { cloneDeep, each, find, get, isEmpty, isFinite, trim } from 'lodash';\n\nimport {\n ComputedStatus,\n pipelineRunFilterReducer,\n PipelineRunKind,\n pipelineRunStatus,\n PipelineTask,\n PipelineTaskWithStatus,\n PLRTaskRuns,\n SucceedConditionReason,\n TaskRunKind,\n} from '@janus-idp/shared-react';\n\nimport {\n TEKTON_PIPELINE_RUN,\n TEKTON_PIPELINE_TASK,\n} from '../consts/tekton-const';\nimport { TaskStatus } from '../types/taskRun';\n\n// Conversions between units and milliseconds\nconst s = 1000;\nconst m = s * 60;\nconst h = m * 60;\nconst d = h * 24;\nconst w = d * 7;\nconst units = { w, d, h, m, s };\n\nexport const formatPrometheusDuration = (ms: number) => {\n if (!isFinite(ms) || ms < 0) {\n return '';\n }\n let remaining = ms;\n let str = '';\n each(units, (factor, unit) => {\n const n = Math.floor(remaining / factor);\n if (n > 0) {\n str += `${n}${unit} `;\n remaining -= n * factor;\n }\n });\n return trim(str);\n};\n\nexport const taskConditions = {\n hasFromDependency: (task: PipelineTask): boolean =>\n !!task?.resources?.inputs?.[0].from,\n hasRunAfterDependency: (task: PipelineTask): boolean =>\n !!task?.runAfter && task?.runAfter?.length > 0,\n};\n\nexport const getPipelineRun = (\n runs: PipelineRunKind[],\n name: string,\n): PipelineRunKind | null => {\n if (runs?.length > 0 && name) {\n return runs.find(run => run?.metadata?.name === name) ?? null;\n }\n return null;\n};\n\nconst getStatusReason = (reason: string | undefined) => {\n switch (reason) {\n case SucceedConditionReason.PipelineRunCancelled:\n return ComputedStatus.Cancelled;\n case SucceedConditionReason.PipelineRunPending:\n return ComputedStatus.Idle;\n default:\n return ComputedStatus.Failed;\n }\n};\n\nconst appendTaskDuration = (mTask: PipelineTaskWithStatus) => {\n const task = cloneDeep(mTask);\n if (mTask?.status?.completionTime && mTask?.status?.startTime) {\n const date =\n new Date(mTask.status.completionTime).getTime() -\n new Date(mTask.status.startTime).getTime();\n task.status = {\n ...mTask.status,\n duration: formatPrometheusDuration(date),\n };\n }\n return task;\n};\n\nconst appendTaskStatus = (mTask: PipelineTaskWithStatus) => {\n let task = cloneDeep(mTask);\n if (!mTask.status) {\n task = {\n ...mTask,\n status: { reason: ComputedStatus.Pending, conditions: [] },\n };\n } else if (mTask.status?.conditions) {\n task.status.reason = pipelineRunStatus(mTask) || ComputedStatus.Pending;\n } else if (mTask.status && !mTask.status.reason) {\n task.status.reason = ComputedStatus.Pending;\n }\n return task;\n};\n\nexport const appendPipelineRunStatus = (\n pipelineRun: PipelineRunKind,\n taskRuns: PLRTaskRuns,\n isFinallyTasks = false,\n) => {\n const tasks =\n (isFinallyTasks\n ? pipelineRun.status?.pipelineSpec?.finally\n : pipelineRun.status?.pipelineSpec?.tasks) || [];\n\n return tasks?.map(task => {\n if (!pipelineRun.status) {\n return task as PipelineTaskWithStatus;\n }\n if (isEmpty(taskRuns)) {\n return {\n ...task,\n status: {\n reason: getStatusReason(pipelineRun?.status?.conditions?.[0].reason),\n },\n } as PipelineTaskWithStatus;\n }\n let mTask = {\n ...task,\n status: get(find(taskRuns, { pipelineTaskName: task.name }), 'status'),\n } as PipelineTaskWithStatus;\n // append task duration\n mTask = appendTaskDuration(mTask);\n // append task status\n mTask = appendTaskStatus(mTask);\n return mTask;\n });\n};\n\nexport const getPLRTaskRuns = (\n taskRuns: TaskRunKind[],\n pipelineRun: string | undefined,\n): PLRTaskRuns => {\n const filteredTaskRuns = taskRuns.filter(\n tr => tr?.metadata?.labels?.[TEKTON_PIPELINE_RUN] === pipelineRun,\n );\n return filteredTaskRuns.reduce((acc: any, taskRun: TaskRunKind) => {\n const temp = {\n [`${taskRun?.metadata?.name}`]: {\n pipelineTaskName: taskRun?.metadata?.labels?.[TEKTON_PIPELINE_TASK],\n status: taskRun?.status,\n },\n };\n // eslint-disable-next-line no-param-reassign\n acc = { ...acc, ...temp };\n return acc;\n }, {});\n};\n\nexport const getTaskStatus = (\n pipelineRun: PipelineRunKind,\n task: PipelineTaskWithStatus,\n) => {\n let taskStatus: TaskStatus = {\n reason: ComputedStatus.Idle,\n };\n\n const computedStatus = pipelineRunFilterReducer(pipelineRun);\n const isSkipped = !!(\n task &&\n pipelineRun?.status?.skippedTasks?.some(\n (t: { name: string }) => t.name === task.name,\n )\n );\n\n if (task?.status) {\n taskStatus = task.status as TaskStatus;\n }\n if (\n computedStatus === ComputedStatus.Failed ||\n computedStatus === ComputedStatus.Cancelled\n ) {\n if (\n task?.status?.reason === ComputedStatus.Idle ||\n task?.status?.reason === ComputedStatus.Pending\n ) {\n taskSt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AAAA;AAErC,EAAO,OAAA,UAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"pipelineRun-utils.esm.js","sources":["../../src/utils/pipelineRun-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 { cloneDeep, each, find, get, isEmpty, isFinite, trim } from 'lodash';\n\nimport {\n ComputedStatus,\n pipelineRunFilterReducer,\n PipelineRunKind,\n pipelineRunStatus,\n PipelineTask,\n PipelineTaskWithStatus,\n PLRTaskRuns,\n SucceedConditionReason,\n TaskRunKind,\n} from '@janus-idp/shared-react';\n\nimport {\n TEKTON_PIPELINE_RUN,\n TEKTON_PIPELINE_TASK,\n} from '../consts/tekton-const';\nimport { TaskStatus } from '../types/taskRun';\n\n// Conversions between units and milliseconds\nconst s = 1000;\nconst m = s * 60;\nconst h = m * 60;\nconst d = h * 24;\nconst w = d * 7;\nconst units = { w, d, h, m, s };\n\nexport const formatPrometheusDuration = (ms: number) => {\n if (!isFinite(ms) || ms < 0) {\n return '';\n }\n let remaining = ms;\n let str = '';\n each(units, (factor, unit) => {\n const n = Math.floor(remaining / factor);\n if (n > 0) {\n str += `${n}${unit} `;\n remaining -= n * factor;\n }\n });\n return trim(str);\n};\n\nexport const taskConditions = {\n hasFromDependency: (task: PipelineTask): boolean =>\n !!task?.resources?.inputs?.[0].from,\n hasRunAfterDependency: (task: PipelineTask): boolean =>\n !!task?.runAfter && task?.runAfter?.length > 0,\n};\n\nexport const getPipelineRun = (\n runs: PipelineRunKind[],\n name: string,\n): PipelineRunKind | null => {\n if (runs?.length > 0 && name) {\n return runs.find(run => run?.metadata?.name === name) ?? null;\n }\n return null;\n};\n\nconst getStatusReason = (reason: string | undefined) => {\n switch (reason) {\n case SucceedConditionReason.PipelineRunCancelled:\n return ComputedStatus.Cancelled;\n case SucceedConditionReason.PipelineRunPending:\n return ComputedStatus.Idle;\n default:\n return ComputedStatus.Failed;\n }\n};\n\nconst appendTaskDuration = (mTask: PipelineTaskWithStatus) => {\n const task = cloneDeep(mTask);\n if (mTask?.status?.completionTime && mTask?.status?.startTime) {\n const date =\n new Date(mTask.status.completionTime).getTime() -\n new Date(mTask.status.startTime).getTime();\n task.status = {\n ...mTask.status,\n duration: formatPrometheusDuration(date),\n };\n }\n return task;\n};\n\nconst appendTaskStatus = (mTask: PipelineTaskWithStatus) => {\n let task = cloneDeep(mTask);\n if (!mTask.status) {\n task = {\n ...mTask,\n status: { reason: ComputedStatus.Pending, conditions: [] },\n };\n } else if (mTask.status?.conditions) {\n task.status.reason = pipelineRunStatus(mTask) || ComputedStatus.Pending;\n } else if (mTask.status && !mTask.status.reason) {\n task.status.reason = ComputedStatus.Pending;\n }\n return task;\n};\n\nexport const appendPipelineRunStatus = (\n pipelineRun: PipelineRunKind,\n taskRuns: PLRTaskRuns,\n isFinallyTasks = false,\n) => {\n const tasks =\n (isFinallyTasks\n ? pipelineRun.status?.pipelineSpec?.finally\n : pipelineRun.status?.pipelineSpec?.tasks) || [];\n\n return tasks?.map(task => {\n if (!pipelineRun.status) {\n return task as PipelineTaskWithStatus;\n }\n if (isEmpty(taskRuns)) {\n return {\n ...task,\n status: {\n reason: getStatusReason(pipelineRun?.status?.conditions?.[0].reason),\n },\n } as PipelineTaskWithStatus;\n }\n let mTask = {\n ...task,\n status: get(find(taskRuns, { pipelineTaskName: task.name }), 'status'),\n } as PipelineTaskWithStatus;\n // append task duration\n mTask = appendTaskDuration(mTask);\n // append task status\n mTask = appendTaskStatus(mTask);\n return mTask;\n });\n};\n\nexport const getPLRTaskRuns = (\n taskRuns: TaskRunKind[],\n pipelineRun: string | undefined,\n): PLRTaskRuns => {\n const filteredTaskRuns = taskRuns.filter(\n tr => tr?.metadata?.labels?.[TEKTON_PIPELINE_RUN] === pipelineRun,\n );\n return filteredTaskRuns.reduce((acc: any, taskRun: TaskRunKind) => {\n const temp = {\n [`${taskRun?.metadata?.name}`]: {\n pipelineTaskName: taskRun?.metadata?.labels?.[TEKTON_PIPELINE_TASK],\n status: taskRun?.status,\n },\n };\n // eslint-disable-next-line no-param-reassign\n acc = { ...acc, ...temp };\n return acc;\n }, {});\n};\n\nexport const getTaskStatus = (\n pipelineRun: PipelineRunKind,\n task: PipelineTaskWithStatus,\n) => {\n let taskStatus: TaskStatus = {\n reason: ComputedStatus.Idle,\n };\n\n const computedStatus = pipelineRunFilterReducer(pipelineRun);\n const isSkipped = !!(\n task &&\n pipelineRun?.status?.skippedTasks?.some(\n (t: { name: string }) => t.name === task.name,\n )\n );\n\n if (task?.status) {\n taskStatus = task.status as TaskStatus;\n }\n if (\n computedStatus === ComputedStatus.Failed ||\n computedStatus === ComputedStatus.Cancelled\n ) {\n if (\n task?.status?.reason === ComputedStatus.Idle ||\n task?.status?.reason === ComputedStatus.Pending\n ) {\n taskStatus.reason = ComputedStatus.Cancelled;\n }\n }\n if (isSkipped) {\n taskStatus.reason = ComputedStatus.Skipped;\n }\n return taskStatus;\n};\n"],"names":[],"mappings":";;;;AAoCA,MAAM,CAAA,GAAI,GAAA;AACV,MAAM,IAAI,CAAA,GAAI,EAAA;AACd,MAAM,IAAI,CAAA,GAAI,EAAA;AACd,MAAM,IAAI,CAAA,GAAI,EAAA;AACd,MAAM,IAAI,CAAA,GAAI,CAAA;AACd,MAAM,QAAQ,EAAE,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,GAAG,CAAA,EAAE;AAEvB,MAAM,wBAAA,GAA2B,CAAC,EAAA,KAAe;AACtD,EAAA,IAAI,CAAC,QAAA,CAAS,EAAE,CAAA,IAAK,KAAK,CAAA,EAAG;AAC3B,IAAA,OAAO,EAA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ACP;AAEO,MAAM,aAAA,GAAgB,CAC3B,WAAA,EACA,IAAA,KACG;AACH,EAAA,IAAI,UAAA,GAAyB;AAAA,IAC3B,QAAQ,cAAA,CAAe;AAAA,GACzB;AAEA,EAAA,MAAM,cAAA,GAAiB,yBAAyB,WAAW,CAAA;AAC3D,EAAA,MAAM,YAAY,CAAC,EACjB,IAAA,IACA,WAAA,EAAa,QAAQ,YAAA,EAAc,IAAA;AAAA,IACjC,CAAC,CAAA,KAAwB,CAAA,CAAE,IAAA,KAAS,IAAA,CAAK;AAAA,GAC3C,CAAA;AAGF,EAAA,IAAI,MAAM,MAAA,EAAQ;AAChB,IAAA,UAAA,GAAa,IAAA,CAAK,MAAA;AAAA,EACpB;AACA,EAAA,IACE,cAAA,KAAmB,cAAA,CAAe,MAAA,IAClC,cAAA,KAAmB,eAAe,SAAA,EAClC;AACA,IAAA,IACE,IAAA,EAAM,QAAQ,MAAA,KAAW,cAAA,CAAe,QACxC,IAAA,EAAM,MAAA,EAAQ,MAAA,KAAW,cAAA,CAAe,OAAA,EACxC;AACA,MAAA,UAAA,CAAW,SAAS,cAAA,CAAe,SAAA;AAAA,IACrC;AAAA,EACF;AACA,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,UAAA,CAAW,SAAS,cAAA,CAAe,OAAA;AAAA,EACrC;AACA,EAAA,OAAO,UAAA;AACT;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskRun-utils.esm.js","sources":["../../src/utils/taskRun-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 {\n TaskRunResultsAnnotations,\n TaskRunResultsKeyValue,\n TaskRunResultsTypeValue,\n} from '@aonic-ui/pipelines';\n\nimport {\n ComputedStatus,\n pipelineRunFilterReducer,\n TaskRunKind,\n} from '@janus-idp/shared-react';\n\nimport {\n TEKTON_PIPELINE_RUN,\n TEKTON_PIPELINE_TASK,\n} from '../consts/tekton-const';\nimport { OutputTaskRunGroup } from '../types/output';\n\nexport type TaskStep = {\n id: string;\n name: string;\n status: ComputedStatus;\n startedAt?: string;\n endedAt?: string;\n};\n\nexport const getSortedTaskRuns = (tRuns: TaskRunKind[]): TaskStep[] => {\n if (!tRuns || tRuns.length === 0) {\n return [];\n }\n const taskRuns = Array.from(tRuns).sort((a, b) => {\n if (a.status?.completionTime) {\n return b.status?.completionTime &&\n new Date(a.status?.completionTime ?? '') >\n new Date(b.status.completionTime)\n ? 1\n : -1;\n }\n return b.status?.completionTime ||\n new Date(a.status?.startTime ?? '') > new Date(b.status?.startTime ?? '')\n ? 1\n : -1;\n });\n return (taskRuns?.map(tr => {\n return {\n id: tr.metadata?.name,\n name: tr.metadata?.labels?.[TEKTON_PIPELINE_TASK],\n status: pipelineRunFilterReducer(tr),\n startedAt: tr.status?.startTime,\n endedAt: tr.status?.completionTime,\n };\n }) || []) as TaskStep[];\n};\n\nexport const getActiveTaskRun = (\n taskRuns: TaskStep[],\n activeTask: string | undefined,\n): string | undefined =>\n activeTask\n ? taskRuns.find(taskRun => taskRun?.id === activeTask)?.id\n : taskRuns[taskRuns.length - 1]?.id;\n\nconst checkTypeAnnotation = (\n tr: TaskRunKind | undefined,\n type: TaskRunResultsTypeValue,\n): boolean =>\n tr?.metadata?.annotations?.[TaskRunResultsAnnotations.TYPE] === type;\n\nexport const isSbomTaskRun = (tr: TaskRunKind | undefined): boolean =>\n tr?.metadata?.annotations?.[TaskRunResultsAnnotations.KEY] ===\n TaskRunResultsKeyValue.SBOM;\n\nexport const isECTaskRun = (tr: TaskRunKind | undefined): boolean =>\n checkTypeAnnotation(tr, TaskRunResultsTypeValue.EC);\n\nexport const isACSImageScanTaskRun = (tr: TaskRunKind | undefined): boolean =>\n checkTypeAnnotation(tr, TaskRunResultsTypeValue.ROXCTL_IMAGE_SCAN);\n\nexport const isACSImageCheckTaskRun = (tr: TaskRunKind | undefined): boolean =>\n checkTypeAnnotation(tr, TaskRunResultsTypeValue.ROXCTL_IMAGE_CHECK);\n\nexport const isACSDeploymentCheckTaskRun = (\n tr: TaskRunKind | undefined,\n): boolean =>\n checkTypeAnnotation(tr, TaskRunResultsTypeValue.ROXCTL_DEPLOYMENT_CHECK);\n\nexport const getTaskrunsOutputGroup = (\n pipelineRunName: string | undefined,\n taskruns: TaskRunKind[],\n): OutputTaskRunGroup => {\n const getPLRTaskRunByType = (\n check: (tr: TaskRunKind | undefined) => boolean,\n ): TaskRunKind | undefined =>\n taskruns?.find(\n (tr: TaskRunKind) =>\n tr?.metadata?.labels?.[TEKTON_PIPELINE_RUN] === pipelineRunName &&\n check(tr),\n );\n\n return {\n sbomTaskRun: getPLRTaskRunByType(isSbomTaskRun),\n ecTaskRun: getPLRTaskRunByType(isECTaskRun),\n acsImageScanTaskRun: getPLRTaskRunByType(isACSImageScanTaskRun),\n acsImageCheckTaskRun: getPLRTaskRunByType(isACSImageCheckTaskRun),\n acsDeploymentCheckTaskRun: getPLRTaskRunByType(isACSDeploymentCheckTaskRun),\n };\n};\n\nexport const hasExternalLink = (\n sbomTaskRun: TaskRunKind | undefined,\n): boolean =>\n sbomTaskRun?.metadata?.annotations?.[TaskRunResultsAnnotations.TYPE] ===\n TaskRunResultsTypeValue.EXTERNAL_LINK;\n\nexport const getSbomLink = (\n sbomTaskRun: TaskRunKind | undefined,\n): string | undefined =>\n (sbomTaskRun?.status?.results || sbomTaskRun?.status?.taskResults)?.find(\n r => r.name === TaskRunResultsKeyValue.SBOM,\n )?.value;\n"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"taskRun-utils.esm.js","sources":["../../src/utils/taskRun-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 {\n TaskRunResultsAnnotations,\n TaskRunResultsKeyValue,\n TaskRunResultsTypeValue,\n} from '@aonic-ui/pipelines';\n\nimport {\n ComputedStatus,\n pipelineRunFilterReducer,\n TaskRunKind,\n} from '@janus-idp/shared-react';\n\nimport {\n TEKTON_PIPELINE_RUN,\n TEKTON_PIPELINE_TASK,\n} from '../consts/tekton-const';\nimport { OutputTaskRunGroup } from '../types/output';\n\nexport type TaskStep = {\n id: string;\n name: string;\n status: ComputedStatus;\n startedAt?: string;\n endedAt?: string;\n};\n\nexport const getSortedTaskRuns = (tRuns: TaskRunKind[]): TaskStep[] => {\n if (!tRuns || tRuns.length === 0) {\n return [];\n }\n const taskRuns = Array.from(tRuns).sort((a, b) => {\n if (a.status?.completionTime) {\n return b.status?.completionTime &&\n new Date(a.status?.completionTime ?? '') >\n new Date(b.status.completionTime)\n ? 1\n : -1;\n }\n return b.status?.completionTime ||\n new Date(a.status?.startTime ?? '') > new Date(b.status?.startTime ?? '')\n ? 1\n : -1;\n });\n return (taskRuns?.map(tr => {\n return {\n id: tr.metadata?.name,\n name: tr.metadata?.labels?.[TEKTON_PIPELINE_TASK],\n status: pipelineRunFilterReducer(tr),\n startedAt: tr.status?.startTime,\n endedAt: tr.status?.completionTime,\n };\n }) || []) as TaskStep[];\n};\n\nexport const getActiveTaskRun = (\n taskRuns: TaskStep[],\n activeTask: string | undefined,\n): string | undefined =>\n activeTask\n ? taskRuns.find(taskRun => taskRun?.id === activeTask)?.id\n : taskRuns[taskRuns.length - 1]?.id;\n\nconst checkTypeAnnotation = (\n tr: TaskRunKind | undefined,\n type: TaskRunResultsTypeValue,\n): boolean =>\n tr?.metadata?.annotations?.[TaskRunResultsAnnotations.TYPE] === type;\n\nexport const isSbomTaskRun = (tr: TaskRunKind | undefined): boolean =>\n tr?.metadata?.annotations?.[TaskRunResultsAnnotations.KEY] ===\n TaskRunResultsKeyValue.SBOM;\n\nexport const isECTaskRun = (tr: TaskRunKind | undefined): boolean =>\n checkTypeAnnotation(tr, TaskRunResultsTypeValue.EC);\n\nexport const isACSImageScanTaskRun = (tr: TaskRunKind | undefined): boolean =>\n checkTypeAnnotation(tr, TaskRunResultsTypeValue.ROXCTL_IMAGE_SCAN);\n\nexport const isACSImageCheckTaskRun = (tr: TaskRunKind | undefined): boolean =>\n checkTypeAnnotation(tr, TaskRunResultsTypeValue.ROXCTL_IMAGE_CHECK);\n\nexport const isACSDeploymentCheckTaskRun = (\n tr: TaskRunKind | undefined,\n): boolean =>\n checkTypeAnnotation(tr, TaskRunResultsTypeValue.ROXCTL_DEPLOYMENT_CHECK);\n\nexport const getTaskrunsOutputGroup = (\n pipelineRunName: string | undefined,\n taskruns: TaskRunKind[],\n): OutputTaskRunGroup => {\n const getPLRTaskRunByType = (\n check: (tr: TaskRunKind | undefined) => boolean,\n ): TaskRunKind | undefined =>\n taskruns?.find(\n (tr: TaskRunKind) =>\n tr?.metadata?.labels?.[TEKTON_PIPELINE_RUN] === pipelineRunName &&\n check(tr),\n );\n\n return {\n sbomTaskRun: getPLRTaskRunByType(isSbomTaskRun),\n ecTaskRun: getPLRTaskRunByType(isECTaskRun),\n acsImageScanTaskRun: getPLRTaskRunByType(isACSImageScanTaskRun),\n acsImageCheckTaskRun: getPLRTaskRunByType(isACSImageCheckTaskRun),\n acsDeploymentCheckTaskRun: getPLRTaskRunByType(isACSDeploymentCheckTaskRun),\n };\n};\n\nexport const hasExternalLink = (\n sbomTaskRun: TaskRunKind | undefined,\n): boolean =>\n sbomTaskRun?.metadata?.annotations?.[TaskRunResultsAnnotations.TYPE] ===\n TaskRunResultsTypeValue.EXTERNAL_LINK;\n\nexport const getSbomLink = (\n sbomTaskRun: TaskRunKind | undefined,\n): string | undefined =>\n (sbomTaskRun?.status?.results || sbomTaskRun?.status?.taskResults)?.find(\n r => r.name === TaskRunResultsKeyValue.SBOM,\n )?.value;\n"],"names":[],"mappings":";;;;AAyCO,MAAM,iBAAA,GAAoB,CAAC,KAAA,KAAqC;AACrE,EAAA,IAAI,CAAC,KAAA,IAAS,KAAA,CAAM,MAAA,KAAW,CAAA,EAAG;AAChC,IAAA,OAAO,EAAC;AAAA,EACV;AACA,EAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,KAAK,EAAE,IAAA,CAAK,CAAC,GAAG,CAAA,KAAM;AAChD,IAAA,IAAI,CAAA,CAAE,QAAQ,cAAA,EAAgB;AAC5B,MAAA,OAAO,EAAE,MAAA,EAAQ,cAAA,IACf,IAAI,IAAA,CAAK,EAAE,MAAA,EAAQ,cAAA,IAAkB,EAAE,CAAA,GACrC,IAAI,IAAA,CAAK,CAAA,CAAE,MAAA,CAAO,cAAc,IAChC,CAAA,GACA,EAAA;AAAA,IACN;AACA,IAAA,OAAO,EAAE,MAAA,EAAQ,cAAA,IACf,IAAI,IAAA,CAAK,EAAE,MAAA,EAAQ,SAAA,IAAa,EAAE,CAAA,GAAI,IAAI,IAAA,CAAK,CAAA,CAAE,QAAQ,SAAA,IAAa,EAAE,IACtE,CAAA,GACA,EAAA;AAAA,EACN,CAAC,CAAA;AACD,EAAA,OAAQ,QAAA,EAAU,IAAI,CAAA,EAAA,KAAM;AAC1B,IAAA,OAAO;AAAA,MACL,EAAA,EAAI,GAAG,QAAA,EAAU,IAAA;AAAA,MACjB,IAAA,EAAM,EAAA,CAAG,QAAA,EAAU,MAAA,GAAS,oBAAoB,CAAA;AAAA,MAChD,MAAA,EAAQ,yBAAyB,EAAE,CAAA;AAAA,MACnC,SAAA,EAAW,GAAG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AAA,IAC1C,mBAAA,EAAqB,oBAAoB,qBAAqB,CAAA;AAAA,IAC9D,oBAAA,EAAsB,oBAAoB,sBAAsB,CAAA;AAAA,IAChE,yBAAA,EAA2B,oBAAoB,2BAA2B;AAAA,GAC5E;AACF;AAEO,MAAM,eAAA,GAAkB,CAC7B,WAAA,KAEA,WAAA,EAAa,UAAU,WAAA,GAAc,yBAAA,CAA0B,IAAI,CAAA,KACnE,uBAAA,CAAwB;AAEnB,MAAM,WAAA,GAAc,CACzB,WAAA,KAAA,CAEC,WAAA,EAAa,QAAQ,OAAA,IAAW,WAAA,EAAa,QAAQ,WAAA,GAAc,IAAA;AAAA,EAClE,CAAA,CAAA,KAAK,CAAA,CAAE,IAAA,KAAS,sBAAA,CAAuB;AACzC,CAAA,EAAG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tekton-utils.esm.js","sources":["../../src/utils/tekton-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 {\n ClusterObjects,\n ObjectsByEntityResponse,\n} from '@backstage/plugin-kubernetes-common';\n\nimport { get } from 'lodash';\n\nimport {\n ComputedStatus,\n getTaskRunsForPipelineRun,\n pipelineRunFilterReducer,\n PipelineRunKind,\n pipelineRunStatus,\n SucceedConditionReason,\n TaskRunKind,\n TaskStatusTypes,\n updateTaskStatus,\n} from '@janus-idp/shared-react';\n\nimport { getPipelineRunScanResults } from '../hooks/usePipelineRunScanResults';\nimport { PipelineRunGVK, TaskRunGVK } from '../models';\nimport {\n ClusterErrors,\n Order,\n PipelineRunScanResults,\n TektonResponseData,\n} from '../types/types';\nimport { TranslationFunction } from '@backstage/core-plugin-api/alpha';\nimport { tektonTranslationRef } from '../translation';\n\nexport const getClusters = (k8sObjects: ObjectsByEntityResponse) => {\n const clusters: string[] = k8sObjects.items.map(\n (item: ClusterObjects) => item.cluster.name,\n );\n const errors: ClusterErrors[] = k8sObjects.items.map(\n (item: ClusterObjects) => item.errors,\n );\n return { clusters, errors };\n};\n\nconst isTektonResource = (kind: string) =>\n [PipelineRunGVK.kind, TaskRunGVK.kind].includes(kind);\n\nconst getResourceType = (kind: string) => {\n switch (kind) {\n case PipelineRunGVK.kind:\n return 'pipelineruns';\n case TaskRunGVK.kind:\n return 'taskruns';\n default:\n return '';\n }\n};\n\nexport const getTektonResources = (\n cluster: number,\n k8sObjects: ObjectsByEntityResponse,\n) =>\n k8sObjects.items?.[cluster]?.resources?.reduce(\n (acc: TektonResponseData, res: any) => {\n if (res.type === 'pods') {\n return {\n ...acc,\n pods: { data: res.resources },\n };\n }\n if (\n res.type !== 'customresources' ||\n (res.type === 'customresources' && res.resources.length === 0)\n ) {\n return acc;\n }\n const customResKind = res.resources[0].kind;\n return {\n ...acc,\n ...(isTektonResource(customResKind) && {\n [getResourceType(customResKind)]: {\n data: res.resources,\n },\n }),\n };\n },\n {},\n );\n\nexport const totalPipelineRunTasks = (pipelinerun: PipelineRunKind): number => {\n if (!pipelinerun?.status?.pipelineSpec) {\n return 0;\n }\n const totalTasks = (pipelinerun.status.pipelineSpec?.tasks || []).length;\n const finallyTasks =\n (pipelinerun.status.pipelineSpec?.finally || []).length ?? 0;\n return totalTasks + finallyTasks;\n};\n\nexport const getTaskStatusOfPLR = (\n pipelinerun: PipelineRunKind,\n taskRuns: TaskRunKind[],\n) => {\n const totalTasks = totalPipelineRunTasks(pipelinerun);\n const plrTasks = getTaskRunsForPipelineRun(pipelinerun, taskRuns);\n const plrTaskLength = plrTasks?.length;\n const skippedTaskLength = pipelinerun?.status?.skippedTasks?.length || 0;\n\n const taskStatus: TaskStatusTypes = updateTaskStatus(pipelinerun, plrTasks);\n\n if (plrTasks?.length > 0) {\n const pipelineRunHasFailure = taskStatus[ComputedStatus.Failed] > 0;\n const pipelineRunIsCancelled =\n pipelineRunFilterReducer(pipelinerun) === ComputedStatus.Cancelled;\n const unhandledTasks =\n totalTasks >= plrTaskLength\n ? totalTasks - plrTaskLength - skippedTaskLength\n : totalTasks;\n\n if (pipelineRunHasFailure || pipelineRunIsCancelled) {\n taskStatus[ComputedStatus.Cancelled] += unhandledTasks;\n } else {\n taskStatus[ComputedStatus.Pending] += unhandledTasks;\n }\n } else if (\n pipelinerun?.status?.conditions?.[0]?.status === 'False' ||\n pipelinerun?.spec?.status === SucceedConditionReason.PipelineRunCancelled\n ) {\n taskStatus[ComputedStatus.Cancelled] = totalTasks;\n } else if (\n pipelinerun?.spec?.status === SucceedConditionReason.PipelineRunPending\n ) {\n taskStatus[ComputedStatus.Pending] += totalTasks;\n } else {\n taskStatus[ComputedStatus.PipelineNotStarted]++;\n }\n return taskStatus;\n};\n\nexport const getDuration = (\n t: TranslationFunction<typeof tektonTranslationRef.T>,\n seconds: number,\n long?: boolean,\n): string => {\n if (seconds === 0) {\n return t('pipelineRunDuration.lessThanSec');\n }\n let sec = Math.round(seconds);\n let min = 0;\n let hr = 0;\n let duration = '';\n if (sec >= 60) {\n min = Math.floor(sec / 60);\n sec %= 60;\n }\n if (min >= 60) {\n hr = Math.floor(min / 60);\n min %= 60;\n }\n if (hr > 0) {\n duration += long ? t('pipelineRunDuration.hour', { count: hr }) : `${hr}h`;\n duration += ' ';\n }\n if (min > 0) {\n duration += long\n ? t('pipelineRunDuration.minute', { count: min })\n : `${min}m`;\n duration += ' ';\n }\n if (sec > 0) {\n duration += long\n ? t('pipelineRunDuration.second', { count: sec })\n : `${sec}s`;\n }\n\n return duration.trim();\n};\n\nexport const descendingComparator = (\n a: PipelineRunKind,\n b: PipelineRunKind,\n orderBy: string,\n) => {\n if (get(b, orderBy) < get(a, orderBy)) {\n return -1;\n }\n if (get(b, orderBy) > get(a, orderBy)) {\n return 1;\n }\n return 0;\n};\n\nexport const calculateDurationInSeconds = (\n startTime: string,\n endTime?: string,\n) => {\n const start = new Date(startTime).getTime();\n const end = endTime ? new Date(endTime).getTime() : new Date().getTime();\n const durationInSeconds = (end - start) / 1000;\n return durationInSeconds;\n};\n\nexport const durationComparator = (a: PipelineRunKind, b: PipelineRunKind) => {\n const durationA = a.status?.startTime\n ? calculateDurationInSeconds(a.status?.startTime, a.status?.completionTime)\n : 0;\n\n const durationB = b.status?.startTime\n ? calculateDurationInSeconds(b.status?.startTime, b.status?.completionTime)\n : 0;\n\n if (durationB < durationA) {\n return -1;\n }\n if (durationB > durationA) {\n return 1;\n }\n return 0;\n};\n\nconst vulnerabilitiesSortValue = (\n scanResults: PipelineRunScanResults,\n): number => {\n if (!scanResults?.vulnerabilities) {\n return -1;\n }\n // Expect no more than 999 of any one severity\n return (\n (scanResults.vulnerabilities.critical ?? 0) * 1000000000 +\n (scanResults.vulnerabilities.high ?? 0) * 1000000 +\n (scanResults.vulnerabilities.medium ?? 0) * 1000 +\n (scanResults.vulnerabilities.low ?? 0)\n );\n};\n\nexport const vulnerabilitiesComparator = (\n a: PipelineRunKind,\n b: PipelineRunKind,\n) => {\n const vulnerabilitiesSortValueA = vulnerabilitiesSortValue(\n getPipelineRunScanResults(a),\n );\n const vulnerabilitiesSortValueB = vulnerabilitiesSortValue(\n getPipelineRunScanResults(b),\n );\n\n if (vulnerabilitiesSortValueB < vulnerabilitiesSortValueA) {\n return -1;\n }\n if (vulnerabilitiesSortValueB > vulnerabilitiesSortValueA) {\n return 1;\n }\n return 0;\n};\n\nexport const getComparator = (\n order: Order,\n orderBy: string,\n orderById: string,\n) => {\n switch (orderById) {\n case 'duration':\n return (a: PipelineRunKind, b: PipelineRunKind) => {\n return order === 'desc'\n ? durationComparator(a, b)\n : -durationComparator(a, b);\n };\n case 'vulnerabilities':\n return (a: PipelineRunKind, b: PipelineRunKind) => {\n return order === 'desc'\n ? vulnerabilitiesComparator(a, b)\n : -vulnerabilitiesComparator(a, b);\n };\n default:\n return (a: PipelineRunKind, b: PipelineRunKind) => {\n return order === 'desc'\n ? descendingComparator(a, b, orderBy)\n : -descendingComparator(a, b, orderBy);\n };\n }\n};\n\nexport const calculateDuration = (\n t: TranslationFunction<typeof tektonTranslationRef.T>,\n startTime: string,\n endTime?: string,\n long?: boolean,\n) => {\n const durationInSeconds = calculateDurationInSeconds(startTime, endTime);\n return getDuration(t, durationInSeconds, long);\n};\n\nexport const pipelineRunDuration = (\n run: PipelineRunKind,\n t: TranslationFunction<typeof tektonTranslationRef.T>,\n): string => {\n if (!run || Object.keys(run).length === 0) {\n return '-';\n }\n const startTime = run.status?.startTime;\n const completionTime = run.status?.completionTime;\n\n // Duration cannot be computed if start time is missing or a completed/failed pipeline/task has no end time\n if (!startTime || (!completionTime && pipelineRunStatus(run) !== 'Running')) {\n return '-';\n }\n return calculateDuration(t, startTime, completionTime, true);\n};\n"],"names":[],"mappings":";;;;;AA6Ca,MAAA,WAAA,GAAc,CAAC,UAAwC,KAAA;AAClE,EAAM,MAAA,QAAA,GAAqB,WAAW,KAAM,CAAA,GAAA;AAAA,IAC1C,CAAC,IAAyB,KAAA,IAAA,CAAK,OAAQ,CAAA;AAAA,GACzC;AACA,EAAM,MAAA,MAAA,GAA0B,WAAW,KAAM,CAAA,GAAA;AAAA,IAC/C,CAAC,SAAyB,IAAK,CAAA;AAAA,GACjC;AACA,EAAO,OAAA,EAAE,UAAU,MAAO,EAAA;AAC5B;AAEA,MAAM,gBAAA,GAAmB,CAAC,IAAA,KACxB,CAAC,cAAA,CAAe,MAAM,UAAW,CAAA,IAAI,CAAE,CAAA,QAAA,CAAS,IAAI,CAAA;AAEtD,MAAM,eAAA,GAAkB,CAAC,IAAiB,KAAA;AACxC,EAAA,QAAQ,IAAM;AAAA,IACZ,KAAK,cAAe,CAAA,IAAA;AAClB,MAAO,OAAA,cAAA;AAAA,IACT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AAA,KAAU,SACb,yBAA0B,CAAA,CAAA,EAAG,CAAC,CAC9B,GAAA,CAAC,yBAA0B,CAAA,CAAA,EAAG,CAAC,CAAA;AAAA,OACrC;AAAA,IACF;AACE,MAAO,OAAA,CAAC,GAAoB,CAAuB,KAAA;AACjD,QAAO,OAAA,KAAA,KAAU,MACb,GAAA,oBAAA,CAAqB,CAAG,EAAA,CAAA,EAAG,OAAO,CAAA,GAClC,CAAC,oBAAA,CAAqB,CAAG,EAAA,CAAA,EAAG,OAAO,CAAA;AAAA,OACzC;AAAA;AAEN;AAEO,MAAM,iBAAoB,GAAA,CAC/B,CACA,EAAA,SAAA,EACA,SACA,IACG,KAAA;AACH,EAAM,MAAA,iBAAA,GAAoB,0BAA2B,CAAA,SAAA,EAAW,OAAO,CAAA;AACvE,EAAO,OAAA,WAAA,CAAY,CAAG,EAAA,iBAAA,EAAmB,IAAI,CAAA;AAC/C;AAEa,MAAA,mBAAA,GAAsB,CACjC,GAAA,EACA,CACW,KAAA;AACX,EAAA,IAAI,CAAC,GAAO,IAAA,MAAA,CAAO,KAAK,GAAG,CAAA,CAAE,WAAW,CAAG,EAAA;AACzC,IAAO,OAAA,GAAA;AAAA;AAET,EAAM,MAAA,SAAA,GAAY,IAAI,MAAQ,EAAA,SAAA;AAC9B,EAAM,MAAA,cAAA,GAAiB,IAAI,MAAQ,EAAA,cAAA;AAGnC,EAAA,IAAI,CAAC,SAAc,IAAA,CAAC,kBAAkB,iBAAkB,CAAA,GAAG,MAAM,SAAY,EAAA;AAC3E,IAAO,OAAA,GAAA;AAAA;AAET,EAAA,OAAO,iBAAkB,CAAA,CAAA,EAAG,SAAW,EAAA,cAAA,EAAgB,IAAI,CAAA;AAC7D;;;;"}
|
|
1
|
+
{"version":3,"file":"tekton-utils.esm.js","sources":["../../src/utils/tekton-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 {\n ClusterObjects,\n ObjectsByEntityResponse,\n} from '@backstage/plugin-kubernetes-common';\n\nimport { get } from 'lodash';\n\nimport {\n ComputedStatus,\n getTaskRunsForPipelineRun,\n pipelineRunFilterReducer,\n PipelineRunKind,\n pipelineRunStatus,\n SucceedConditionReason,\n TaskRunKind,\n TaskStatusTypes,\n updateTaskStatus,\n} from '@janus-idp/shared-react';\n\nimport { getPipelineRunScanResults } from '../hooks/usePipelineRunScanResults';\nimport { PipelineRunGVK, TaskRunGVK } from '../models';\nimport {\n ClusterErrors,\n Order,\n PipelineRunScanResults,\n TektonResponseData,\n} from '../types/types';\nimport { TranslationFunction } from '@backstage/core-plugin-api/alpha';\nimport { tektonTranslationRef } from '../translation';\n\nexport const getClusters = (k8sObjects: ObjectsByEntityResponse) => {\n const clusters: string[] = k8sObjects.items.map(\n (item: ClusterObjects) => item.cluster.name,\n );\n const errors: ClusterErrors[] = k8sObjects.items.map(\n (item: ClusterObjects) => item.errors,\n );\n return { clusters, errors };\n};\n\nconst isTektonResource = (kind: string) =>\n [PipelineRunGVK.kind, TaskRunGVK.kind].includes(kind);\n\nconst getResourceType = (kind: string) => {\n switch (kind) {\n case PipelineRunGVK.kind:\n return 'pipelineruns';\n case TaskRunGVK.kind:\n return 'taskruns';\n default:\n return '';\n }\n};\n\nexport const getTektonResources = (\n cluster: number,\n k8sObjects: ObjectsByEntityResponse,\n) =>\n k8sObjects.items?.[cluster]?.resources?.reduce(\n (acc: TektonResponseData, res: any) => {\n if (res.type === 'pods') {\n return {\n ...acc,\n pods: { data: res.resources },\n };\n }\n if (\n res.type !== 'customresources' ||\n (res.type === 'customresources' && res.resources.length === 0)\n ) {\n return acc;\n }\n const customResKind = res.resources[0].kind;\n return {\n ...acc,\n ...(isTektonResource(customResKind) && {\n [getResourceType(customResKind)]: {\n data: res.resources,\n },\n }),\n };\n },\n {},\n );\n\nexport const totalPipelineRunTasks = (pipelinerun: PipelineRunKind): number => {\n if (!pipelinerun?.status?.pipelineSpec) {\n return 0;\n }\n const totalTasks = (pipelinerun.status.pipelineSpec?.tasks || []).length;\n const finallyTasks =\n (pipelinerun.status.pipelineSpec?.finally || []).length ?? 0;\n return totalTasks + finallyTasks;\n};\n\nexport const getTaskStatusOfPLR = (\n pipelinerun: PipelineRunKind,\n taskRuns: TaskRunKind[],\n) => {\n const totalTasks = totalPipelineRunTasks(pipelinerun);\n const plrTasks = getTaskRunsForPipelineRun(pipelinerun, taskRuns);\n const plrTaskLength = plrTasks?.length;\n const skippedTaskLength = pipelinerun?.status?.skippedTasks?.length || 0;\n\n const taskStatus: TaskStatusTypes = updateTaskStatus(pipelinerun, plrTasks);\n\n if (plrTasks?.length > 0) {\n const pipelineRunHasFailure = taskStatus[ComputedStatus.Failed] > 0;\n const pipelineRunIsCancelled =\n pipelineRunFilterReducer(pipelinerun) === ComputedStatus.Cancelled;\n const unhandledTasks =\n totalTasks >= plrTaskLength\n ? totalTasks - plrTaskLength - skippedTaskLength\n : totalTasks;\n\n if (pipelineRunHasFailure || pipelineRunIsCancelled) {\n taskStatus[ComputedStatus.Cancelled] += unhandledTasks;\n } else {\n taskStatus[ComputedStatus.Pending] += unhandledTasks;\n }\n } else if (\n pipelinerun?.status?.conditions?.[0]?.status === 'False' ||\n pipelinerun?.spec?.status === SucceedConditionReason.PipelineRunCancelled\n ) {\n taskStatus[ComputedStatus.Cancelled] = totalTasks;\n } else if (\n pipelinerun?.spec?.status === SucceedConditionReason.PipelineRunPending\n ) {\n taskStatus[ComputedStatus.Pending] += totalTasks;\n } else {\n taskStatus[ComputedStatus.PipelineNotStarted]++;\n }\n return taskStatus;\n};\n\nexport const getDuration = (\n t: TranslationFunction<typeof tektonTranslationRef.T>,\n seconds: number,\n long?: boolean,\n): string => {\n if (seconds === 0) {\n return t('pipelineRunDuration.lessThanSec');\n }\n let sec = Math.round(seconds);\n let min = 0;\n let hr = 0;\n let duration = '';\n if (sec >= 60) {\n min = Math.floor(sec / 60);\n sec %= 60;\n }\n if (min >= 60) {\n hr = Math.floor(min / 60);\n min %= 60;\n }\n if (hr > 0) {\n duration += long ? t('pipelineRunDuration.hour', { count: hr }) : `${hr}h`;\n duration += ' ';\n }\n if (min > 0) {\n duration += long\n ? t('pipelineRunDuration.minute', { count: min })\n : `${min}m`;\n duration += ' ';\n }\n if (sec > 0) {\n duration += long\n ? t('pipelineRunDuration.second', { count: sec })\n : `${sec}s`;\n }\n\n return duration.trim();\n};\n\nexport const descendingComparator = (\n a: PipelineRunKind,\n b: PipelineRunKind,\n orderBy: string,\n) => {\n if (get(b, orderBy) < get(a, orderBy)) {\n return -1;\n }\n if (get(b, orderBy) > get(a, orderBy)) {\n return 1;\n }\n return 0;\n};\n\nexport const calculateDurationInSeconds = (\n startTime: string,\n endTime?: string,\n) => {\n const start = new Date(startTime).getTime();\n const end = endTime ? new Date(endTime).getTime() : new Date().getTime();\n const durationInSeconds = (end - start) / 1000;\n return durationInSeconds;\n};\n\nexport const durationComparator = (a: PipelineRunKind, b: PipelineRunKind) => {\n const durationA = a.status?.startTime\n ? calculateDurationInSeconds(a.status?.startTime, a.status?.completionTime)\n : 0;\n\n const durationB = b.status?.startTime\n ? calculateDurationInSeconds(b.status?.startTime, b.status?.completionTime)\n : 0;\n\n if (durationB < durationA) {\n return -1;\n }\n if (durationB > durationA) {\n return 1;\n }\n return 0;\n};\n\nconst vulnerabilitiesSortValue = (\n scanResults: PipelineRunScanResults,\n): number => {\n if (!scanResults?.vulnerabilities) {\n return -1;\n }\n // Expect no more than 999 of any one severity\n return (\n (scanResults.vulnerabilities.critical ?? 0) * 1000000000 +\n (scanResults.vulnerabilities.high ?? 0) * 1000000 +\n (scanResults.vulnerabilities.medium ?? 0) * 1000 +\n (scanResults.vulnerabilities.low ?? 0)\n );\n};\n\nexport const vulnerabilitiesComparator = (\n a: PipelineRunKind,\n b: PipelineRunKind,\n) => {\n const vulnerabilitiesSortValueA = vulnerabilitiesSortValue(\n getPipelineRunScanResults(a),\n );\n const vulnerabilitiesSortValueB = vulnerabilitiesSortValue(\n getPipelineRunScanResults(b),\n );\n\n if (vulnerabilitiesSortValueB < vulnerabilitiesSortValueA) {\n return -1;\n }\n if (vulnerabilitiesSortValueB > vulnerabilitiesSortValueA) {\n return 1;\n }\n return 0;\n};\n\nexport const getComparator = (\n order: Order,\n orderBy: string,\n orderById: string,\n) => {\n switch (orderById) {\n case 'duration':\n return (a: PipelineRunKind, b: PipelineRunKind) => {\n return order === 'desc'\n ? durationComparator(a, b)\n : -durationComparator(a, b);\n };\n case 'vulnerabilities':\n return (a: PipelineRunKind, b: PipelineRunKind) => {\n return order === 'desc'\n ? vulnerabilitiesComparator(a, b)\n : -vulnerabilitiesComparator(a, b);\n };\n default:\n return (a: PipelineRunKind, b: PipelineRunKind) => {\n return order === 'desc'\n ? descendingComparator(a, b, orderBy)\n : -descendingComparator(a, b, orderBy);\n };\n }\n};\n\nexport const calculateDuration = (\n t: TranslationFunction<typeof tektonTranslationRef.T>,\n startTime: string,\n endTime?: string,\n long?: boolean,\n) => {\n const durationInSeconds = calculateDurationInSeconds(startTime, endTime);\n return getDuration(t, durationInSeconds, long);\n};\n\nexport const pipelineRunDuration = (\n run: PipelineRunKind,\n t: TranslationFunction<typeof tektonTranslationRef.T>,\n): string => {\n if (!run || Object.keys(run).length === 0) {\n return '-';\n }\n const startTime = run.status?.startTime;\n const completionTime = run.status?.completionTime;\n\n // Duration cannot be computed if start time is missing or a completed/failed pipeline/task has no end time\n if (!startTime || (!completionTime && pipelineRunStatus(run) !== 'Running')) {\n return '-';\n }\n return calculateDuration(t, startTime, completionTime, true);\n};\n"],"names":[],"mappings":";;;;;AA6CO,MAAM,WAAA,GAAc,CAAC,UAA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I,CAAA;AAC/C;AAEO,MAAM,mBAAA,GAAsB,CACjC,GAAA,EACA,CAAA,KACW;AACX,EAAA,IAAI,CAAC,GAAA,IAAO,MAAA,CAAO,KAAK,GAAG,CAAA,CAAE,WAAW,CAAA,EAAG;AACzC,IAAA,OAAO,GAAA;AAAA,EACT;AACA,EAAA,MAAM,SAAA,GAAY,IAAI,MAAA,EAAQ,SAAA;AAC9B,EAAA,MAAM,cAAA,GAAiB,IAAI,MAAA,EAAQ,cAAA;AAGnC,EAAA,IAAI,CAAC,SAAA,IAAc,CAAC,kBAAkB,iBAAA,CAAkB,GAAG,MAAM,SAAA,EAAY;AAC3E,IAAA,OAAO,GAAA;AAAA,EACT;AACA,EAAA,OAAO,iBAAA,CAAkB,CAAA,EAAG,SAAA,EAAW,cAAA,EAAgB,IAAI,CAAA;AAC7D;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-tekton",
|
|
3
|
-
"version": "3.27.
|
|
3
|
+
"version": "3.27.5",
|
|
4
4
|
"main": "dist/index.esm.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"@backstage/core-components": "^0.17.4",
|
|
40
40
|
"@backstage/core-plugin-api": "^1.10.9",
|
|
41
41
|
"@backstage/plugin-catalog-react": "^1.19.1",
|
|
42
|
-
"@backstage/plugin-kubernetes": "^0.12.9",
|
|
43
42
|
"@backstage/plugin-kubernetes-common": "^0.9.6",
|
|
44
43
|
"@backstage/plugin-kubernetes-react": "^0.5.9",
|
|
45
44
|
"@backstage/plugin-permission-react": "^0.4.36",
|
|
@@ -51,7 +50,6 @@
|
|
|
51
50
|
"@material-ui/lab": "^4.0.0-alpha.45",
|
|
52
51
|
"@mui/icons-material": "5.18.0",
|
|
53
52
|
"@patternfly/patternfly": "^6.0.0",
|
|
54
|
-
"@patternfly/react-charts": "^7.1.1",
|
|
55
53
|
"@patternfly/react-core": "^6.0.0",
|
|
56
54
|
"@patternfly/react-tokens": "^6.0.0",
|
|
57
55
|
"@patternfly/react-topology": "^6.0.0",
|
|
@@ -59,7 +57,6 @@
|
|
|
59
57
|
"classnames": "^2.3.2",
|
|
60
58
|
"dagre": "^0.8.5",
|
|
61
59
|
"lodash": "^4.17.21",
|
|
62
|
-
"react-measure": "^2.5.2",
|
|
63
60
|
"react-use": "^17.4.0"
|
|
64
61
|
},
|
|
65
62
|
"peerDependencies": {
|
|
@@ -69,14 +66,11 @@
|
|
|
69
66
|
},
|
|
70
67
|
"devDependencies": {
|
|
71
68
|
"@backstage/cli": "^0.33.1",
|
|
72
|
-
"@backstage/core-app-api": "^1.18.0",
|
|
73
69
|
"@backstage/dev-utils": "^1.1.12",
|
|
74
70
|
"@backstage/test-utils": "^1.7.10",
|
|
75
71
|
"@playwright/test": "^1.52.0",
|
|
76
|
-
"@testing-library/jest-dom": "6.
|
|
72
|
+
"@testing-library/jest-dom": "6.7.0",
|
|
77
73
|
"@testing-library/react": "14.3.1",
|
|
78
|
-
"@testing-library/react-hooks": "8.0.1",
|
|
79
|
-
"@testing-library/user-event": "14.6.1",
|
|
80
74
|
"@types/dagre": "^0.7.52",
|
|
81
75
|
"@types/lodash": "4.17.20",
|
|
82
76
|
"cross-fetch": "4.0.0",
|