From 89d9bcd894fe720ca022ec316bb791740612d842 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 5 Mar 2014 16:27:56 -0500 Subject: [PATCH] - Make sure to send the subdirectory when restarting a build - Make sure to use the subdirectory to read the Dockerfile's location in a build package, and display the path - Nicer UI for showing the trigger description in the build view - Fix an NPE in the file change tree --- endpoints/api.py | 7 ++++-- static/css/quay.css | 16 ++++++++++++++ static/directives/trigger-description.html | 2 +- static/js/app.js | 3 ++- static/js/controllers.js | 25 ++++++++++++++++++++-- static/js/graphing.js | 3 ++- static/partials/build-package.html | 1 + static/partials/repo-build.html | 2 +- 8 files changed, 51 insertions(+), 8 deletions(-) diff --git a/endpoints/api.py b/endpoints/api.py index 0a4700a22..c77fffbac 100644 --- a/endpoints/api.py +++ b/endpoints/api.py @@ -1239,7 +1239,10 @@ def request_repo_build(namespace, repository): permission = ModifyRepositoryPermission(namespace, repository) if permission.can(): logger.debug('User requested repository initialization.') - dockerfile_id = request.get_json()['file_id'] + request_json = request.get_json() + + dockerfile_id = request_json['file_id'] + subdir = request_json['subdirectory'] if 'subdirectory' in request_json else '' # Check if the dockerfile resource has already been used. If so, then it # can only be reused if the user has access to the repository for which it @@ -1255,7 +1258,7 @@ def request_repo_build(namespace, repository): display_name = user_files.get_file_checksum(dockerfile_id) build_request = start_build(repo, dockerfile_id, ['latest'], display_name, - '', True) + subdir, True) resp = jsonify(build_status_view(build_request, True)) repo_string = '%s/%s' % (namespace, repository) diff --git a/static/css/quay.css b/static/css/quay.css index 3ddf44b50..636343e4b 100644 --- a/static/css/quay.css +++ b/static/css/quay.css @@ -9,7 +9,23 @@ } } +.dockerfile-path { + margin-top: 10px; + padding: 20px; + padding-bottom: 0px; + font-family: Consolas, "Lucida Console", Monaco, monospace; + font-size: 14px; +} + +.dockerfile-path:before { + content: "\f15b"; + font-family: FontAwesome; + margin-right: 8px; + font-size: 18px; +} + .dockerfile-view { + margin-top: 10px; margin: 20px; padding: 20px; background: #F7F6F6; diff --git a/static/directives/trigger-description.html b/static/directives/trigger-description.html index 7cb1a5731..2a081aa69 100644 --- a/static/directives/trigger-description.html +++ b/static/directives/trigger-description.html @@ -9,7 +9,7 @@ -
+
Dockerfile: //Dockerfile diff --git a/static/js/app.js b/static/js/app.js index affa12fdb..d82bb27a1 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -2672,7 +2672,8 @@ quayApp.directive('triggerDescription', function () { transclude: false, restrict: 'C', scope: { - 'trigger': '=trigger' + 'trigger': '=trigger', + 'short': '=short' }, controller: function($scope, $element) { } diff --git a/static/js/controllers.js b/static/js/controllers.js index d9ba93c2d..168b622b5 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -818,9 +818,23 @@ function BuildPackageCtrl($scope, Restangular, ApiService, $routeParams, $rootSc // itself (should) be the Dockerfile. if (zipFiles && Object.keys(zipFiles).length) { // Load the dockerfile contents. - var dockerfile = zip.file('Dockerfile'); + var dockerfilePath = 'Dockerfile'; + if ($scope.repobuild['job_config']) { + var dockerfileFolder = ($scope.repobuild['job_config']['build_subdir'] || ''); + if (dockerfileFolder[0] == '/') { + dockerfileFolder = dockerfileFolder.substr(1); + } + if (dockerfileFolder[dockerfileFolder.length - 1] == '/') { + dockerfileFolder = dockerfileFolder.substr(0, dockerfileFolder.length - 1); + } + + dockerfilePath = dockerfileFolder + 'Dockerfile'; + } + + var dockerfile = zip.file(dockerfilePath); if (dockerfile) { $scope.dockerFileContents = dockerfile.asText(); + $scope.dockerFilePath = dockerfilePath; } // Build the zip file tree. @@ -835,6 +849,7 @@ function BuildPackageCtrl($scope, Restangular, ApiService, $routeParams, $rootSc }); } else { $scope.dockerFileContents = response; + $scope.dockerFilePath = 'Dockerfile'; } $scope.loaded = true; @@ -953,8 +968,14 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope $scope.restartBuild = function(build) { $('#confirmRestartBuildModal').modal('hide'); + var subdirectory = ''; + if (build['job_config']) { + subdirectory = build['job_config']['build_subdir'] || ''; + } + var data = { - 'file_id': build['resource_key'] + 'file_id': build['resource_key'], + 'subdirectory': subdirectory }; var params = { diff --git a/static/js/graphing.js b/static/js/graphing.js index b796fd8a4..b4db1a78f 100644 --- a/static/js/graphing.js +++ b/static/js/graphing.js @@ -851,7 +851,8 @@ function FileTreeBase() { * Calculates the dimensions of the tree. */ FileTreeBase.prototype.calculateDimensions_ = function(container) { - var cw = document.getElementById(container).clientWidth; + var containerElm = document.getElementById(container); + var cw = containerElm ? containerElm.clientWidth : 1200; var barHeight = 20; var ch = (this.getNodesHeight() * barHeight) + 40; diff --git a/static/partials/build-package.html b/static/partials/build-package.html index 182fd9c58..5ca4dfd13 100644 --- a/static/partials/build-package.html +++ b/static/partials/build-package.html @@ -37,6 +37,7 @@
+
{{ dockerFilePath }}
No Dockerfile found in the build pack
diff --git a/static/partials/repo-build.html b/static/partials/repo-build.html index 252396007..5ecef369f 100644 --- a/static/partials/repo-build.html +++ b/static/partials/repo-build.html @@ -40,7 +40,7 @@
- Triggered by: + Triggered by: