Merge pull request #2379 from coreos-inc/fix-build-form
Fix Dockerfile Build Form
This commit is contained in:
commit
6436444274
2 changed files with 32 additions and 6 deletions
|
@ -27,10 +27,10 @@ angular.module('quay').directive('dockerfileBuildForm', function () {
|
|||
$scope.state = 'checking-image';
|
||||
ApiService.getRepo(null, params).then(function(repository) {
|
||||
$scope.privateBaseRepository = repository.is_public ? null : baseImage;
|
||||
$scope.state = 'awaiting-bot';
|
||||
$scope.state = repository.is_public ? 'ready' : 'awaiting-bot';
|
||||
}, function() {
|
||||
$scope.privateBaseRepository = baseImage;
|
||||
$scope.state = 'awaiting-bot';
|
||||
$scope.privateBaseRepository = null;
|
||||
$scope.state = 'ready';
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -12,20 +12,46 @@ angular.module('quay').factory('DockerfileService', ['DataFileService', 'Config'
|
|||
DockerfileInfo.prototype.getRegistryBaseImage = function() {
|
||||
var baseImage = this.getBaseImage();
|
||||
if (!baseImage) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (baseImage.indexOf(Config.getDomain() + '/') != 0) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
return baseImage.substring(Config.getDomain().length + 1);
|
||||
};
|
||||
|
||||
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 ');
|
||||
if (fromIndex < 0) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
var newline = this.contents.indexOf('\n', fromIndex);
|
||||
|
|
Reference in a new issue