Skip to content

Commit

Permalink
check for taskRef kind in the TR spec
Browse files Browse the repository at this point in the history
  • Loading branch information
debsmita1 committed Nov 3, 2020
1 parent 3da7b18 commit 240d097
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import * as React from 'react';
import { TableRow, TableData, RowFunction } from '@console/internal/components/factory';
import { ResourceLink, Timestamp, Kebab, ResourceKebab } from '@console/internal/components/utils';
import { referenceForModel } from '@console/internal/module/k8s';
import { TaskRunKind } from '../../../utils/pipeline-augment';
import { TaskRunModel, PipelineModel, TaskModel } from '../../../models';
import { TaskRunKind, getModelReferenceFromTaskKind } from '../../../utils/pipeline-augment';
import { TaskRunModel, PipelineModel } from '../../../models';
import { tableColumnClasses } from './taskruns-table';
import { Status } from '@console/shared';
import { pipelineRunFilterReducer as taskRunFilterReducer } from '../../../utils/pipeline-filter-reducer';

const taskRunsReference = referenceForModel(TaskRunModel);
const taskReference = referenceForModel(TaskModel);
const pipelineReference = referenceForModel(PipelineModel);

const TaskRunsRow: RowFunction<TaskRunKind> = ({ obj, index, key, style, ...props }) => (
Expand Down Expand Up @@ -42,7 +41,7 @@ const TaskRunsRow: RowFunction<TaskRunKind> = ({ obj, index, key, style, ...prop
<TableData className={tableColumnClasses[3]}>
{obj.spec.taskRef?.name ? (
<ResourceLink
kind={taskReference}
kind={getModelReferenceFromTaskKind(obj.spec.taskRef?.kind)}
name={obj.spec.taskRef.name}
namespace={obj.metadata.namespace}
/>
Expand Down
6 changes: 6 additions & 0 deletions frontend/packages/dev-console/src/utils/pipeline-augment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
K8sResourceKind,
PersistentVolumeClaimKind,
referenceForModel,
GroupVersionKind,
} from '@console/internal/module/k8s';
import {
ClusterTaskModel,
Expand Down Expand Up @@ -491,3 +492,8 @@ export const getResourceModelFromTask = (task: PipelineTask): K8sKind => {

export const pipelineRefExists = (pipelineRun: PipelineRun): boolean =>
!!pipelineRun.spec.pipelineRef?.name;

export const getModelReferenceFromTaskKind = (kind: string): GroupVersionKind => {
const model = getResourceModelFromTaskKind(kind);
return referenceForModel(model);
};

0 comments on commit 240d097

Please sign in to comment.