|
1 |
| -const debug = require('debug')('codefresh:cli:create:trigger'); |
| 1 | +require('debug')('codefresh:cli:create:trigger'); |
| 2 | + |
2 | 3 | const Command = require('../../Command');
|
3 | 4 | const { trigger } = require('../../../../logic').api;
|
4 |
| -const createRoot = require('../root/create.cmd'); |
5 | 5 |
|
6 | 6 | const command = new Command({
|
7 |
| - command: 'trigger <event-uri> <pipeline> [pipelines...]', |
8 |
| - aliases: ['t'], |
9 |
| - parent: createRoot, |
10 |
| - description: 'Set pipeline(s) trigger: connect the `trigger-event` to the pipeline(s). *Note:* `trigger-event` exists only if there is at least one connected pipeline.', |
| 7 | + root: true, |
| 8 | + command: 'link <event-uri> <pipeline> [pipelines...]', |
| 9 | + description: 'Define new trigger(s): link pipeline(s) to the specified `trigger-event`', |
11 | 10 | webDocs: {
|
12 | 11 | category: 'Triggers',
|
13 |
| - title: 'Set Pipeline Trigger', |
| 12 | + title: 'Define Pipeline Trigger', |
14 | 13 | },
|
15 | 14 | builder: (yargs) => {
|
16 |
| - return yargs |
| 15 | + yargs |
17 | 16 | .positional('event-uri', {
|
18 | 17 | describe: '`trigger-event` URI (as defined by trigger `type[/kind]`)',
|
19 | 18 | require: true,
|
20 | 19 | })
|
21 | 20 | .positional('pipeline', {
|
22 | 21 | describe: 'pipeline(s) to be triggered by the specified `trigger-event`',
|
23 | 22 | require: true,
|
24 |
| - }); |
| 23 | + }) |
| 24 | + .example('codefresh link registry:dockerhub:codefresh:fortune:push 5a439664af73ad0001f3ece0', 'Setup trigger by linking 5a43... pipeline to the DockerHub `codefresh/fortune` `push` event'); |
25 | 25 | },
|
26 | 26 | handler: async (argv) => {
|
27 | 27 | /* eslint-disable prefer-destructuring */
|
28 | 28 | const pipelines = [].concat(argv.pipeline).concat(argv.pipelines);
|
29 |
| - const eventURI = argv['event-uri']; |
| 29 | + const event = argv['event-uri']; |
30 | 30 | /* eslint-enable prefer-destructuring */
|
31 |
| - await trigger.addPipelineTrigger(eventURI, pipelines); |
32 |
| - console.log(`Trigger : ${eventURI} was successfully added to the pipeline(s): ${pipelines}`); |
| 31 | + await trigger.linkPipelinesToEvent(event, pipelines); |
| 32 | + console.log(`Trigger: ${event} was successfully linked to the pipeline(s): ${pipelines}`); |
33 | 33 | },
|
34 | 34 | });
|
35 | 35 |
|
|
0 commit comments