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
|
@ -0,0 +1,5 @@
|
|||
<div class="image-command-element">
|
||||
<div class="nondocker-command" ng-if="!$ctrl.getDockerfileCommand($ctrl.command)">{{ ::$ctrl.command.join(' ') }}</div>
|
||||
<dockerfile-command command="::$ctrl.getDockerfileCommand($ctrl.command)"
|
||||
ng-if="$ctrl.getDockerfileCommand($ctrl.command)"></dockerfile-command>
|
||||
</div>
|
|
@ -0,0 +1,26 @@
|
|||
import { Input, Component, Inject } from 'ng-metadata/core';
|
||||
|
||||
/**
|
||||
* A component which displays an image's command, nicely formatted.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'image-command',
|
||||
templateUrl: '/static/js/directives/ui/image-command/image-command.component.html',
|
||||
})
|
||||
export class ImageCommandComponent {
|
||||
@Input('<') public command: string;
|
||||
|
||||
private getDockerfileCommand(command: string[]): string {
|
||||
if (!command || !command.length) { return ''; }
|
||||
command = command.join(' ').split(' ');
|
||||
|
||||
// ["/bin/sh", "-c", "#(nop)", "RUN", "foo"]
|
||||
if (command[0] != '/bin/sh' || command[1] != '-c') { return ''; }
|
||||
|
||||
if (command[2].trim() != '#(nop)') {
|
||||
return 'RUN ' + command.slice(2).join(' ');
|
||||
}
|
||||
|
||||
return command.slice(3).join(' ');
|
||||
};
|
||||
}
|
|
@ -13,7 +13,7 @@ angular.module('quay').directive('imageFeatureView', function () {
|
|||
'image': '=image',
|
||||
'isEnabled': '=isEnabled'
|
||||
},
|
||||
controller: function($scope, $element, Config, ApiService, VulnerabilityService, ViewArray, ImageMetadataService, TableService) {
|
||||
controller: function($scope, $element, Config, ApiService, VulnerabilityService, ViewArray, TableService) {
|
||||
$scope.options = {
|
||||
'filter': null,
|
||||
'predicate': 'fixableScore',
|
||||
|
|
|
@ -13,9 +13,7 @@ angular.module('quay').directive('imageViewLayer', function () {
|
|||
'image': '=image',
|
||||
'images': '=images'
|
||||
},
|
||||
controller: function($scope, $element, ImageMetadataService) {
|
||||
$scope.getDockerfileCommand = ImageMetadataService.getDockerfileCommand;
|
||||
|
||||
controller: function($scope, $element) {
|
||||
$scope.getClass = function() {
|
||||
var index = $.inArray($scope.image, $scope.images);
|
||||
if (index < 0) {
|
||||
|
|
|
@ -13,7 +13,7 @@ angular.module('quay').directive('imageVulnerabilityView', function () {
|
|||
'image': '=image',
|
||||
'isEnabled': '=isEnabled'
|
||||
},
|
||||
controller: function($scope, $element, $routeParams, Config, ApiService, VulnerabilityService, ViewArray, ImageMetadataService, TableService) {
|
||||
controller: function($scope, $element, $routeParams, Config, ApiService, VulnerabilityService, ViewArray, TableService) {
|
||||
$scope.options = {
|
||||
'filter': null,
|
||||
'fixableVulns': $routeParams['fixable'] == 'true',
|
||||
|
|
Reference in a new issue