refactoring to promises
This commit is contained in:
parent
390e389027
commit
85441c8459
9 changed files with 191 additions and 28 deletions
|
@ -39,25 +39,48 @@ angular.module('quay').directive('dockerfileBuildForm', function () {
|
|||
$scope.state = 'checking';
|
||||
$scope.selectedFiles = files;
|
||||
|
||||
DockerfileService.getDockerfile(files[0], function(df) {
|
||||
var baseImage = df.getRegistryBaseImage();
|
||||
if (baseImage) {
|
||||
checkPrivateImage(baseImage);
|
||||
} else {
|
||||
$scope.state = 'ready';
|
||||
}
|
||||
// FIXME: Remove this
|
||||
// DockerfileService.getDockerfile(files[0], function(df) {
|
||||
// var baseImage = df.getRegistryBaseImage();
|
||||
// if (baseImage) {
|
||||
// checkPrivateImage(baseImage);
|
||||
// } else {
|
||||
// $scope.state = 'ready';
|
||||
// }
|
||||
//
|
||||
// $scope.$apply(function() {
|
||||
// opt_callback && opt_callback(true, 'Dockerfile found and valid')
|
||||
// });
|
||||
// }, function(msg) {
|
||||
// $scope.state = 'empty';
|
||||
// $scope.privateBaseRepository = null;
|
||||
//
|
||||
// $scope.$apply(function() {
|
||||
// opt_callback && opt_callback(false, msg || 'Could not find valid Dockerfile');
|
||||
// });
|
||||
// });
|
||||
|
||||
$scope.$apply(function() {
|
||||
opt_callback && opt_callback(true, 'Dockerfile found and valid')
|
||||
});
|
||||
}, function(msg) {
|
||||
$scope.state = 'empty';
|
||||
$scope.privateBaseRepository = null;
|
||||
DockerfileService.extractDockerfile(files[0])
|
||||
.then(function(dockerfileInfo) {
|
||||
var baseImage = dockerfileInfo.getRegistryBaseImage();
|
||||
if (baseImage) {
|
||||
checkPrivateImage(baseImage);
|
||||
} else {
|
||||
$scope.state = 'ready';
|
||||
}
|
||||
|
||||
$scope.$apply(function() {
|
||||
opt_callback && opt_callback(false, msg || 'Could not find valid Dockerfile');
|
||||
$scope.$apply(function() {
|
||||
opt_callback && opt_callback(true, 'Dockerfile found and valid')
|
||||
});
|
||||
})
|
||||
.catch(function(error) {
|
||||
$scope.state = 'empty';
|
||||
$scope.privateBaseRepository = null;
|
||||
|
||||
$scope.$apply(function() {
|
||||
opt_callback && opt_callback(false, error || 'Could not find valid Dockerfile');
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.handleFilesCleared = function() {
|
||||
|
|
Reference in a new issue