@@ -20,60 +20,60 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
<material-button waves-center =" true" rounded =" true" waves-color =" #ddd" onClick =" { toTaglist }" >
21
21
<i class =" material-icons" >arrow_back</i >
22
22
</material-button >
23
- <h2 >
24
- History of { props .image }:{ props .tag } <i class =" material-icons" >history</i >
25
- </h2 >
23
+ <h2 >History of { props .image }:{ props .tag } <i class =" material-icons" >history</i ></h2 >
26
24
</div >
27
25
</material-card >
28
26
<div if =" { ! state .loadend }" class =" spinner-wrapper" >
29
- <material-spinner / >
27
+ <material-spinner ></ material-spinner >
30
28
</div >
31
29
32
- <material-tabs if =" { state .archs && state .loadend }" useLine =" { true }" tabs =" { state .archs }"
33
- onTabChanged =" { onTabChanged }" />
30
+ <material-tabs
31
+ if =" { state .archs && state .loadend }"
32
+ useLine =" { true }"
33
+ tabs =" { state .archs }"
34
+ onTabChanged =" { onTabChanged }"
35
+ ></material-tabs >
34
36
35
37
<material-card each =" { element in state .elements }" class =" tag-history-element" >
36
- <tag-history-element each =" { entry in element }" if =" { entry .value && entry .value .length > 0 }" entry =" { entry }" />
38
+ <tag-history-element
39
+ each =" { entry in element }"
40
+ if =" { entry .value && entry .value .length > 0 }"
41
+ entry =" { entry }"
42
+ ></tag-history-element >
37
43
</material-card >
38
44
<script >
39
- import {
40
- DockerImage
41
- } from ' ../../scripts/docker-image' ;
42
- import {
43
- bytesToSize
44
- } from ' ../../scripts/utils' ;
45
+ import { DockerImage } from ' ../../scripts/docker-image' ;
46
+ import { bytesToSize } from ' ../../scripts/utils' ;
45
47
import router from ' ../../scripts/router' ;
46
- import TagHistoryElement from ' ./tag-history-element.riot'
48
+ import TagHistoryElement from ' ./tag-history-element.riot' ;
47
49
export default {
48
50
components: {
49
- TagHistoryElement
51
+ TagHistoryElement,
50
52
},
51
53
onBeforeMount (props , state ) {
52
54
state .elements = [];
53
55
state .image = new DockerImage (props .image , props .tag , {
54
56
list: true ,
55
57
registryUrl: props .registryUrl ,
56
58
onNotify: props .onNotify ,
57
- onAuthentication: props .onAuthentication
59
+ onAuthentication: props .onAuthentication ,
58
60
});
59
- state .image .fillInfo ()
61
+ state .image .fillInfo ();
60
62
},
61
63
onMounted (props , state ) {
62
64
state .image .on (' blobs' , this .processBlobs );
63
65
state .image .on (' list' , this .multiArchList );
64
66
},
65
67
onTabChanged (arch , idx ) {
66
68
const state = this .state ;
67
- const {
68
- registryUrl ,
69
- onNotify
70
- } = this .props ;
71
- state .elements = []
72
- state .image .variants [idx] = state .image .variants [idx] ||
69
+ const { registryUrl , onNotify } = this .props ;
70
+ state .elements = [];
71
+ state .image .variants [idx] =
72
+ state .image .variants [idx] ||
73
73
new DockerImage (this .props .image , arch .digest , {
74
74
list: false ,
75
75
registryUrl,
76
- onNotify
76
+ onNotify,
77
77
});
78
78
if (state .image .variants [idx].blobs ) {
79
79
return this .processBlobs (state .image .variants [idx].blobs );
@@ -83,48 +83,52 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
83
83
},
84
84
processBlobs (blobs ) {
85
85
const state = this .state ;
86
+ const { historyCustomLabels } = this .props ;
86
87
87
88
function exec (elt ) {
88
89
const guiElements = [];
89
90
for (var attribute in elt) {
90
91
if (elt .hasOwnProperty (attribute) && attribute != ' empty_layer' ) {
91
92
const value = elt[attribute];
92
93
const guiElement = {
93
- " key" : attribute,
94
- " value" : modifySpecificAttributeTypes (attribute, value)
94
+ ' key' : attribute,
95
+ ' value' : modifySpecificAttributeTypes (attribute, value),
95
96
};
96
97
guiElements .push (guiElement);
97
98
}
98
99
}
99
100
return guiElements .sort (eltSort);
100
101
}
101
102
const elements = new Array (blobs .history .length + 1 );
102
- elements[0 ] = exec (getConfig (blobs));
103
+ elements[0 ] = exec (getConfig (blobs, { historyCustomLabels } ));
103
104
blobs .history .forEach (function (elt , i ) {
104
- elements[blobs .history .length - i] = exec (elt)
105
+ elements[blobs .history .length - i] = exec (elt);
105
106
});
106
107
this .update ({
107
108
elements,
108
- loadend: true
109
+ loadend: true ,
109
110
});
110
111
},
111
112
multiArchList (manifests ) {
112
113
manifests = manifests .manifests || manifests;
113
114
const archs = manifests .map (function (manifest ) {
114
115
return {
115
- title: manifest .platform .os + ' /' + manifest .platform .architecture + (manifest .platform .variant ?
116
- manifest .platform .variant : ' ' ),
117
- digest: manifest .digest
118
- }
116
+ title:
117
+ manifest .platform .os +
118
+ ' /' +
119
+ manifest .platform .architecture +
120
+ (manifest .platform .variant ? manifest .platform .variant : ' ' ),
121
+ digest: manifest .digest ,
122
+ };
119
123
});
120
124
this .update ({
121
- archs
125
+ archs,
122
126
});
123
127
},
124
128
toTaglist () {
125
129
router .taglist (this .props .image );
126
- }
127
- }
130
+ },
131
+ };
128
132
const eltIdx = function (e ) {
129
133
switch (e) {
130
134
case ' created' :
@@ -158,7 +162,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
158
162
return new Date (value).toLocaleString ();
159
163
case ' created_by' :
160
164
const cmd = value .match (/ \/ bin\/ sh * -c * #\( nop\) * ([A-Z ] + )/ );
161
- return (cmd && cmd[1 ]) || ' RUN'
165
+ return (cmd && cmd[1 ]) || ' RUN' ;
162
166
case ' size' :
163
167
return bytesToSize (value);
164
168
case ' Entrypoint' :
@@ -175,26 +179,47 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
175
179
return value || ' ' ;
176
180
};
177
181
178
- const getConfig = function (blobs ) {
179
- const res = [' architecture' , ' User' , ' created' , ' docker_version' , ' os' , ' Cmd' , ' Entrypoint' , ' Env' , ' Labels' ,
180
- ' User' , ' Volumes' , ' WorkingDir' , ' author' , ' id' , ' ExposedPorts'
181
- ]
182
- .reduce (function (acc , e ) {
183
- const value = blobs[e] || blobs .config [e];
184
- if (value && e === ' architecture' && blobs .variant ) {
185
- acc[e] = value + blobs .variant ;
186
- } else if (value) {
187
- acc[e] = value;
188
- }
189
- return acc;
190
- }, {});
182
+ const getConfig = function (blobs , { historyCustomLabels }) {
183
+ console .log (this );
184
+ const res = [
185
+ ' architecture' ,
186
+ ' User' ,
187
+ ' created' ,
188
+ ' docker_version' ,
189
+ ' os' ,
190
+ ' Cmd' ,
191
+ ' Entrypoint' ,
192
+ ' Env' ,
193
+ ' Labels' ,
194
+ ' User' ,
195
+ ' Volumes' ,
196
+ ' WorkingDir' ,
197
+ ' author' ,
198
+ ' id' ,
199
+ ' ExposedPorts' ,
200
+ ].reduce (function (acc , e ) {
201
+ const value = blobs[e] || blobs .config [e];
202
+ if (value && e === ' architecture' && blobs .variant ) {
203
+ acc[e] = value + blobs .variant ;
204
+ } else if (value) {
205
+ acc[e] = value;
206
+ }
207
+ return acc;
208
+ }, {});
191
209
192
- if (! res .author && ( res .Labels && res .Labels .maintainer ) ) {
210
+ if (! res .author && res .Labels && res .Labels .maintainer ) {
193
211
res .author = blobs .config .Labels .maintainer ;
194
212
delete res .Labels .maintainer ;
195
213
}
196
214
215
+ historyCustomLabels
216
+ .filter ((label ) => res .Labels [label])
217
+ .forEach ((label ) => {
218
+ res[` custom-label-${ label} ` ] = res .Labels [label];
219
+ delete res .Labels [label];
220
+ });
221
+
197
222
return res;
198
223
};
199
224
</script >
200
- </tag-history >
225
+ </tag-history >
0 commit comments