@@ -4,30 +4,41 @@ const { sendHttpRequest } = require('./helper');
4
4
const filesize = require ( 'filesize' ) ;
5
5
const moment = require ( 'moment' ) ;
6
6
const Image = require ( '../entities/Image' ) ;
7
+ const DEFAULTS = require ( '../../interface/cli/defaults' ) ;
7
8
8
9
9
- const _extractFieldsForImageEntity = ( image , tag ) => ( {
10
- name : image . imageDisplayName ,
11
- tag : tag . tag ,
12
- image_id : image . internalImageId . substring ( 0 , 12 ) ,
13
- created : moment ( tag . created ) . fromNow ( ) ,
14
- size : filesize ( image . size ) ,
15
- pull : `${ tag . registry } /${ tag . repository } :${ tag . tag } ` ,
16
- } ) ;
10
+ const _extractFieldsForImageEntity = ( image , tag ) => {
11
+ const newImage = {
12
+ name : image . imageDisplayName ,
13
+ size : filesize ( image . size ) ,
14
+ } ;
15
+ newImage . image_id = image . internalImageId ? image . internalImageId . substring ( 0 , 12 ) : '' ;
16
+ if ( _ . isEqual ( tag , '<none>' ) ) {
17
+ newImage . tag = tag ;
18
+ newImage . pull = '' ;
19
+ newImage . created = moment ( image . created )
20
+ . fromNow ( ) ;
21
+ } else {
22
+ newImage . tag = tag . tag ;
23
+ newImage . pull = `${ tag . registry } /${ tag . repository } :${ tag . tag } ` ;
24
+ newImage . created = moment ( tag . created )
25
+ . fromNow ( ) ;
26
+ }
27
+ return newImage ;
28
+ } ;
17
29
18
30
19
31
const getAll = async ( options ) => {
20
32
const qs = {
21
33
limit : options . limit ,
22
- offset : 0 ,
34
+ offset : options . offset ,
23
35
metadata : options . labels ,
36
+ type : options . type ,
37
+ branch : options . branch ,
38
+ imageDisplayNameRegex : options . imageName ,
24
39
select : 'internalName tags internalImageId created size imageDisplayName' ,
25
40
} ;
26
41
27
- if ( ! options . volumeImages ) {
28
- qs . metadata . cf_volume = false ;
29
- }
30
-
31
42
if ( options . sha ) {
32
43
qs . sha = options . sha ;
33
44
}
@@ -43,14 +54,22 @@ const getAll = async (options) => {
43
54
}
44
55
const res = [ ] ;
45
56
_ . forEach ( images . docs , ( image ) => {
57
+ let addedCfCrTag = false ;
46
58
_ . forEach ( image . tags , ( tag ) => {
47
59
// in case we are filtering by registries, ignore the image if it is not from the registires list
48
- if ( options . filterRegistries && options . filterRegistries . indexOf ( tag . registry ) === - 1 ) {
60
+ if ( ( options . filterRegistries && options . filterRegistries . indexOf ( tag . registry ) === - 1 ) || _ . isEqual ( tag . tag , 'volume' ) ) {
49
61
return ;
50
62
}
63
+ if ( DEFAULTS . CODEFRESH_REGISTRIES . indexOf ( tag . registry ) !== - 1 ) {
64
+ addedCfCrTag = true ;
65
+ }
51
66
const data = _extractFieldsForImageEntity ( image , tag ) ;
52
67
res . push ( new Image ( data ) ) ;
53
68
} ) ;
69
+ if ( _ . isEmpty ( image . tags ) || ! addedCfCrTag ) {
70
+ const data = _extractFieldsForImageEntity ( image , '<none>' ) ;
71
+ res . push ( new Image ( data ) ) ;
72
+ }
54
73
} ) ;
55
74
return res ;
56
75
} ;
0 commit comments