Skip to content

Commit

Permalink
fix(tekton): external sbom view action should not open logs modal (#1152
Browse files Browse the repository at this point in the history
)
  • Loading branch information
karthikjeeyar authored Feb 2, 2024
1 parent 91742e8 commit 714ac5d
Show file tree
Hide file tree
Showing 6 changed files with 411 additions and 10 deletions.
184 changes: 184 additions & 0 deletions plugins/tekton/src/__fixtures__/1-pipelinesData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {
acsImageCheckTaskRun,
acsImageScanTaskRun,
enterpriseContractTaskRun,
taskRunWithSBOMResult,
taskRunWithSBOMResultExternalLink,
} from './taskRunData';

export const mockKubernetesPlrResponse = {
Expand Down Expand Up @@ -393,6 +395,66 @@ export const mockKubernetesPlrResponse = {
phase: 'Succeeded',
conditions: [],

startTime: new Date('2023-12-08T12:19:38Z'),
},
},
{
metadata: {
name: 'pipelinerun-with-sbom-task-t237ev-sbom-task-pod',
namespace: 'karthik',
uid: '055cc13a-bd3e-414e-9eb6-e6cb72870578',
resourceVersion: '379623',
labels: {
'backstage.io/kubernetes-id': 'developer-portal',
'janus-idp.io/tekton': 'developer-portal',
'tekton.dev/pipeline': 'test-pipeline',
'tekton.dev/pipelineRun': 'pipelinerun-with-sbom-task',
'tekton.dev/pipelineTask': 'sbom-task',
'tekton.dev/task': 'sbom-task',
'tekton.dev/taskRun': 'test-pipeline-8e09zm-sbom-task',
},
},
spec: {
containers: [
{
name: 'step-print-sbom-results',
},
],
},
status: {
phase: 'Succeeded',
conditions: [],

startTime: new Date('2023-12-08T12:19:38Z'),
},
},
{
metadata: {
name: 'pipelinerun-with-sbom-task-with-external-pod',
namespace: 'karthik',
uid: '055cc13a-bd3e-414e-9eb6-e6cb72870578',
resourceVersion: '379623',
labels: {
'backstage.io/kubernetes-id': 'developer-portal',
'janus-idp.io/tekton': 'developer-portal',
'tekton.dev/pipeline': 'test-pipeline',
'tekton.dev/pipelineRun': 'pipelinerun-with-external-sbom-task',
'tekton.dev/pipelineTask': 'sbom-task-with-external-link',
'tekton.dev/task': 'sbom-task-with-external-link',
'tekton.dev/taskRun': 'test-pipeline-8e09zm-sbom-task',
},
},
spec: {
containers: [
{
name: 'step-print-sbom-results',
},
],
},
status: {
phase: 'Succeeded',
conditions: [],

startTime: new Date('2023-12-08T12:19:38Z'),
},
},
Expand Down Expand Up @@ -640,6 +702,126 @@ export const mockKubernetesPlrResponse = {
startTime: '2023-04-11T05:49:05Z',
},
},
{
apiVersion: 'tekton.dev/v1',
kind: 'PipelineRun',
metadata: {
annotations: {
'pipeline.openshift.io/started-by': 'kube-admin',
'chains.tekton.dev/signed': 'false',
},
labels: {
'backstage.io/kubernetes-id': 'test-backstage',
'tekton.dev/pipeline': 'pipeline-test',
'app.kubernetes.io/instance': 'abs',
'app.kubernetes.io/name': 'ghg',
'operator.tekton.dev/operand-name': 'ytui',
'pipeline.openshift.io/runtime-version': 'hjkhk',
'pipeline.openshift.io/type': 'hhu',
'pipeline.openshift.io/runtime': 'node',
},
name: 'pipelinerun-with-sbom-task',
namespace: 'deb-test',
resourceVersion: '117337',
uid: '0a091bbf-3813-48d3-a6ce-fc43644a9b24',
creationTimestamp: new Date('2023-04-11T12:31:56Z'),
},
spec: {
pipelineRef: {
name: 'pipeline-test',
},
serviceAccountName: 'pipeline',
workspaces: [],
},
status: {
completionTime: '2023-04-11T06:49:05Z',
conditions: [
{
lastTransitionTime: '2023-03-30T07:05:13Z',
message: 'Tasks Completed: 3 (Failed: 0, Cancelled 0), Skipped: 0',
reason: 'Succeeded',
status: 'True',
type: 'Succeeded',
},
],
pipelineSpec: {
tasks: [
{
name: 'sbom-task',
params: [],
taskRef: {
kind: 'ClusterTask',
name: 'sbom-task',
},
workspaces: [],
},
],
workspaces: [],
startTime: '2023-04-11T06:48:50Z',
},
startTime: '2023-04-11T05:49:05Z',
},
},
{
apiVersion: 'tekton.dev/v1',
kind: 'PipelineRun',
metadata: {
annotations: {
'pipeline.openshift.io/started-by': 'kube-admin',
'chains.tekton.dev/signed': 'false',
},
labels: {
'backstage.io/kubernetes-id': 'test-backstage',
'tekton.dev/pipeline': 'pipeline-test',
'app.kubernetes.io/instance': 'abs',
'app.kubernetes.io/name': 'ghg',
'operator.tekton.dev/operand-name': 'ytui',
'pipeline.openshift.io/runtime-version': 'hjkhk',
'pipeline.openshift.io/type': 'hhu',
'pipeline.openshift.io/runtime': 'node',
},
name: 'pipelinerun-with-external-sbom-task',
namespace: 'deb-test',
resourceVersion: '117337',
uid: '0a091bbf-3813-48d3-a6ce-fc43644a9b24',
creationTimestamp: new Date('2023-04-11T12:31:56Z'),
},
spec: {
pipelineRef: {
name: 'pipeline-test',
},
serviceAccountName: 'pipeline',
workspaces: [],
},
status: {
completionTime: '2023-04-11T06:49:05Z',
conditions: [
{
lastTransitionTime: '2023-03-30T07:05:13Z',
message: 'Tasks Completed: 3 (Failed: 0, Cancelled 0), Skipped: 0',
reason: 'Succeeded',
status: 'True',
type: 'Succeeded',
},
],
pipelineSpec: {
tasks: [
{
name: 'sbom-task-with-external-link',
params: [],
taskRef: {
kind: 'ClusterTask',
name: 'sbom-task-with-external-link',
},
workspaces: [],
},
],
workspaces: [],
startTime: '2023-04-11T06:48:50Z',
},
startTime: '2023-04-11T05:49:05Z',
},
},
],
taskruns: [
{
Expand Down Expand Up @@ -1051,6 +1233,8 @@ export const mockKubernetesPlrResponse = {
},
},
},
taskRunWithSBOMResult,
taskRunWithSBOMResultExternalLink,
enterpriseContractTaskRun,
acsImageScanTaskRun,
acsImageCheckTaskRun,
Expand Down
38 changes: 32 additions & 6 deletions plugins/tekton/src/__fixtures__/taskRunData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,26 @@ export const taskRunWithSBOMResult = {
'task.results.key': 'LINK_TO_SBOM',
},
labels: {
[TEKTON_PIPELINE_RUN]: 'test-plr',
[TEKTON_PIPELINE_RUN]: 'pipelinerun-with-sbom-task',
'tekton.dev/pipelineTask': 'sbom-task',
},
ownerReferences: [
{
apiVersion: 'tekton.dev/v1',
blockOwnerDeletion: true,
controller: true,
kind: 'PipelineRun',
name: 'pipelinerun-with-sbom-task',
uid: '0a091bbf-3813-48d3-a6ce-fc43644a9b24',
},
],
name: 'pipelinerun-with-sbom-task-t237ev-sbom-task',
uid: '764d0a6c-a4f6-419c-a3c3-585c2a9eb67c',
},
spec: {
serviceAccountName: 'pipeline',
taskRef: {
kind: 'Task',
kind: 'ClusterTask',
name: 'sbom-task',
},
timeout: '1h0m0s',
Expand Down Expand Up @@ -126,6 +137,20 @@ export const taskRunWithSBOMResultExternalLink: TaskRunKind = {
'task.results.type': 'external-link',
'task.results.key': 'LINK_TO_SBOM',
},
labels: {
[TEKTON_PIPELINE_RUN]: 'pipelinerun-with-external-sbom-task',
'tekton.dev/pipelineTask': 'sbom-task-with-external-link',
},
ownerReferences: [
{
apiVersion: 'tekton.dev/v1',
blockOwnerDeletion: true,
controller: true,
kind: 'PipelineRun',
name: 'pipelinerun-with-external-sbom-task',
uid: '0a091bbf-3813-48d3-a6ce-fc43644a9b24',
},
],
resourceVersion: '197373',
name: 'pipelinerun-with-sbom-task-t237ev-sbom-task',
uid: '764d0a6c-a4f6-419c-a3c3-585c2a9eb67c',
Expand All @@ -134,8 +159,8 @@ export const taskRunWithSBOMResultExternalLink: TaskRunKind = {
spec: {
serviceAccountName: 'pipeline',
taskRef: {
kind: 'Task',
name: 'sbom-task',
kind: 'ClusterTask',
name: 'sbom-task-with-external-link',
},
timeout: '1h0m0s',
},
Expand All @@ -150,12 +175,13 @@ export const taskRunWithSBOMResultExternalLink: TaskRunKind = {
type: 'Succeeded',
},
],
podName: 'pipelinerun-with-sbom-task-t237ev-sbom-task-pod',
podName: 'pipelinerun-with-sbom-task-with-external-pod',
results: [
{
name: 'LINK_TO_SBOM',
type: 'string',
value: 'http://quay.io/test/image:build-8e536-1692702836',
value:
'https://quay.io/repository/janus-idp/backstage-showcase?tab=tags',
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { TektonResourcesContext } from '../../hooks/TektonResourcesContext';
import {
getTaskrunsOutputGroup,
hasExternalLink,
isSbomTaskRun,
} from '../../utils/taskRun-utils';
import OutputIcon from '../Icons/OutputIcon';
Expand Down Expand Up @@ -115,9 +116,12 @@ const PipelineRunRowActions: React.FC<{ pipelineRun: PipelineRunKind }> = ({
}
>
<IconButton
data-testid="view-sbom-icon"
disabled={!sbomTaskRun || !isSbomTaskRun(sbomTaskRun)}
size="small"
onClick={() => openDialog()}
onClick={
!hasExternalLink(sbomTaskRun) ? () => openDialog() : undefined
}
style={{ pointerEvents: 'auto', padding: 0 }}
>
<PipelineRunSBOMLink sbomTaskRun={sbomTaskRun} />
Expand All @@ -133,6 +137,7 @@ const PipelineRunRowActions: React.FC<{ pipelineRun: PipelineRunKind }> = ({
}
>
<IconButton
data-testid="view-output-icon"
disabled={disabled}
size="small"
onClick={() => openOutputDialog()}
Expand Down
Loading

0 comments on commit 714ac5d

Please sign in to comment.