Cleanup display of image commands to be better shared
Also moves the work into a TS component
This commit is contained in:
parent
7f436bb54a
commit
1d60414a23
10 changed files with 41 additions and 51 deletions
|
@ -1,28 +1,8 @@
|
|||
/**
|
||||
* Helper service for returning information extracted from repository image metadata.
|
||||
*/
|
||||
angular.module('quay').factory('ImageMetadataService', ['UtilService', function(UtilService) {
|
||||
angular.module('quay').factory('ImageMetadataService', [function() {
|
||||
var metadataService = {};
|
||||
metadataService.getFormattedCommand = function(image) {
|
||||
if (!image || !image.command || !image.command.length) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var getCommandStr = function(command) {
|
||||
// Handle /bin/sh commands specially.
|
||||
if (command.length > 2 && command[0] == '/bin/sh' && command[1] == '-c') {
|
||||
return command[2];
|
||||
}
|
||||
|
||||
return command.join(' ');
|
||||
};
|
||||
|
||||
return getCommandStr(image.command);
|
||||
};
|
||||
|
||||
metadataService.getEscapedFormattedCommand = function(image) {
|
||||
return UtilService.textToSafeHtml(metadataService.getFormattedCommand(image));
|
||||
};
|
||||
|
||||
metadataService.getImageCommand = function(image, imageId) {
|
||||
if (!image) {
|
||||
|
@ -44,22 +24,7 @@ angular.module('quay').factory('ImageMetadataService', ['UtilService', function(
|
|||
return null;
|
||||
}
|
||||
|
||||
return metadataService.getDockerfileCommand(found.command);
|
||||
};
|
||||
|
||||
metadataService.getDockerfileCommand = function(command) {
|
||||
if (!command) { return ''; }
|
||||
command = command.join(' ').split(' ');
|
||||
|
||||
// ["/bin/sh", "-c", "#(nop)", "RUN", "foo"]
|
||||
if (command[0] != '/bin/sh' || command[1] != '-c') { return ''; }
|
||||
|
||||
var commandPrefix = '#(nop)';
|
||||
if (command[2] != commandPrefix) {
|
||||
return 'RUN ' + command.slice(2).join(' ');
|
||||
}
|
||||
|
||||
return command.slice(3).join(' ');
|
||||
return found.command;
|
||||
};
|
||||
|
||||
return metadataService;
|
||||
|
|
Reference in a new issue