feat(app): push pull templates create container

pull/3393/head
xAt0mZ 2019-11-22 00:30:30 +01:00
parent e92dcd1450
commit 51d9b2b9ec
4 changed files with 11 additions and 15 deletions

View File

@ -34,7 +34,7 @@ angular.module('portainer.docker')
}; };
let fullImageName = ''; let fullImageName = '';
if (registry.UseRegistry) { if (registry.UseRegistry && registry.Registry.URL) {
fullImageName = registry.Registry.URL + '/' + registry.Image; fullImageName = registry.Registry.URL + '/' + registry.Image;
if (!_.includes(registry.Image, ':')) { if (!_.includes(registry.Image, ':')) {
fullImageName += ':latest'; fullImageName += ':latest';

View File

@ -14,7 +14,6 @@ export function TemplateDefaultModel() {
this.RegistryModel = new PorImageRegistryModel(); this.RegistryModel = new PorImageRegistryModel();
} }
// TODO CHANGE
export function TemplateCreateRequest(model) { export function TemplateCreateRequest(model) {
this.Type = model.Type; this.Type = model.Type;
this.Name = model.Name; this.Name = model.Name;
@ -54,7 +53,6 @@ export function TemplateUpdateRequest(model) {
this.id = model.Id; this.id = model.Id;
} }
// TODO CHANGE
export function TemplateViewModel(data) { export function TemplateViewModel(data) {
this.Id = data.Id; this.Id = data.Id;
this.Title = data.title; this.Title = data.title;
@ -68,9 +66,9 @@ export function TemplateViewModel(data) {
this.Logo = data.logo; this.Logo = data.logo;
this.Repository = data.repository; this.Repository = data.repository;
this.Hostname = data.hostname; this.Hostname = data.hostname;
this.Registry = data.registry ? { URL: data.registry } : {}; // CHANGE this.RegistryModel = new PorImageRegistryModel();
this.Image = data.image; // CHANGE this.RegistryModel.Image = data.image;
this.Registry = data.registry ? data.registry : ''; // CHANGE this.RegistryModel.Registry = data.registry || {};
this.Command = data.command ? data.command : ''; this.Command = data.command ? data.command : '';
this.Network = data.network ? data.network : ''; this.Network = data.network ? data.network : '';
this.Privileged = data.privileged ? data.privileged : false; this.Privileged = data.privileged ? data.privileged : false;

View File

@ -10,7 +10,6 @@ function TemplateServiceFactory($q, Templates, TemplateHelper, ImageHelper, Cont
'use strict'; 'use strict';
var service = {}; var service = {};
// TODO CHANGE
service.templates = function() { service.templates = function() {
var deferred = $q.defer(); var deferred = $q.defer();
@ -28,7 +27,6 @@ function TemplateServiceFactory($q, Templates, TemplateHelper, ImageHelper, Cont
return deferred.promise; return deferred.promise;
}; };
// TODO CHANGE
service.template = function(id) { service.template = function(id) {
var deferred = $q.defer(); var deferred = $q.defer();
@ -49,7 +47,6 @@ function TemplateServiceFactory($q, Templates, TemplateHelper, ImageHelper, Cont
return Templates.remove({ id: id }).$promise; return Templates.remove({ id: id }).$promise;
}; };
// TODO CHANGE
service.create = function(model) { service.create = function(model) {
var payload = new TemplateCreateRequest(model); var payload = new TemplateCreateRequest(model);
return Templates.create(payload).$promise; return Templates.create(payload).$promise;
@ -63,12 +60,12 @@ function TemplateServiceFactory($q, Templates, TemplateHelper, ImageHelper, Cont
service.createTemplateConfiguration = function(template, containerName, network) { service.createTemplateConfiguration = function(template, containerName, network) {
var imageConfiguration = ImageHelper.createImageConfigForContainer(template.RegistryModel); var imageConfiguration = ImageHelper.createImageConfigForContainer(template.RegistryModel);
var containerConfiguration = service.createContainerConfiguration(template, containerName, network); var containerConfiguration = createContainerConfiguration(template, containerName, network);
containerConfiguration.Image = imageConfiguration.fromImage + ':' + imageConfiguration.tag; containerConfiguration.Image = imageConfiguration.fromImage;
return containerConfiguration; return containerConfiguration;
}; };
service.createContainerConfiguration = function(template, containerName, network) { function createContainerConfiguration(template, containerName, network) {
var configuration = TemplateHelper.getDefaultContainerConfiguration(); var configuration = TemplateHelper.getDefaultContainerConfiguration();
configuration.HostConfig.NetworkMode = network.Name; configuration.HostConfig.NetworkMode = network.Name;
configuration.HostConfig.Privileged = template.Privileged; configuration.HostConfig.Privileged = template.Privileged;
@ -76,7 +73,6 @@ function TemplateServiceFactory($q, Templates, TemplateHelper, ImageHelper, Cont
configuration.HostConfig.ExtraHosts = template.Hosts ? template.Hosts : []; configuration.HostConfig.ExtraHosts = template.Hosts ? template.Hosts : [];
configuration.name = containerName; configuration.name = containerName;
configuration.Hostname = template.Hostname; configuration.Hostname = template.Hostname;
configuration.Image = template.Image;
configuration.Env = TemplateHelper.EnvToStringArray(template.Env); configuration.Env = TemplateHelper.EnvToStringArray(template.Env);
configuration.Cmd = ContainerHelper.commandStringToArray(template.Command); configuration.Cmd = ContainerHelper.commandStringToArray(template.Command);
var portConfiguration = TemplateHelper.portArrayToPortConfiguration(template.Ports); var portConfiguration = TemplateHelper.portArrayToPortConfiguration(template.Ports);
@ -87,7 +83,7 @@ function TemplateServiceFactory($q, Templates, TemplateHelper, ImageHelper, Cont
configuration.Tty = consoleConfiguration.tty; configuration.Tty = consoleConfiguration.tty;
configuration.Labels = TemplateHelper.updateContainerConfigurationWithLabels(template.Labels); configuration.Labels = TemplateHelper.updateContainerConfigurationWithLabels(template.Labels);
return configuration; return configuration;
}; }
service.updateContainerConfigurationWithVolumes = function(configuration, template, generatedVolumesPile) { service.updateContainerConfigurationWithVolumes = function(configuration, template, generatedVolumesPile) {
var volumes = template.Volumes; var volumes = template.Volumes;

View File

@ -73,7 +73,7 @@ function ($scope, $q, $state, $transition$, $anchorScroll, ContainerService, Ima
generatedVolumeIds.push(volumeId); generatedVolumeIds.push(volumeId);
}); });
TemplateService.updateContainerConfigurationWithVolumes(templateConfiguration, template, data); TemplateService.updateContainerConfigurationWithVolumes(templateConfiguration, template, data);
return ImageService.pullImage(template.Image, { URL: template.Registry }, true); return ImageService.pullImage(template.RegistryModel, true);
}) })
.then(function success() { .then(function success() {
return ContainerService.createAndStartContainer(templateConfiguration); return ContainerService.createAndStartContainer(templateConfiguration);
@ -94,6 +94,7 @@ function ($scope, $q, $state, $transition$, $anchorScroll, ContainerService, Ima
}); });
} }
// TODO CHANGE
function createComposeStackFromTemplate(template, userId, accessControlData) { function createComposeStackFromTemplate(template, userId, accessControlData) {
var stackName = $scope.formValues.name; var stackName = $scope.formValues.name;
@ -127,6 +128,7 @@ function ($scope, $q, $state, $transition$, $anchorScroll, ContainerService, Ima
}); });
} }
// TODO CHANGE
function createStackFromTemplate(template, userId, accessControlData) { function createStackFromTemplate(template, userId, accessControlData) {
var stackName = $scope.formValues.name; var stackName = $scope.formValues.name;
var env =_.filter( var env =_.filter(