Skip to content

Commit 7753189

Browse files
ziv-codefreshitai-codefresh
authored andcommitted
add id output option (#151)
1 parent c6de50d commit 7753189

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

lib/interface/cli/commands/root/get.cmd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const get = new Command({
2020
.option('output', {
2121
describe: 'Output format',
2222
alias: 'o',
23-
choices: ['json', 'yaml', 'wide', 'name'],
23+
choices: ['json', 'yaml', 'wide', 'name', 'id'],
2424
group: 'Output Options',
2525
})
2626
.option('watch', {

lib/interface/cli/helpers/get.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ const specifyOutputForArray = (type, enitities) => {
9898
break;
9999
case 'name':
100100
_.forEach(enitities, (entity) => {
101-
print(entity.toName());
101+
console.log(entity.toName());
102+
});
103+
break;
104+
case 'id':
105+
_.forEach(enitities, (entity) => {
106+
console.log(entity.toId());
102107
});
103108
break;
104109
case 'wide':

lib/logic/api/image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const _extractFieldsForImageEntity = (image, tag) => {
1515
annotations: _.get(image, 'metadata', {}),
1616
tagId: tag._id,
1717
};
18-
newImage.image_id = image.internalImageId ? image.internalImageId.substring(0, 12) : '\b';
18+
newImage.id = image.internalImageId ? image.internalImageId.substring(0, 12) : '\b';
1919
if (_.isEqual(tag, '<none>')) {
2020
newImage.tag = tag;
2121
newImage.pull = '';

lib/logic/entities/Entity.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ class Entity {
2828
return `${this.entityType}/${this.info.name}`;
2929
}
3030

31+
toId() {
32+
return `${this.info.id}`;
33+
}
34+
3135
extractValues(columns) {
3236
const values = {};
3337
columns.forEach((key) => {

lib/logic/entities/Image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Image extends Entity {
55
super();
66
this.entityType = 'image';
77
this.info = data;
8-
this.defaultColumns = ['image_id', 'name', 'tag', 'created', 'size', 'pull'];
8+
this.defaultColumns = ['id', 'name', 'tag', 'created', 'size', 'pull'];
99
this.wideColumns = this.defaultColumns.concat([]);
1010
}
1111
}

0 commit comments

Comments
 (0)