From 8052a8ed9227c042347d311987506b7d581cc6a1 Mon Sep 17 00:00:00 2001 From: Yevhen Vydolob Date: Wed, 20 May 2020 12:42:07 +0300 Subject: [PATCH] #277 show condition run as child for taskrun Signed-off-by: Yevhen Vydolob --- src/tekton.d.ts | 1 + src/tekton/tektonitem.ts | 6 - src/tkn.ts | 127 +- test/clustertask.json | 2303 -------------------------------- test/extension.test.ts | 7 - test/pipelinerun.json | 172 +++ test/tekton/taskrun.test.ts | 7 - test/tekton/tektonitem.test.ts | 21 - test/tkn.test.ts | 195 +-- 9 files changed, 302 insertions(+), 2537 deletions(-) delete mode 100644 test/clustertask.json create mode 100644 test/pipelinerun.json diff --git a/src/tekton.d.ts b/src/tekton.d.ts index a42951b3..bde29383 100644 --- a/src/tekton.d.ts +++ b/src/tekton.d.ts @@ -110,6 +110,7 @@ export interface ConditionCheckStatus { startTime?: string; completionTime?: string; check?: ContainerState; + conditions?: PipelineRunConditions[]; } export interface PipelineRunConditionCheckStatus { diff --git a/src/tekton/tektonitem.ts b/src/tekton/tektonitem.ts index 008b78bf..734cdf05 100644 --- a/src/tekton/tektonitem.ts +++ b/src/tekton/tektonitem.ts @@ -50,12 +50,6 @@ export abstract class TektonItem { return taskList; } - static async getTaskRunNames(taskRun: TektonNode): Promise { - const taskRunList: Array = await TektonItem.tkn.getTaskRunsForPipelineRun(taskRun); - if (taskRunList.length === 0) { throw Error(errorMessage.TaskRun); } - return taskRunList; - } - static async getPipelineResourceNames(pipelineResource: TektonNode): Promise { const pipelineResourceList: Array = await TektonItem.tkn.getPipelineResources(pipelineResource); if (pipelineResourceList.length === 0) { throw Error(errorMessage.PipelineResource); } diff --git a/src/tkn.ts b/src/tkn.ts index d573353c..4bc6e968 100644 --- a/src/tkn.ts +++ b/src/tkn.ts @@ -10,7 +10,7 @@ import * as path from 'path'; import { ToolsConfig } from './tools'; import format = require('string-format'); import humanize = require('humanize-duration'); -import { TknPipelineResource, TknTask, PipelineRunData } from './tekton'; +import { TknPipelineResource, TknTask, PipelineRunData, TaskRun as RawTaskRun, PipelineRunConditionCheckStatus } from './tekton'; import { kubectl } from './kubectl'; import { pipelineExplorer } from './pipeline/pipelineExplorer'; import { StartObject } from './tekton/pipelinecontent'; @@ -74,6 +74,7 @@ export enum ContextType { CONDITIONSNODE = 'conditionsnode', CONDITIONS = 'conditions', PIPELINERUNNODE = 'pipelinerunnode', + CONDITIONRUN = 'conditionrunnode', } // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -394,7 +395,7 @@ export class TektonNodeImpl implements TektonNode { pipelinerun: { icon: 'running.gif', tooltip: 'PipelineRun: {label}', - getChildren: () => this.tkn.getTaskRunsForPipelineRun(this) + getChildren: () => [] }, task: { icon: 'T.svg', @@ -406,6 +407,11 @@ export class TektonNodeImpl implements TektonNode { tooltip: 'TaskRun: {label}', getChildren: () => [] }, + conditionrunnode: { + icon: 'running.gif', + tooltip: 'ConditionRun: {label}', + getChildren: () => [] + }, clustertask: { icon: 'CT.svg', tooltip: 'Clustertask: {label}', @@ -476,7 +482,7 @@ export class TektonNodeImpl implements TektonNode { constructor(private parent: TektonNode, public readonly name: string, public readonly contextValue: ContextType, - private readonly tkn: Tkn, + protected readonly tkn: Tkn, public readonly collapsibleState: TreeItemCollapsibleState = TreeItemCollapsibleState.Collapsed, public readonly creationTime?: string, public readonly state?: string) { @@ -588,19 +594,86 @@ export class TaskRun extends TektonNodeImpl { } } +export abstract class BaseTaskRun extends TektonNodeImpl { + constructor(parent: TektonNode, + name: string, + contextType: ContextType, + tkn: Tkn, + collapsibleState: TreeItemCollapsibleState, + creationTime: string, + protected finished: string | undefined, + state: string) { + super(parent, name, contextType, tkn, collapsibleState, creationTime, state); + } + + get description(): string { + let r = ''; + if (this.getParent().contextValue === ContextType.TASK) { + if (this.creationTime) { + r = 'started ' + humanizer(Date.now() - Date.parse(this.creationTime)) + ' ago, finished in ' + humanizer(Date.parse(this.finished) - Date.parse(this.creationTime)); + } else { + r = 'started ' + humanizer(Date.now() - Date.parse(this.creationTime)) + ' ago, running for ' + humanizer(Date.now() - Date.parse(this.creationTime)); + } + } else { + if (this.finished) { + r = 'finished in ' + humanizer(Date.parse(this.finished) - Date.parse(this.creationTime)); + } else { + r = 'running for ' + humanizer(Date.now() - Date.parse(this.creationTime)); + } + } + return r; + } +} + +export class ConditionRun extends BaseTaskRun { + constructor(parent: TektonNode, name: string, tkn: Tkn, item: PipelineRunConditionCheckStatus) { + super(parent, name, ContextType.CONDITIONRUN, tkn, TreeItemCollapsibleState.None, item.status?.startTime, item.status?.completionTime, item.status?.conditions[0]?.status) + } +} + +export class TaskRunFromPipeline extends BaseTaskRun { + constructor(parent: TektonNode, name: string, tkn: Tkn, private rawTaskRun: RawTaskRun) { + super(parent, + name, + ContextType.TASKRUN, + tkn, + rawTaskRun.conditionChecks ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.None, + rawTaskRun.status.startTime, + rawTaskRun.status?.completionTime, + rawTaskRun.status ? rawTaskRun.status.conditions[0].status : ''); + } + + get label(): string { + return this.name; + } + + getChildren(): ProviderResult { + if (this.rawTaskRun.conditionChecks) { + const result = [] + for (const conditionName in this.rawTaskRun.conditionChecks) { + const rawCondition = this.rawTaskRun.conditionChecks[conditionName]; + result.push(new ConditionRun(this, rawCondition.conditionName, this.tkn, rawCondition)); + + } + return result.sort(compareTimeNewestFirst); + } else { + return super.getChildren(); + } + } +} export class PipelineRun extends TektonNodeImpl { private started: string; private finished: string; - private generateName: string; + private item: PipelineRunData; constructor(parent: TektonNode, name: string, tkn: Tkn, item: PipelineRunData, collapsibleState: TreeItemCollapsibleState) { super(parent, name, ContextType.PIPELINERUN, tkn, collapsibleState, item.metadata.creationTimestamp, item.status ? item.status.conditions[0].status : ''); this.started = item.metadata.creationTimestamp; - this.generateName = item.metadata.generateName; this.finished = item.status?.completionTime; + this.item = item; } get label(): string { @@ -616,6 +689,20 @@ export class PipelineRun extends TektonNodeImpl { } return r; } + + getChildren(): ProviderResult { + const result = []; + const tasks = this.item.status?.taskRuns; + if (!tasks) { + return result; + } + for (const task in tasks) { + const taskRun = tasks[task]; + result.push(new TaskRunFromPipeline(this, taskRun.pipelineTaskName, this.tkn, taskRun)); + } + + return result.sort(compareTimeNewestFirst); + } } export class MoreNode extends TreeItem implements TektonNode { @@ -664,7 +751,6 @@ export interface Tkn { getPipelineResources(pipelineResources: TektonNode): Promise; getTasks(task: TektonNode): Promise; getRawTasks(): Promise; - getTaskRunsForPipelineRun(taskRun: TektonNode): Promise; getClusterTasks(clustertask: TektonNode): Promise; getRawClusterTasks(): Promise; execute(command: CliCommand, cwd?: string, fail?: boolean): Promise; @@ -718,7 +804,7 @@ export class TknImpl implements Tkn { } if (result.error && getStderrString(result.error).indexOf('You must be logged in to the server (Unauthorized)') > -1) { const tknMessage = 'Please login to the server.'; - return [ new TektonNodeImpl(null, tknMessage, ContextType.TKN_DOWN, this, TreeItemCollapsibleState.None)] + return [new TektonNodeImpl(null, tknMessage, ContextType.TKN_DOWN, this, TreeItemCollapsibleState.None)] } if (result.error && getStderrString(result.error).indexOf('the server doesn\'t have a resource type \'pipeline\'') > -1) { const tknDownMsg = 'Please install the OpenShift Pipelines Operator.'; @@ -893,33 +979,6 @@ export class TknImpl implements Tkn { return data.map((value) => new TaskRun(taskRun, value.metadata.name, this, value)).sort(compareTimeNewestFirst); } - async getTaskRunsForPipelineRun(pipelineRun: TektonNode): Promise { - if (!pipelineRun.visibleChildren) { - pipelineRun.visibleChildren = this.defaultPageSize; - } - - const taskRuns = await this._getTaskRunsForPipelineRun(pipelineRun); - - return this.limitView(pipelineRun, taskRuns); - } - - async _getTaskRunsForPipelineRun(pipelinerun: TektonNode): Promise { - const result = await this.execute(Command.listTaskRunsForPipelineRun(pipelinerun.getName())); - if (result.error) { - console.log(result + ' Std.err when processing pipelines'); - return [new TektonNodeImpl(pipelinerun, getStderrString(result.error), ContextType.TASKRUN, this, TreeItemCollapsibleState.Expanded)]; - } - let data: PipelineTaskRunData[] = []; - try { - data = JSON.parse(result.stdout).items; - // eslint-disable-next-line no-empty - } catch (ignore) { - } - - return data - .map((value) => new TaskRun(pipelinerun, value.metadata.name, this, value)) - .sort(compareTimeNewestFirst); - } async getPipelines(pipeline: TektonNode): Promise { return this._getPipelines(pipeline); diff --git a/test/clustertask.json b/test/clustertask.json deleted file mode 100644 index ab38833e..00000000 --- a/test/clustertask.json +++ /dev/null @@ -1,2303 +0,0 @@ -[ - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "buildah", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/buildah", - "uid": "439b5b24-c02e-4a10-8358-5ecf1cd5fed1", - "resourceVersion": "78656", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:53Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "resources": [ - { - "name": "source", - "type": "git" - } - ], - "params": [ - { - "name": "BUILDER_IMAGE", - "type": "string", - "description": "The location of the buildah builder image.", - "default": "quay.io/buildah/stable:v1.11.0" - }, - { - "name": "DOCKERFILE", - "type": "string", - "description": "Path to the Dockerfile to build.", - "default": "./Dockerfile" - }, - { - "name": "TLSVERIFY", - "type": "string", - "description": "Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)", - "default": "true" - } - ] - }, - "outputs": { - "resources": [ - { - "name": "image", - "type": "image" - } - ] - }, - "steps": [ - { - "name": "build", - "image": "$(inputs.params.BUILDER_IMAGE)", - "command": [ - "buildah", - "bud", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "--layers", - "-f", - "$(inputs.params.DOCKERFILE)", - "-t", - "$(outputs.resources.image.url)", - "." - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - }, - { - "name": "push", - "image": "$(inputs.params.BUILDER_IMAGE)", - "command": [ - "buildah", - "push", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "$(outputs.resources.image.url)", - "docker://$(outputs.resources.image.url)" - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - } - ], - "volumes": [ - { - "name": "varlibcontainers", - "emptyDir": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "buildah-v0-8-0", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/buildah-v0-8-0", - "uid": "9b9b409f-d894-4805-9859-4c3842f72967", - "resourceVersion": "78657", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:53Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "resources": [ - { - "name": "source", - "type": "git" - } - ], - "params": [ - { - "name": "BUILDER_IMAGE", - "type": "string", - "description": "The location of the buildah builder image.", - "default": "quay.io/buildah/stable:v1.11.0" - }, - { - "name": "DOCKERFILE", - "type": "string", - "description": "Path to the Dockerfile to build.", - "default": "./Dockerfile" - }, - { - "name": "TLSVERIFY", - "type": "string", - "description": "Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)", - "default": "true" - } - ] - }, - "outputs": { - "resources": [ - { - "name": "image", - "type": "image" - } - ] - }, - "steps": [ - { - "name": "build", - "image": "$(inputs.params.BUILDER_IMAGE)", - "command": [ - "buildah", - "bud", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "--layers", - "-f", - "$(inputs.params.DOCKERFILE)", - "-t", - "$(outputs.resources.image.url)", - "." - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - }, - { - "name": "push", - "image": "$(inputs.params.BUILDER_IMAGE)", - "command": [ - "buildah", - "push", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "$(outputs.resources.image.url)", - "docker://$(outputs.resources.image.url)" - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - } - ], - "volumes": [ - { - "name": "varlibcontainers", - "emptyDir": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "example-cluster-task", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/example-cluster-task", - "uid": "9f432731-5492-4169-b297-bee09dc2cdbf", - "resourceVersion": "320397", - "generation": 1, - "creationTimestamp": "2020-01-21T02:18:59Z" - }, - "spec": { - "inputs": { - "params": [ - { - "name": "appName", - "type": "string" - } - ] - }, - "steps": [ - { - "name": "", - "image": "registry.redhat.io/ubi7/ubi-minimal", - "command": [ - "/bin/bash", - "-c", - "echo", - "$(inputs.params.appName)" - ], - "resources": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "openshift-client", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/openshift-client", - "uid": "67f97279-bc47-4032-95ac-f21a210255f3", - "resourceVersion": "78662", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:53Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "params": [ - { - "name": "ARGS", - "type": "array", - "description": "The OpenShift CLI arguments to run", - "default": [ - "help" - ] - } - ] - }, - "steps": [ - { - "name": "oc", - "image": "quay.io/openshift/origin-cli:latest", - "command": [ - "/usr/bin/oc" - ], - "args": [ - "$(inputs.params.ARGS)" - ], - "resources": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "openshift-client-v0-8-0", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/openshift-client-v0-8-0", - "uid": "5417e8f7-d10c-464d-b7ba-f15c92ca1e9d", - "resourceVersion": "78666", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:54Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "params": [ - { - "name": "ARGS", - "type": "array", - "description": "The OpenShift CLI arguments to run", - "default": [ - "help" - ] - } - ] - }, - "steps": [ - { - "name": "oc", - "image": "quay.io/openshift/origin-cli:latest", - "command": [ - "/usr/bin/oc" - ], - "args": [ - "$(inputs.params.ARGS)" - ], - "resources": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "s2i", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/s2i", - "uid": "9bf60e52-d308-40f8-aa26-433588319811", - "resourceVersion": "78670", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:54Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "resources": [ - { - "name": "source", - "type": "git" - } - ], - "params": [ - { - "name": "BUILDER_IMAGE", - "type": "string", - "description": "The location of the s2i builder image." - }, - { - "name": "PATH_CONTEXT", - "type": "string", - "description": "The location of the path to run s2i from.", - "default": "." - }, - { - "name": "TLSVERIFY", - "type": "string", - "description": "Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)", - "default": "true" - }, - { - "name": "LOGLEVEL", - "type": "string", - "description": "Log level when running the S2I binary", - "default": "0" - } - ] - }, - "outputs": { - "resources": [ - { - "name": "image", - "type": "image" - } - ] - }, - "steps": [ - { - "name": "generate", - "image": "quay.io/openshift-pipeline/s2i:nightly", - "command": [ - "/usr/local/bin/s2i", - "--loglevel=$(inputs.params.LOGLEVEL)", - "build", - "$(inputs.params.PATH_CONTEXT)", - "$(inputs.params.BUILDER_IMAGE)", - "--as-dockerfile", - "/gen-source/Dockerfile.gen" - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ] - }, - { - "name": "build", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "bud", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "--layers", - "-f", - "/gen-source/Dockerfile.gen", - "-t", - "$(outputs.resources.image.url)", - "." - ], - "workingDir": "/gen-source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - }, - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ], - "securityContext": { - "privileged": true - } - }, - { - "name": "push", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "push", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "$(outputs.resources.image.url)", - "docker://$(outputs.resources.image.url)" - ], - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - } - ], - "volumes": [ - { - "name": "varlibcontainers", - "emptyDir": {} - }, - { - "name": "gen-source", - "emptyDir": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "s2i-go", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/s2i-go", - "uid": "5a9b36c5-55c1-4cfe-9806-7f3218531029", - "resourceVersion": "78675", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:55Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "resources": [ - { - "name": "source", - "type": "git" - } - ], - "params": [ - { - "name": "PATH_CONTEXT", - "type": "string", - "description": "The location of the path to run s2i from.", - "default": "." - }, - { - "name": "TLSVERIFY", - "type": "string", - "description": "Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)", - "default": "true" - } - ] - }, - "outputs": { - "resources": [ - { - "name": "image", - "type": "image" - } - ] - }, - "steps": [ - { - "name": "generate", - "image": "quay.io/openshift-pipeline/s2i:v0.8.0", - "command": [ - "s2i", - "build", - "$(inputs.params.PATH_CONTEXT)", - "registry.access.redhat.com/devtools/go-toolset-rhel7", - "--as-dockerfile", - "/gen-source/Dockerfile.gen" - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ] - }, - { - "name": "build", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "bud", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "--layers", - "-f", - "/gen-source/Dockerfile.gen", - "-t", - "$(outputs.resources.image.url)", - "." - ], - "workingDir": "/gen-source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - }, - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ], - "securityContext": { - "privileged": true - } - }, - { - "name": "push", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "push", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "$(outputs.resources.image.url)", - "docker://$(outputs.resources.image.url)" - ], - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - } - ], - "volumes": [ - { - "name": "varlibcontainers", - "emptyDir": {} - }, - { - "name": "gen-source", - "emptyDir": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "s2i-go-v0-8-0", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/s2i-go-v0-8-0", - "uid": "9b4324da-bdea-4427-8136-dfa48b8d6d0c", - "resourceVersion": "78678", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:55Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "resources": [ - { - "name": "source", - "type": "git" - } - ], - "params": [ - { - "name": "PATH_CONTEXT", - "type": "string", - "description": "The location of the path to run s2i from.", - "default": "." - }, - { - "name": "TLSVERIFY", - "type": "string", - "description": "Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)", - "default": "true" - } - ] - }, - "outputs": { - "resources": [ - { - "name": "image", - "type": "image" - } - ] - }, - "steps": [ - { - "name": "generate", - "image": "quay.io/openshift-pipeline/s2i:v0.8.0", - "command": [ - "s2i", - "build", - "$(inputs.params.PATH_CONTEXT)", - "registry.access.redhat.com/devtools/go-toolset-rhel7", - "--as-dockerfile", - "/gen-source/Dockerfile.gen" - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ] - }, - { - "name": "build", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "bud", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "--layers", - "-f", - "/gen-source/Dockerfile.gen", - "-t", - "$(outputs.resources.image.url)", - "." - ], - "workingDir": "/gen-source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - }, - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ], - "securityContext": { - "privileged": true - } - }, - { - "name": "push", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "push", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "$(outputs.resources.image.url)", - "docker://$(outputs.resources.image.url)" - ], - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - } - ], - "volumes": [ - { - "name": "varlibcontainers", - "emptyDir": {} - }, - { - "name": "gen-source", - "emptyDir": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "s2i-java-11", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/s2i-java-11", - "uid": "9bcb84b1-fc11-4cf3-8f69-02c9322f0e93", - "resourceVersion": "78680", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:56Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "resources": [ - { - "name": "source", - "type": "git" - } - ], - "params": [ - { - "name": "PATH_CONTEXT", - "type": "string", - "description": "The location of the path to run s2i from", - "default": "." - }, - { - "name": "TLSVERIFY", - "type": "string", - "description": "Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)", - "default": "true" - }, - { - "name": "MAVEN_ARGS_APPEND", - "type": "string", - "description": "Additional Maven arguments", - "default": "" - }, - { - "name": "MAVEN_CLEAR_REPO", - "type": "string", - "description": "Remove the Maven repository after the artifact is built", - "default": "false" - }, - { - "name": "MAVEN_MIRROR_URL", - "type": "string", - "description": "The base URL of a mirror used for retrieving artifacts", - "default": "" - } - ] - }, - "outputs": { - "resources": [ - { - "name": "image", - "type": "image" - } - ] - }, - "steps": [ - { - "name": "gen-env-file", - "image": "quay.io/openshift-pipeline/s2i:v0.8.0", - "command": [ - "/bin/sh", - "-c" - ], - "args": [ - "echo \"MAVEN_CLEAR_REPO=$(inputs.params.MAVEN_CLEAR_REPO)\" \u003e env-file\n\n[[ '$(inputs.params.MAVEN_ARGS_APPEND)' != \"\" ]] \u0026\u0026\n echo \"MAVEN_ARGS_APPEND=$(inputs.params.MAVEN_ARGS_APPEND)\" \u003e\u003e env-file\n\n[[ '$(inputs.params.MAVEN_MIRROR_URL)' != \"\" ]] \u0026\u0026\n echo \"MAVEN_MIRROR_URL=$(inputs.params.MAVEN_MIRROR_URL)\" \u003e\u003e env-file\n\necho \"Generated Env file\"\necho \"------------------------------\"\ncat env-file\necho \"------------------------------\"" - ], - "workingDir": "/env-params", - "resources": {}, - "volumeMounts": [ - { - "name": "envparams", - "mountPath": "/env-params" - } - ] - }, - { - "name": "generate", - "image": "quay.io/openshift-pipeline/s2i", - "command": [ - "s2i", - "build", - "$(inputs.params.PATH_CONTEXT)", - "registry.access.redhat.com/openjdk/openjdk-11-rhel7", - "--image-scripts-url", - "image:///usr/local/s2i", - "--as-dockerfile", - "/gen-source/Dockerfile.gen", - "--environment-file", - "/env-params/env-file" - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "gen-source", - "mountPath": "/gen-source" - }, - { - "name": "envparams", - "mountPath": "/env-params" - } - ] - }, - { - "name": "build", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "bud", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "--layers", - "-f", - "/gen-source/Dockerfile.gen", - "-t", - "$(outputs.resources.image.url)", - "." - ], - "workingDir": "/gen-source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - }, - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ], - "securityContext": { - "privileged": true - } - }, - { - "name": "push", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "push", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "$(outputs.resources.image.url)", - "docker://$(outputs.resources.image.url)" - ], - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - } - ], - "volumes": [ - { - "name": "varlibcontainers", - "emptyDir": {} - }, - { - "name": "gen-source", - "emptyDir": {} - }, - { - "name": "envparams", - "emptyDir": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "s2i-java-11-v0-8-0", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/s2i-java-11-v0-8-0", - "uid": "e65d1bbb-52a0-4c32-aa42-0105cc916faf", - "resourceVersion": "78682", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:56Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "resources": [ - { - "name": "source", - "type": "git" - } - ], - "params": [ - { - "name": "PATH_CONTEXT", - "type": "string", - "description": "The location of the path to run s2i from", - "default": "." - }, - { - "name": "TLSVERIFY", - "type": "string", - "description": "Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)", - "default": "true" - }, - { - "name": "MAVEN_ARGS_APPEND", - "type": "string", - "description": "Additional Maven arguments", - "default": "" - }, - { - "name": "MAVEN_CLEAR_REPO", - "type": "string", - "description": "Remove the Maven repository after the artifact is built", - "default": "false" - }, - { - "name": "MAVEN_MIRROR_URL", - "type": "string", - "description": "The base URL of a mirror used for retrieving artifacts", - "default": "" - } - ] - }, - "outputs": { - "resources": [ - { - "name": "image", - "type": "image" - } - ] - }, - "steps": [ - { - "name": "gen-env-file", - "image": "quay.io/openshift-pipeline/s2i:v0.8.0", - "command": [ - "/bin/sh", - "-c" - ], - "args": [ - "echo \"MAVEN_CLEAR_REPO=$(inputs.params.MAVEN_CLEAR_REPO)\" \u003e env-file\n\n[[ '$(inputs.params.MAVEN_ARGS_APPEND)' != \"\" ]] \u0026\u0026\n echo \"MAVEN_ARGS_APPEND=$(inputs.params.MAVEN_ARGS_APPEND)\" \u003e\u003e env-file\n\n[[ '$(inputs.params.MAVEN_MIRROR_URL)' != \"\" ]] \u0026\u0026\n echo \"MAVEN_MIRROR_URL=$(inputs.params.MAVEN_MIRROR_URL)\" \u003e\u003e env-file\n\necho \"Generated Env file\"\necho \"------------------------------\"\ncat env-file\necho \"------------------------------\"" - ], - "workingDir": "/env-params", - "resources": {}, - "volumeMounts": [ - { - "name": "envparams", - "mountPath": "/env-params" - } - ] - }, - { - "name": "generate", - "image": "quay.io/openshift-pipeline/s2i", - "command": [ - "s2i", - "build", - "$(inputs.params.PATH_CONTEXT)", - "registry.access.redhat.com/openjdk/openjdk-11-rhel7", - "--image-scripts-url", - "image:///usr/local/s2i", - "--as-dockerfile", - "/gen-source/Dockerfile.gen", - "--environment-file", - "/env-params/env-file" - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "gen-source", - "mountPath": "/gen-source" - }, - { - "name": "envparams", - "mountPath": "/env-params" - } - ] - }, - { - "name": "build", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "bud", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "--layers", - "-f", - "/gen-source/Dockerfile.gen", - "-t", - "$(outputs.resources.image.url)", - "." - ], - "workingDir": "/gen-source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - }, - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ], - "securityContext": { - "privileged": true - } - }, - { - "name": "push", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "push", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "$(outputs.resources.image.url)", - "docker://$(outputs.resources.image.url)" - ], - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - } - ], - "volumes": [ - { - "name": "varlibcontainers", - "emptyDir": {} - }, - { - "name": "gen-source", - "emptyDir": {} - }, - { - "name": "envparams", - "emptyDir": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "s2i-java-8", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/s2i-java-8", - "uid": "9c745856-a38d-453b-8baa-c23e2efba838", - "resourceVersion": "78683", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:56Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "resources": [ - { - "name": "source", - "type": "git" - } - ], - "params": [ - { - "name": "PATH_CONTEXT", - "type": "string", - "description": "The location of the path to run s2i from", - "default": "." - }, - { - "name": "TLSVERIFY", - "type": "string", - "description": "Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)", - "default": "true" - }, - { - "name": "MAVEN_ARGS_APPEND", - "type": "string", - "description": "Additional Maven arguments", - "default": "" - }, - { - "name": "MAVEN_CLEAR_REPO", - "type": "string", - "description": "Remove the Maven repository after the artifact is built", - "default": "false" - }, - { - "name": "MAVEN_MIRROR_URL", - "type": "string", - "description": "The base URL of a mirror used for retrieving artifacts", - "default": "" - } - ] - }, - "outputs": { - "resources": [ - { - "name": "image", - "type": "image" - } - ] - }, - "steps": [ - { - "name": "gen-env-file", - "image": "quay.io/openshift-pipeline/s2i:v0.8.0", - "command": [ - "/bin/sh", - "-c" - ], - "args": [ - "echo \"MAVEN_CLEAR_REPO=$(inputs.params.MAVEN_CLEAR_REPO)\" \u003e env-file\n\n[[ '$(inputs.params.MAVEN_ARGS_APPEND)' != \"\" ]] \u0026\u0026\n echo \"MAVEN_ARGS_APPEND=$(inputs.params.MAVEN_ARGS_APPEND)\" \u003e\u003e env-file\n\n[[ '$(inputs.params.MAVEN_MIRROR_URL)' != \"\" ]] \u0026\u0026\n echo \"MAVEN_MIRROR_URL=$(inputs.params.MAVEN_MIRROR_URL)\" \u003e\u003e env-file\n\necho \"Generated Env file\"\necho \"------------------------------\"\ncat env-file\necho \"------------------------------\"" - ], - "workingDir": "/env-params", - "resources": {}, - "volumeMounts": [ - { - "name": "envparams", - "mountPath": "/env-params" - } - ] - }, - { - "name": "generate", - "image": "quay.io/openshift-pipeline/s2i", - "command": [ - "s2i", - "build", - "$(inputs.params.PATH_CONTEXT)", - "registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift", - "--image-scripts-url", - "image:///usr/local/s2i", - "--as-dockerfile", - "/gen-source/Dockerfile.gen", - "--environment-file", - "/env-params/env-file" - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "gen-source", - "mountPath": "/gen-source" - }, - { - "name": "envparams", - "mountPath": "/env-params" - } - ] - }, - { - "name": "build", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "bud", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "--layers", - "-f", - "/gen-source/Dockerfile.gen", - "-t", - "$(outputs.resources.image.url)", - "." - ], - "workingDir": "/gen-source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - }, - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ], - "securityContext": { - "privileged": true - } - }, - { - "name": "push", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "push", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "$(outputs.resources.image.url)", - "docker://$(outputs.resources.image.url)" - ], - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - } - ], - "volumes": [ - { - "name": "varlibcontainers", - "emptyDir": {} - }, - { - "name": "gen-source", - "emptyDir": {} - }, - { - "name": "envparams", - "emptyDir": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "s2i-java-8-v0-8-0", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/s2i-java-8-v0-8-0", - "uid": "ce0b4989-dcc9-429f-93b3-da9051a0c4e9", - "resourceVersion": "78687", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:57Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "resources": [ - { - "name": "source", - "type": "git" - } - ], - "params": [ - { - "name": "PATH_CONTEXT", - "type": "string", - "description": "The location of the path to run s2i from", - "default": "." - }, - { - "name": "TLSVERIFY", - "type": "string", - "description": "Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)", - "default": "true" - }, - { - "name": "MAVEN_ARGS_APPEND", - "type": "string", - "description": "Additional Maven arguments", - "default": "" - }, - { - "name": "MAVEN_CLEAR_REPO", - "type": "string", - "description": "Remove the Maven repository after the artifact is built", - "default": "false" - }, - { - "name": "MAVEN_MIRROR_URL", - "type": "string", - "description": "The base URL of a mirror used for retrieving artifacts", - "default": "" - } - ] - }, - "outputs": { - "resources": [ - { - "name": "image", - "type": "image" - } - ] - }, - "steps": [ - { - "name": "gen-env-file", - "image": "quay.io/openshift-pipeline/s2i:v0.8.0", - "command": [ - "/bin/sh", - "-c" - ], - "args": [ - "echo \"MAVEN_CLEAR_REPO=$(inputs.params.MAVEN_CLEAR_REPO)\" \u003e env-file\n\n[[ '$(inputs.params.MAVEN_ARGS_APPEND)' != \"\" ]] \u0026\u0026\n echo \"MAVEN_ARGS_APPEND=$(inputs.params.MAVEN_ARGS_APPEND)\" \u003e\u003e env-file\n\n[[ '$(inputs.params.MAVEN_MIRROR_URL)' != \"\" ]] \u0026\u0026\n echo \"MAVEN_MIRROR_URL=$(inputs.params.MAVEN_MIRROR_URL)\" \u003e\u003e env-file\n\necho \"Generated Env file\"\necho \"------------------------------\"\ncat env-file\necho \"------------------------------\"" - ], - "workingDir": "/env-params", - "resources": {}, - "volumeMounts": [ - { - "name": "envparams", - "mountPath": "/env-params" - } - ] - }, - { - "name": "generate", - "image": "quay.io/openshift-pipeline/s2i", - "command": [ - "s2i", - "build", - "$(inputs.params.PATH_CONTEXT)", - "registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift", - "--image-scripts-url", - "image:///usr/local/s2i", - "--as-dockerfile", - "/gen-source/Dockerfile.gen", - "--environment-file", - "/env-params/env-file" - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "gen-source", - "mountPath": "/gen-source" - }, - { - "name": "envparams", - "mountPath": "/env-params" - } - ] - }, - { - "name": "build", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "bud", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "--layers", - "-f", - "/gen-source/Dockerfile.gen", - "-t", - "$(outputs.resources.image.url)", - "." - ], - "workingDir": "/gen-source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - }, - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ], - "securityContext": { - "privileged": true - } - }, - { - "name": "push", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "push", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "$(outputs.resources.image.url)", - "docker://$(outputs.resources.image.url)" - ], - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - } - ], - "volumes": [ - { - "name": "varlibcontainers", - "emptyDir": {} - }, - { - "name": "gen-source", - "emptyDir": {} - }, - { - "name": "envparams", - "emptyDir": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "s2i-nodejs", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/s2i-nodejs", - "uid": "4f74140b-a7df-486b-9ac5-ffa363f3c31e", - "resourceVersion": "78689", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:57Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "resources": [ - { - "name": "source", - "type": "git" - } - ], - "params": [ - { - "name": "VERSION", - "type": "string", - "description": "The version of the nodejs", - "default": "8" - }, - { - "name": "PATH_CONTEXT", - "type": "string", - "description": "The location of the path to run s2i from.", - "default": "." - }, - { - "name": "TLSVERIFY", - "type": "string", - "description": "Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)", - "default": "true" - } - ] - }, - "outputs": { - "resources": [ - { - "name": "image", - "type": "image" - } - ] - }, - "steps": [ - { - "name": "generate", - "image": "quay.io/openshift-pipeline/s2i:v0.8.0", - "command": [ - "s2i", - "build", - "$(inputs.params.PATH_CONTEXT)", - "registry.access.redhat.com/rhscl/nodejs-$(inputs.params.VERSION)-rhel7", - "--as-dockerfile", - "/gen-source/Dockerfile.gen" - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ] - }, - { - "name": "build", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "bud", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "--layers", - "-f", - "/gen-source/Dockerfile.gen", - "-t", - "$(outputs.resources.image.url)", - "." - ], - "workingDir": "/gen-source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - }, - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ], - "securityContext": { - "privileged": true - } - }, - { - "name": "push", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "push", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "$(outputs.resources.image.url)", - "docker://$(outputs.resources.image.url)" - ], - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - } - ], - "volumes": [ - { - "name": "varlibcontainers", - "emptyDir": {} - }, - { - "name": "gen-source", - "emptyDir": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "s2i-nodejs-v0-8-0", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/s2i-nodejs-v0-8-0", - "uid": "60cead5e-4acf-46e3-8334-859ab3a8530d", - "resourceVersion": "78693", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:58Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "resources": [ - { - "name": "source", - "type": "git" - } - ], - "params": [ - { - "name": "VERSION", - "type": "string", - "description": "The version of the nodejs", - "default": "8" - }, - { - "name": "PATH_CONTEXT", - "type": "string", - "description": "The location of the path to run s2i from.", - "default": "." - }, - { - "name": "TLSVERIFY", - "type": "string", - "description": "Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)", - "default": "true" - } - ] - }, - "outputs": { - "resources": [ - { - "name": "image", - "type": "image" - } - ] - }, - "steps": [ - { - "name": "generate", - "image": "quay.io/openshift-pipeline/s2i:v0.8.0", - "command": [ - "s2i", - "build", - "$(inputs.params.PATH_CONTEXT)", - "registry.access.redhat.com/rhscl/nodejs-$(inputs.params.VERSION)-rhel7", - "--as-dockerfile", - "/gen-source/Dockerfile.gen" - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ] - }, - { - "name": "build", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "bud", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "--layers", - "-f", - "/gen-source/Dockerfile.gen", - "-t", - "$(outputs.resources.image.url)", - "." - ], - "workingDir": "/gen-source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - }, - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ], - "securityContext": { - "privileged": true - } - }, - { - "name": "push", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "push", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "$(outputs.resources.image.url)", - "docker://$(outputs.resources.image.url)" - ], - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - } - ], - "volumes": [ - { - "name": "varlibcontainers", - "emptyDir": {} - }, - { - "name": "gen-source", - "emptyDir": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "s2i-python-3", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/s2i-python-3", - "uid": "34a0225d-e0fc-40df-8f96-80673b08bded", - "resourceVersion": "78697", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:58Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "resources": [ - { - "name": "source", - "type": "git" - } - ], - "params": [ - { - "name": "MINOR_VERSION", - "type": "string", - "description": "The minor version of the python 3", - "default": "6" - }, - { - "name": "PATH_CONTEXT", - "type": "string", - "description": "The location of the path to run s2i from.", - "default": "." - }, - { - "name": "TLSVERIFY", - "type": "string", - "description": "Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)", - "default": "true" - } - ] - }, - "outputs": { - "resources": [ - { - "name": "image", - "type": "image" - } - ] - }, - "steps": [ - { - "name": "generate", - "image": "quay.io/openshift-pipeline/s2i:v0.8.0", - "command": [ - "s2i", - "build", - "$(inputs.params.PATH_CONTEXT)", - "registry.access.redhat.com/rhscl/python-3$(inputs.params.MINOR_VERSION)-rhel7", - "--as-dockerfile", - "/gen-source/Dockerfile.gen" - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ] - }, - { - "name": "build", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "bud", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "--layers", - "-f", - "/gen-source/Dockerfile.gen", - "-t", - "$(outputs.resources.image.url)", - "." - ], - "workingDir": "/gen-source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - }, - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ], - "securityContext": { - "privileged": true - } - }, - { - "name": "push", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "push", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "$(outputs.resources.image.url)", - "docker://$(outputs.resources.image.url)" - ], - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - } - ], - "volumes": [ - { - "name": "varlibcontainers", - "emptyDir": {} - }, - { - "name": "gen-source", - "emptyDir": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "s2i-python-3-v0-8-0", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/s2i-python-3-v0-8-0", - "uid": "b23af17b-c770-43b6-af42-87afe5d4a846", - "resourceVersion": "78698", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:58Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "resources": [ - { - "name": "source", - "type": "git" - } - ], - "params": [ - { - "name": "MINOR_VERSION", - "type": "string", - "description": "The minor version of the python 3", - "default": "6" - }, - { - "name": "PATH_CONTEXT", - "type": "string", - "description": "The location of the path to run s2i from.", - "default": "." - }, - { - "name": "TLSVERIFY", - "type": "string", - "description": "Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)", - "default": "true" - } - ] - }, - "outputs": { - "resources": [ - { - "name": "image", - "type": "image" - } - ] - }, - "steps": [ - { - "name": "generate", - "image": "quay.io/openshift-pipeline/s2i:v0.8.0", - "command": [ - "s2i", - "build", - "$(inputs.params.PATH_CONTEXT)", - "registry.access.redhat.com/rhscl/python-3$(inputs.params.MINOR_VERSION)-rhel7", - "--as-dockerfile", - "/gen-source/Dockerfile.gen" - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ] - }, - { - "name": "build", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "bud", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "--layers", - "-f", - "/gen-source/Dockerfile.gen", - "-t", - "$(outputs.resources.image.url)", - "." - ], - "workingDir": "/gen-source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - }, - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ], - "securityContext": { - "privileged": true - } - }, - { - "name": "push", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "push", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "$(outputs.resources.image.url)", - "docker://$(outputs.resources.image.url)" - ], - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - } - ], - "volumes": [ - { - "name": "varlibcontainers", - "emptyDir": {} - }, - { - "name": "gen-source", - "emptyDir": {} - } - ] - } - }, - { - "kind": "ClusterTask", - "apiVersion": "tekton.dev/v1alpha1", - "metadata": { - "name": "s2i-v0-8-0", - "selfLink": "/apis/tekton.dev/v1alpha1/clustertasks/s2i-v0-8-0", - "uid": "db57f332-ab01-4380-a208-b27e05eaee6d", - "resourceVersion": "78671", - "generation": 1, - "creationTimestamp": "2020-01-20T17:39:54Z", - "annotations": { - "manifestival": "new" - }, - "ownerReferences": [ - { - "apiVersion": "operator.tekton.dev/v1alpha1", - "kind": "Config", - "name": "cluster", - "uid": "e595c575-4148-42b5-8d8b-44ee77f92d4c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "inputs": { - "resources": [ - { - "name": "source", - "type": "git" - } - ], - "params": [ - { - "name": "BUILDER_IMAGE", - "type": "string", - "description": "The location of the s2i builder image." - }, - { - "name": "PATH_CONTEXT", - "type": "string", - "description": "The location of the path to run s2i from.", - "default": "." - }, - { - "name": "TLSVERIFY", - "type": "string", - "description": "Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)", - "default": "true" - }, - { - "name": "LOGLEVEL", - "type": "string", - "description": "Log level when running the S2I binary", - "default": "0" - } - ] - }, - "outputs": { - "resources": [ - { - "name": "image", - "type": "image" - } - ] - }, - "steps": [ - { - "name": "generate", - "image": "quay.io/openshift-pipeline/s2i:nightly", - "command": [ - "/usr/local/bin/s2i", - "--loglevel=$(inputs.params.LOGLEVEL)", - "build", - "$(inputs.params.PATH_CONTEXT)", - "$(inputs.params.BUILDER_IMAGE)", - "--as-dockerfile", - "/gen-source/Dockerfile.gen" - ], - "workingDir": "/workspace/source", - "resources": {}, - "volumeMounts": [ - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ] - }, - { - "name": "build", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "bud", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "--layers", - "-f", - "/gen-source/Dockerfile.gen", - "-t", - "$(outputs.resources.image.url)", - "." - ], - "workingDir": "/gen-source", - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - }, - { - "name": "gen-source", - "mountPath": "/gen-source" - } - ], - "securityContext": { - "privileged": true - } - }, - { - "name": "push", - "image": "quay.io/buildah/stable", - "command": [ - "buildah", - "push", - "--tls-verify=$(inputs.params.TLSVERIFY)", - "$(outputs.resources.image.url)", - "docker://$(outputs.resources.image.url)" - ], - "resources": {}, - "volumeMounts": [ - { - "name": "varlibcontainers", - "mountPath": "/var/lib/containers" - } - ], - "securityContext": { - "privileged": true - } - } - ], - "volumes": [ - { - "name": "varlibcontainers", - "emptyDir": {} - }, - { - "name": "gen-source", - "emptyDir": {} - } - ] - } - } -] diff --git a/test/extension.test.ts b/test/extension.test.ts index 26c0091d..3587a499 100644 --- a/test/extension.test.ts +++ b/test/extension.test.ts @@ -55,7 +55,6 @@ suite('Tekton Pipeline Extension', () => { sandbox.stub(TknImpl.prototype, '_getTasks').resolves([taskItem]); sandbox.stub(TknImpl.prototype, '_getClusterTasks').resolves([clustertaskItem]); sandbox.stub(TknImpl.prototype, '_getPipelineRuns').resolves([pipelinerunItem]); - sandbox.stub(TknImpl.prototype, '_getTaskRunsForPipelineRun').resolves([taskrunItem]); }); teardown(() => { @@ -106,12 +105,6 @@ suite('Tekton Pipeline Extension', () => { expect(pipelinerun.length).is.equals(1); }); - test('should load taskruns from pipelinerun folder', async () => { - sandbox.stub(TknImpl.prototype, 'execute').resolves({ error: undefined, stdout: '' }); - const taskrun = await tkn.getTaskRunsForPipelineRun(pipelinerunItem); - expect(taskrun.length).is.equals(1); - }); - test('should register all extension commands declared commands in package descriptor', async () => { return await vscode.commands.getCommands(true).then((commands) => { packagejson.contributes.commands.forEach(value => { diff --git a/test/pipelinerun.json b/test/pipelinerun.json new file mode 100644 index 00000000..1d958a9d --- /dev/null +++ b/test/pipelinerun.json @@ -0,0 +1,172 @@ +{ + "apiVersion": "tekton.dev/v1beta1", + "kind": "PipelineRun", + "metadata": { + "creationTimestamp": "2020-05-07T14:39:15Z", + "generation": 1, + "labels": { + "tekton.dev/pipeline": "conditional-pipeline" + }, + "name": "condtional-pr", + "namespace": "default", + "resourceVersion": "393173", + "selfLink": "/apis/tekton.dev/v1beta1/namespaces/default/pipelineruns/condtional-pr", + "uid": "92c53583-bbd9-4cc0-a191-04530ae21648" + }, + "spec": { + "pipelineRef": { + "name": "conditional-pipeline" + }, + "resources": [ + { + "name": "source-repo", + "resourceRef": { + "name": "pipeline-git" + } + } + ], + "serviceAccountName": "default", + "timeout": "1h0m0s" + }, + "status": { + "completionTime": "2020-05-07T14:43:15Z", + "conditions": [ + { + "lastTransitionTime": "2020-05-07T14:43:15Z", + "message": "Tasks Completed: 2, Skipped: 0", + "reason": "Succeeded", + "status": "True", + "type": "Succeeded" + } + ], + "startTime": "2020-05-07T14:39:15Z", + "taskRuns": { + "condtional-pr-first-create-file-x2cvl": { + "pipelineTaskName": "first-create-file", + "status": { + "completionTime": "2020-05-07T14:41:04Z", + "conditions": [ + { + "lastTransitionTime": "2020-05-07T14:41:04Z", + "message": "All Steps have completed executing", + "reason": "Succeeded", + "status": "True", + "type": "Succeeded" + } + ], + "podName": "condtional-pr-first-create-file-x2cvl-pod-2b7qt", + "startTime": "2020-05-07T14:39:15Z", + "steps": [ + { + "container": "step-write-new-stuff", + "imageID": "docker.io/library/ubuntu@sha256:5747316366b8cc9e3021cd7286f42b2d6d81e3d743e2ab571f55bcd5df788cc8", + "name": "write-new-stuff", + "terminated": { + "containerID": "cri-o://5dfd667521d20c91150a82e0971c9cbfd5c35a721e2b94bc8ea27cd91a421ada", + "exitCode": 0, + "finishedAt": "2020-05-07T14:41:03Z", + "reason": "Completed", + "startedAt": "2020-05-07T14:41:03Z" + } + }, + { + "container": "step-source-copy-pipeline-git-7szw9", + "imageID": "registry.access.redhat.com/ubi8/ubi-minimal@sha256:326c94ab44d1472a30d47c49c2f896df687184830fc66a66de00c416885125b0", + "name": "source-copy-pipeline-git-7szw9", + "terminated": { + "containerID": "cri-o://825bbdedd15e596b109843deb3e104eb29f446be02c0ab79b7bc48d3215b6ad1", + "exitCode": 0, + "finishedAt": "2020-05-07T14:41:04Z", + "reason": "Completed", + "startedAt": "2020-05-07T14:41:04Z" + } + }, + { + "container": "step-source-mkdir-pipeline-git-pvtn7", + "imageID": "registry.access.redhat.com/ubi8/ubi-minimal@sha256:326c94ab44d1472a30d47c49c2f896df687184830fc66a66de00c416885125b0", + "name": "source-mkdir-pipeline-git-pvtn7", + "terminated": { + "containerID": "cri-o://321366c33b0d38bfe52016cd6700457acda2469f3f0f88ccc7c1c09ffc3bafcf", + "exitCode": 0, + "finishedAt": "2020-05-07T14:41:03Z", + "reason": "Completed", + "startedAt": "2020-05-07T14:41:03Z" + } + }, + { + "container": "step-create-dir-workspace-m9tcg", + "imageID": "registry.access.redhat.com/ubi8/ubi-minimal@sha256:326c94ab44d1472a30d47c49c2f896df687184830fc66a66de00c416885125b0", + "name": "create-dir-workspace-m9tcg", + "terminated": { + "containerID": "cri-o://8f92eb5eb14742dddd80731c792214954698ff6390364162409a3077b26a3a18", + "exitCode": 0, + "finishedAt": "2020-05-07T14:41:02Z", + "reason": "Completed", + "startedAt": "2020-05-07T14:41:02Z" + } + } + ] + } + }, + "condtional-pr-then-check-mr5dp": { + "conditionChecks": { + "condtional-pr-then-check-mr5dp-file-exists-bhxgl": { + "conditionName": "file-exists", + "status": { + "check": { + "terminated": { + "containerID": "cri-o://24de1fa5e10ed936e478d0b415016c63d8cd7eef4b50bf1c9d46a8abc951cb8f", + "exitCode": 0, + "finishedAt": "2020-05-07T14:42:53Z", + "reason": "Completed", + "startedAt": "2020-05-07T14:42:53Z" + } + }, + "completionTime": "2020-05-07T14:42:54Z", + "conditions": [ + { + "lastTransitionTime": "2020-05-07T14:42:54Z", + "message": "All Steps have completed executing", + "reason": "Succeeded", + "status": "True", + "type": "Succeeded" + } + ], + "podName": "condtional-pr-then-check-mr5dp-file-exists-bhxgl-pod-75n9f", + "startTime": "2020-05-07T14:41:04Z" + } + } + }, + "pipelineTaskName": "then-check", + "status": { + "completionTime": "2020-05-07T14:43:15Z", + "conditions": [ + { + "lastTransitionTime": "2020-05-07T14:43:15Z", + "message": "All Steps have completed executing", + "reason": "Succeeded", + "status": "True", + "type": "Succeeded" + } + ], + "podName": "condtional-pr-then-check-mr5dp-pod-7nj9v", + "startTime": "2020-05-07T14:42:54Z", + "steps": [ + { + "container": "step-echo", + "imageID": "docker.io/library/ubuntu@sha256:5747316366b8cc9e3021cd7286f42b2d6d81e3d743e2ab571f55bcd5df788cc8", + "name": "echo", + "terminated": { + "containerID": "cri-o://133f1e5a347e7012c49cd78c25918545da3e9797310aaf043b245c877220bee5", + "exitCode": 0, + "finishedAt": "2020-05-07T14:43:14Z", + "reason": "Completed", + "startedAt": "2020-05-07T14:43:14Z" + } + } + ] + } + } + } + } +} diff --git a/test/tekton/taskrun.test.ts b/test/tekton/taskrun.test.ts index 6039914f..e055910c 100644 --- a/test/tekton/taskrun.test.ts +++ b/test/tekton/taskrun.test.ts @@ -21,7 +21,6 @@ chai.use(sinonChai); suite('Tekton/TaskRun', () => { const sandbox = sinon.createSandbox(); let execStub: sinon.SinonStub; - let getTaskRunsStub: sinon.SinonStub; let getPipelineRunNamesStub: sinon.SinonStub; const pipelineItem = new TestItem(null, 'pipeline', ContextType.PIPELINE); const pipelinerunItem = new TestItem(pipelineItem, 'pipelinerun', ContextType.PIPELINERUN, undefined, '2019-07-25T12:03:00Z', 'True'); @@ -29,7 +28,6 @@ suite('Tekton/TaskRun', () => { setup(() => { execStub = sandbox.stub(TknImpl.prototype, 'execute').resolves({ error: null, stdout: '', stderr: '' }); - sandbox.stub(TknImpl.prototype, 'getTaskRunsForPipelineRun').resolves([taskrunItem]); getPipelineRunNamesStub = sandbox.stub(TektonItem, 'getPipelinerunNames').resolves([pipelinerunItem]); sandbox.stub(vscode.window, 'showInputBox').resolves(); }); @@ -82,10 +80,6 @@ suite('Tekton/TaskRun', () => { suite('listFromTasks command', () => { const taskItem = new TestItem(null, 'task', ContextType.TASK); - setup(() => { - getTaskRunsStub = sandbox.stub(TektonItem, 'getTaskRunNames').resolves([taskrunItem]); - }); - suite('called from \'Tekton Pipelines Explorer\'', () => { test('executes the listFromTasks tkn command in terminal', async () => { @@ -98,7 +92,6 @@ suite('Tekton/TaskRun', () => { suite('called from command palette', () => { test('calls the appropriate error message when no project found', async () => { - getTaskRunsStub.restore(); sandbox.stub(TknImpl.prototype, 'getTaskRunsForTasks').resolves([]); try { await TaskRun.listFromTask(null); diff --git a/test/tekton/tektonitem.test.ts b/test/tekton/tektonitem.test.ts index eb2aec57..8e43e49d 100644 --- a/test/tekton/tektonitem.test.ts +++ b/test/tekton/tektonitem.test.ts @@ -149,27 +149,6 @@ suite('TektonItem', () => { }); }); - suite('getTaskrunNames', () => { - - test('returns an array of taskrun names for the pipelinerun if there is at least one task', async () => { - sandbox.stub(TknImpl.prototype, 'getTaskRunsForPipelineRun').resolves([taskrunItem]); - const taskrunNames = await TektonItem.getTaskRunNames(pipelinerunItem); - expect(taskrunNames[0].getName()).equals('taskrun'); - - }); - - test('throws error if there are no taskruns available', async () => { - sandbox.stub(TknImpl.prototype, 'getTaskRunsForPipelineRun').resolves([]); - try { - await TektonItem.getTaskRunNames(pipelinerunItem); - } catch (err) { - expect(err.message).equals('You need at least one TaskRun available. Please create new Tekton TaskRun and try again.'); - return; - } - fail('should throw error in case tasks array is empty'); - }); - }); - suite('getClustertaskNames', () => { test('returns an array of clustertask names for the task if there is at least one task', async () => { diff --git a/test/tkn.test.ts b/test/tkn.test.ts index 8792a83c..ed0a318c 100644 --- a/test/tkn.test.ts +++ b/test/tkn.test.ts @@ -13,12 +13,13 @@ import * as sinonChai from 'sinon-chai'; import * as assert from 'assert'; import { ToolsConfig } from '../src/tools'; import { WindowUtil } from '../src/util/windowUtils'; -import { Terminal } from 'vscode'; +import { Terminal, TreeItemCollapsibleState } from 'vscode'; import { TestItem } from './tekton/testTektonitem'; import { ExecException } from 'child_process'; import * as path from 'path'; import { TektonNode } from '../src/tkn'; import { StartObject, Resources, Params } from '../src/tekton/pipelinecontent'; +import { PipelineRunData } from '../src/tekton'; const expect = chai.expect; chai.use(sinonChai); @@ -106,7 +107,6 @@ suite('tkn', () => { toolsStub = sandbox.stub(ToolsConfig, 'detectOrDownload').resolves(path.join('segment1', 'segment2')); const ctStub = sandbox.stub(WindowUtil, 'createTerminal').returns(termFake); await tknCli.executeInTerminal(createCliCommand('tkn')); - // tslint:disable-next-line: no-unused-expression expect(termFake.show).calledOnce; expect(ctStub).calledWith('Tekton', process.cwd(), 'segment1'); }); @@ -130,7 +130,7 @@ suite('tkn', () => { const triggerTemplatesItem = new TestItem(tkn.TknImpl.ROOT, 'triggertemplates', tkn.ContextType.TRIGGERTEMPLATES); const triggerBindingItem = new TestItem(tkn.TknImpl.ROOT, 'triggerbinding', tkn.ContextType.TRIGGERBINDING); const eventListenerItem = new TestItem(tkn.TknImpl.ROOT, 'eventlistener', tkn.ContextType.EVENTLISTENER); - const conditionItem = new TestItem(tkn.TknImpl.ROOT, 'condition', tkn.ContextType.CONDITIONS ); + const conditionItem = new TestItem(tkn.TknImpl.ROOT, 'condition', tkn.ContextType.CONDITIONS); const pipelineRunNodeItem = new TestItem(tkn.TknImpl.ROOT, 'PipelineRun', tkn.ContextType.PIPELINERUNNODE); const taskRunNodeItem = new TestItem(tkn.TknImpl.ROOT, 'TaskRun', tkn.ContextType.TASKRUNNODE); @@ -858,136 +858,6 @@ suite('tkn', () => { expect(result).empty; }); - test('getTaskRun returns taskrun list for a pipelinerun', async () => { - execStub.resolves({ - error: null, stdout: JSON.stringify({ - 'items': [ - { - 'kind': 'TaskRun', - 'apiVersion': 'tekton.dev/v1alpha1', - 'metadata': { - 'creationTimestamp': '2019-07-25T12:03:01Z', - 'name': 'taskrun1', - 'ownerReferences': [{ - 'kind': 'PipelineRun', - 'name': 'pipelinerun1' - }], - 'labels': { - 'tekton.dev/pipelineRun': 'pipelinerun1' - } - - }, - 'status': { - 'conditions': [ - { - 'status': 'True', - } - ], - 'startTime': '2019-07-25T12:03:01Z', - } - }, - { - 'kind': 'TaskRun', - 'apiVersion': 'tekton.dev/v1alpha1', - 'metadata': { - 'creationTimestamp': '2019-07-25T12:03:00Z', - 'name': 'taskrun2', - 'ownerReferences': [{ - 'kind': 'PipelineRun', - 'name': 'pipelinerun1' - }], - 'labels': { - 'tekton.dev/pipelineRun': 'pipelinerun1' - } - }, - 'status': { - 'conditions': [ - { - 'status': 'True', - } - ], - 'startTime': '2019-07-25T12:03:00Z', - } - }] - }) - }); - const result = await tknCli.getTaskRunsForPipelineRun(pipelinerunItem); - - expect(result.length).equals(2); - expect(result[0].getName()).equals('taskrun1'); - }); - - test('getTaskruns returns taskruns for a pipelinerun', async () => { - const tknTaskRuns = ['taskrun1', 'taskrun2']; - execStub.resolves({ - error: null, stdout: JSON.stringify({ - 'items': [ - { - 'kind': 'TaskRun', - 'apiVersion': 'tekton.dev/v1alpha1', - 'metadata': { - 'creationTimestamp': '2019-07-25T12:03:01Z', - 'name': 'taskrun1', - 'ownerReferences': [{ - 'kind': 'PipelineRun', - 'name': 'pipelinerun1' - }], - 'labels': { - 'tekton.dev/pipelineRun': 'pipelinerun1' - } - }, - 'status': { - 'conditions': [ - { - 'status': 'True', - } - ], - 'startTime': '2019-07-25T12:03:01Z', - } - }, - { - 'kind': 'TaskRun', - 'apiVersion': 'tekton.dev/v1alpha1', - 'metadata': { - 'creationTimestamp': '2019-07-25T12:03:00Z', - 'name': 'taskrun2', - 'ownerReferences': [{ - 'kind': 'PipelineRun', - 'name': 'pipelinerun1' - }], - 'labels': { - 'tekton.dev/pipelineRun': 'pipelinerun1' - } - }, - 'status': { - 'conditions': [ - { - 'status': 'True', - } - ], - 'startTime': '2019-07-25T12:03:00Z', - } - }] - }) - }); - const result = await tknCli.getTaskRunsForPipelineRun(pipelinerunItem); - expect(execStub).calledWith(tkn.Command.listTaskRunsForPipelineRun(pipelinerunItem.getName())); - expect(result.length).equals(2); - for (let i = 0; i < result.length; i++) { - expect(result[i].getName()).equals(tknTaskRuns[i]); - } - }); - - test('getTaskRunsForPipelineRun returns an empty list if an error occurs', async () => { - sandbox.stub(tkn.TknImpl.prototype, 'getTaskRunsForPipelineRun').resolves([]); - execStub.onFirstCall().resolves({ error: undefined, stdout: '' }); - execStub.onSecondCall().rejects(errorMessage); - const result = await tknCli.getTaskRunsForPipelineRun(pipelinerunItem); - - // tslint:disable-next-line: no-unused-expression - expect(result).empty; - }); - test('getTaskRunFromTasks returns taskrun list for a task', async () => { execStub.resolves({ error: null, stdout: JSON.stringify({ @@ -1244,31 +1114,6 @@ suite('tkn', () => { } }); - test('getPipelineRunChildren returns taskruns for an pipelinerun', async () => { - sandbox.stub(tkn.TknImpl.prototype, 'getTaskRunsForPipelineRun').resolves([taskrunItem]); - execStub.onFirstCall().resolves({ - error: undefined, stdout: JSON.stringify({ - items: [ - { - metadata: { - name: 'taskrun1', - }, - spec: { - pipelineRef: { - name: 'pipeline1', - } - } - - } - ] - }) - }); - execStub.onSecondCall().resolves({ error: undefined, stdout: 'serv' }); - //TODO: Probably need a get children here - const result = await tknCli.getTaskRunsForPipelineRun(pipelinerunItem); - - expect(result[0].getName()).deep.equals('taskrun1'); - }); test('getRawClusterTasks returns items from tkn task list command', async () => { const tknTasks = ['clustertask1', 'clustertask2']; @@ -1348,7 +1193,7 @@ suite('tkn', () => { }); }); - suite('mode node', () => { + suite('more node', () => { const pipelineNodeItem = new TestItem(tkn.TknImpl.ROOT, 'pipelinenode', tkn.ContextType.PIPELINENODE); const pipelineItem = new TestItem(pipelineNodeItem, 'pipeline1', tkn.ContextType.PIPELINE); @@ -1374,4 +1219,36 @@ suite('tkn', () => { assert.equal(more.description, '4 from 10'); }); }); + + suite('PipelineRun node', () => { + const pipelineItem = new TestItem(null, 'pipeline', tkn.ContextType.PIPELINE); + + test('PipelineRun should use pipelinerun JSON to create TaskRun nodes', () => { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const json = require(path.join('..', '..', 'test', 'pipelinerun.json')) as PipelineRunData; + const pipelineRun = new tkn.PipelineRun(pipelineItem, json.metadata.name, undefined, json, TreeItemCollapsibleState.Expanded); + + expect(pipelineRun.label).equal('condtional-pr'); + const children = pipelineRun.getChildren(); + expect(children).to.have.lengthOf(2); + expect(children[0].name).eq('then-check'); + expect(children[1].name).eq('first-create-file'); + }); + + test('TaskRun should contains condition run node', () => { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const json = require(path.join('..', '..', 'test', 'pipelinerun.json')) as PipelineRunData; + const pipelineRun = new tkn.PipelineRun(pipelineItem, json.metadata.name, undefined, json, TreeItemCollapsibleState.Expanded); + + expect(pipelineRun.label).equal('condtional-pr'); + const children = pipelineRun.getChildren() as tkn.TektonNodeImpl[]; + expect(children).to.have.lengthOf(2); + expect(children[0].name).eq('then-check'); + + const conditionRun = children[0].getChildren() as tkn.TektonNodeImpl[]; + expect(conditionRun).not.undefined; + expect(conditionRun).to.have.lengthOf(1); + expect(conditionRun[0].name).eq('file-exists'); + }); + }); });