Skip to content

Commit 60745d1

Browse files
itai-codefreshziv-codefresh
authored andcommitted
Fix wrong parameter passing to logic of images. Refactor tag names to be a positional (#88)
1 parent 852824c commit 60745d1

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/interface/cli/commands/image/tag.cmd.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,29 @@ const { image } = require('../../../../logic').api;
77

88
const tag = new Command({
99
root: true,
10-
command: 'tag <id>',
10+
command: 'tag <id> [tags..]',
1111
description: 'Add an image tag',
1212
builder: (yargs) => {
1313
yargs
14-
.option('tag', {
15-
describe: 'image tags',
16-
type: 'array',
17-
require: true,
14+
.positional('id', {
15+
description: 'Docker image id',
16+
})
17+
.positional('names', {
18+
description: 'Tag names',
1819
});
1920

2021
return yargs;
2122
},
2223
handler: async (argv) => {
2324
const imageId = argv.id;
24-
const tags = _.isArray(argv.tag) ? argv.tag : [argv.tag];
25+
const tags = argv.tags;
2526
for (let i = 0; i < tags.length; i += 1) {
2627
const tag = tags[i];
2728
await image.addImageTag({
2829
imageId,
2930
tag,
3031
});
31-
console.log(`tag: ${tag} successfully added to image ${imageId}`);
32+
console.log(`Tag: ${tag} was added successfully to image: ${imageId}`);
3233
}
3334
},
3435
});

lib/logic/api/image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const annotateImage = async (dockerImageId, annotations) => {
136136
};
137137

138138
const addImageTag = async (options) => {
139-
const image = await getImageById(options.imageId);
139+
const image = await getImageById({ imageId: options.imageId });
140140
const imageId = image[0].info._id;
141141
const RequestOptions = {
142142
url: `/api/images/${encodeURIComponent(imageId)}/tag/${options.tag}`,

0 commit comments

Comments
 (0)