Skip to content

Commit

Permalink
Add 'hub.tekton.dev/catalog' label to task yaml while installing it f…
Browse files Browse the repository at this point in the history
…rom TektonHub (#494)
  • Loading branch information
sudhirverma authored Jan 27, 2021
1 parent 37178b5 commit fec0756
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/hub/install-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export interface HubTaskInstallation {
tknVersion?: string;
minPipelinesVersion?: string;
asClusterTask: boolean;
taskVersion?: string;
}
2 changes: 1 addition & 1 deletion src/hub/install-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function doInstallTask(task: HubTaskInstallation): void {
}
}
}
const result = await tkn.execute(Command.updateYaml(task.url));
const result = await tkn.execute(Command.hubInstall(task.name, task.taskVersion));
if (result.error){
vscode.window.showWarningMessage(`Task installation failed: ${getStderrString(result.error)}`);
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/tkn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ export class Command {
static updateYaml(fsPath: string): CliCommand {
return newK8sCommand('apply', '-f', fsPath);
}
static hubInstall(name: string, version: string): CliCommand {
return newTknCommand('hub', 'install', 'task', name, '--version', version);
}
static listTaskRun(): CliCommand {
return newK8sCommand('get', 'taskrun', '-o', 'json');
}
Expand Down
3 changes: 2 additions & 1 deletion src/webview/hub/task-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ export class TaskItem extends BaseWidget {
url: this.task.latestVersion.rawURL,
name: this.task.name,
minPipelinesVersion: this.task.latestVersion.minPipelinesVersion,
tknVersion: this.tknVersion
tknVersion: this.tknVersion,
taskVersion: this.task.latestVersion.version
} as HubTaskInstallation});
}

Expand Down
3 changes: 2 additions & 1 deletion src/webview/task-page/task-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ export class TaskWidget extends BaseWidget {
name: this.task.name,
minPipelinesVersion: this.currentVersion.minPipelinesVersion,
tknVersion: this.tknVersion,
asClusterTask: asCluster
asClusterTask: asCluster,
taskVersion: this.currentVersion.version
} as HubTaskInstallation});
}

Expand Down
5 changes: 3 additions & 2 deletions test/hub/install-task.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ suite('Install Task', () => {
await installTask({
name: 'foo',
url: 'https://some/path/task.yaml',
asClusterTask: false
asClusterTask: false,
taskVersion: '1.0'
});

expect(executeStub).calledOnceWith(Command.updateYaml('https://some/path/task.yaml'));
expect(executeStub).calledOnceWith(Command.hubInstall('foo', '1.0'));
expect(showInformationMessageStub).calledOnceWith('Task foo installed.');
});

Expand Down

0 comments on commit fec0756

Please sign in to comment.