Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 'kubectl' to list taskrun for pipeline #281

Merged
merged 1 commit into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
vscode.commands.registerCommand('tekton.eventlistener.delete', (context) => execute(EventListener.delete, context)),
vscode.commands.registerCommand('tekton.clustertask.list', (context) => execute(ClusterTask.list, context)),
vscode.commands.registerCommand('tekton.clustertask.delete', (context) => execute(ClusterTask.delete, context)),
vscode.commands.registerCommand('tekton.taskrun.list', (context) => execute(TaskRun.list, context)),
vscode.commands.registerCommand('tekton.taskrun.list', (context) => execute(TaskRun.listFromPipelineRun, context)),
vscode.commands.registerCommand('tekton.taskrun.listFromTask', (context) => execute(TaskRun.listFromTask, context)),
vscode.commands.registerCommand('tekton.taskrun.logs', (context) => execute(TaskRun.logs, context)),
vscode.commands.registerCommand('tekton.taskrun.followLogs', (context) => execute(TaskRun.followLogs, context)),
Expand Down
6 changes: 4 additions & 2 deletions src/tekton/taskrun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import { Progress } from '../util/progress';

export class TaskRun extends TektonItem {

static async list(taskRun: TektonNode): Promise<void> {
if (taskRun) { TaskRun.tkn.executeInTerminal(Command.listTaskRunsInTerminal()); }
static async listFromPipelineRun(pipelineRun: TektonNode): Promise<void> {
if (pipelineRun) {
TaskRun.tkn.executeInTerminal(Command.listTaskRunsForPipelineRunInTerminal(pipelineRun.getName()));
}
}

static async listFromTask(taskRun: TektonNode): Promise<void> {
Expand Down
10 changes: 3 additions & 7 deletions src/tkn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,19 +278,15 @@ export class Command {
static listTasksInTerminal(namespace?: string): CliCommand {
return newTknCommand('task', 'list', ...(namespace ? ['-n', namespace] : ''), '-o', 'json');
}
@verbose
static listTaskRuns(namespace?: string): CliCommand {
return newTknCommand('taskrun', 'list', ...(namespace ? ['-n', namespace] : ''), '-o', 'json');
}

static listTaskRunsForPipelineRun(pipelineRunName: string): CliCommand {
return newK8sCommand('get', 'taskrun', '-l', `tekton.dev/pipelineRun=${pipelineRunName}`, '-o', 'json');
}

@verbose
static listTaskRunsInTerminal(namespace?: string): CliCommand {
return newTknCommand('taskrun', 'list', ...(namespace ? ['-n', namespace] : ''));
static listTaskRunsForPipelineRunInTerminal(pipelineRunName: string): CliCommand {
return newK8sCommand('get', 'taskrun', '-l', `tekton.dev/pipelineRun=${pipelineRunName}`);
}

@verbose
static deleteTask(name: string): CliCommand {
return newTknCommand('task', 'delete', name, '-f');
Expand Down
8 changes: 4 additions & 4 deletions test/tekton/taskrun.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ suite('Tekton/TaskRun', () => {
suite('called from \'Tekton Pipelines Explorer\'', () => {

test('executes the list tkn command in terminal', async () => {
await TaskRun.list(taskrunItem);
expect(termStub).calledOnceWith(Command.listTaskRunsInTerminal());
await TaskRun.listFromPipelineRun(taskrunItem);
expect(termStub).calledOnceWith(Command.listTaskRunsForPipelineRunInTerminal(taskrunItem.getName()));
});

});
Expand All @@ -59,7 +59,7 @@ suite('Tekton/TaskRun', () => {
test('calls the appropriate error message when no project found', async () => {
getPipelineRunNamesStub.restore();
try {
await TaskRun.list(null);
await TaskRun.listFromPipelineRun(null);
} catch (err) {
expect(err.message).equals('You need at least one Pipeline available. Please create new Tekton Pipeline and try again.');
return;
Expand All @@ -70,7 +70,7 @@ suite('Tekton/TaskRun', () => {
suite('called from command bar', () => {

test('skips tkn command execution if canceled by user', async () => {
await TaskRun.list(null);
await TaskRun.listFromPipelineRun(null);
// tslint:disable-next-line: no-unused-expression
expect(termStub).not.called;
});
Expand Down