Merge pull request #2379 from coreos-inc/fix-build-form

Fix Dockerfile Build Form
This commit is contained in:
josephschorr 2017-02-22 20:42:15 -05:00 committed by GitHub
commit 6436444274
2 changed files with 32 additions and 6 deletions

View file

@ -27,10 +27,10 @@ angular.module('quay').directive('dockerfileBuildForm', function () {
$scope.state = 'checking-image'; $scope.state = 'checking-image';
ApiService.getRepo(null, params).then(function(repository) { ApiService.getRepo(null, params).then(function(repository) {
$scope.privateBaseRepository = repository.is_public ? null : baseImage; $scope.privateBaseRepository = repository.is_public ? null : baseImage;
$scope.state = 'awaiting-bot'; $scope.state = repository.is_public ? 'ready' : 'awaiting-bot';
}, function() { }, function() {
$scope.privateBaseRepository = baseImage; $scope.privateBaseRepository = null;
$scope.state = 'awaiting-bot'; $scope.state = 'ready';
}); });
}; };

View file

@ -12,20 +12,46 @@ angular.module('quay').factory('DockerfileService', ['DataFileService', 'Config'
DockerfileInfo.prototype.getRegistryBaseImage = function() { DockerfileInfo.prototype.getRegistryBaseImage = function() {
var baseImage = this.getBaseImage(); var baseImage = this.getBaseImage();
if (!baseImage) { if (!baseImage) {
return; return null;
} }
if (baseImage.indexOf(Config.getDomain() + '/') != 0) { if (baseImage.indexOf(Config.getDomain() + '/') != 0) {
return; return null;
} }
return baseImage.substring(Config.getDomain().length + 1); return baseImage.substring(Config.getDomain().length + 1);
}; };
DockerfileInfo.prototype.getBaseImage = function() { DockerfileInfo.prototype.getBaseImage = function() {
var imageAndTag = this.getBaseImageAndTag();
if (!imageAndTag) {
return null;
}
// Note, we have to handle a few different cases here:
// 1) someimage
// 2) someimage:tag
// 3) host:port/someimage
// 4) host:port/someimage:tag
var lastIndex = imageAndTag.lastIndexOf(':');
if (lastIndex < 0) {
return imageAndTag;
}
// Otherwise, check if there is a / in the portion after the split point. If so,
// then the latter is part of the path (and not a tag).
var afterColon = imageAndTag.substring(lastIndex + 1);
if (afterColon.indexOf('/') >= 0) {
return imageAndTag;
}
return imageAndTag.substring(0, lastIndex);
};
DockerfileInfo.prototype.getBaseImageAndTag = function() {
var fromIndex = this.contents.indexOf('FROM '); var fromIndex = this.contents.indexOf('FROM ');
if (fromIndex < 0) { if (fromIndex < 0) {
return; return null;
} }
var newline = this.contents.indexOf('\n', fromIndex); var newline = this.contents.indexOf('\n', fromIndex);