fix(containerCreation): fix an issue when creating an image from a custom registry without automatic pulling (#50)

pull/53/head
Anthony Lapenna 9 years ago committed by GitHub
parent d124c21d1b
commit ca27e7f27a

@ -12,6 +12,8 @@ function ($scope, $state, Config, Container, Image, Volume, Network, Messages, e
Registry: '' Registry: ''
}; };
$scope.imageConfig = {};
$scope.config = { $scope.config = {
Env: [], Env: [],
HostConfig: { HostConfig: {
@ -104,6 +106,23 @@ function ($scope, $state, Config, Container, Image, Volume, Network, Messages, e
}); });
} }
function pullImageAndCreateContainer(config) {
$('#createContainerSpinner').show();
Image.create($scope.imageConfig, function (data) {
var err = data.length > 0 && data[data.length - 1].hasOwnProperty('error');
if (err) {
var detail = data[data.length - 1];
$('#createContainerSpinner').hide();
Messages.error('Error', detail.error);
} else {
createContainer(config);
}
}, function (e) {
$('#createContainerSpinner').hide();
Messages.error('Error', 'Unable to pull image ' + image);
});
}
function createImageConfig(imageName, registry) { function createImageConfig(imageName, registry) {
var imageNameAndTag = imageName.split(':'); var imageNameAndTag = imageName.split(':');
var image = imageNameAndTag[0]; var image = imageNameAndTag[0];
@ -117,27 +136,12 @@ function ($scope, $state, Config, Container, Image, Volume, Network, Messages, e
return imageConfig; return imageConfig;
} }
function pullImageAndCreateContainer(config) { function prepareImageConfig(config) {
$('#createContainerSpinner').show();
var image = _.toLower(config.Image); var image = _.toLower(config.Image);
var registry = _.toLower($scope.formValues.Registry); var registry = $scope.formValues.Registry;
var imageConfig = createImageConfig(image, registry); var imageConfig = createImageConfig(image, registry);
config.Image = imageConfig.fromImage + ':' + imageConfig.tag; config.Image = imageConfig.fromImage + ':' + imageConfig.tag;
$scope.imageConfig = imageConfig;
Image.create(imageConfig, function (data) {
var err = data.length > 0 && data[data.length - 1].hasOwnProperty('error');
if (err) {
var detail = data[data.length - 1];
$('#createContainerSpinner').hide();
Messages.error('Error', detail.error);
} else {
createContainer(config);
}
}, function (e) {
$('#createContainerSpinner').hide();
Messages.error('Error', 'Unable to pull image ' + image);
});
} }
function preparePortBindings(config) { function preparePortBindings(config) {
@ -199,6 +203,7 @@ function ($scope, $state, Config, Container, Image, Volume, Network, Messages, e
function prepareConfiguration() { function prepareConfiguration() {
var config = angular.copy($scope.config); var config = angular.copy($scope.config);
prepareImageConfig(config);
preparePortBindings(config); preparePortBindings(config);
prepareConsole(config); prepareConsole(config);
prepareEnvironmentVariables(config); prepareEnvironmentVariables(config);

Loading…
Cancel
Save