mirror of https://github.com/portainer/portainer
feat(app): push pull templates create container
parent
e92dcd1450
commit
51d9b2b9ec
|
@ -34,7 +34,7 @@ angular.module('portainer.docker')
|
|||
};
|
||||
let fullImageName = '';
|
||||
|
||||
if (registry.UseRegistry) {
|
||||
if (registry.UseRegistry && registry.Registry.URL) {
|
||||
fullImageName = registry.Registry.URL + '/' + registry.Image;
|
||||
if (!_.includes(registry.Image, ':')) {
|
||||
fullImageName += ':latest';
|
||||
|
|
|
@ -14,7 +14,6 @@ export function TemplateDefaultModel() {
|
|||
this.RegistryModel = new PorImageRegistryModel();
|
||||
}
|
||||
|
||||
// TODO CHANGE
|
||||
export function TemplateCreateRequest(model) {
|
||||
this.Type = model.Type;
|
||||
this.Name = model.Name;
|
||||
|
@ -54,7 +53,6 @@ export function TemplateUpdateRequest(model) {
|
|||
this.id = model.Id;
|
||||
}
|
||||
|
||||
// TODO CHANGE
|
||||
export function TemplateViewModel(data) {
|
||||
this.Id = data.Id;
|
||||
this.Title = data.title;
|
||||
|
@ -68,9 +66,9 @@ export function TemplateViewModel(data) {
|
|||
this.Logo = data.logo;
|
||||
this.Repository = data.repository;
|
||||
this.Hostname = data.hostname;
|
||||
this.Registry = data.registry ? { URL: data.registry } : {}; // CHANGE
|
||||
this.Image = data.image; // CHANGE
|
||||
this.Registry = data.registry ? data.registry : ''; // CHANGE
|
||||
this.RegistryModel = new PorImageRegistryModel();
|
||||
this.RegistryModel.Image = data.image;
|
||||
this.RegistryModel.Registry = data.registry || {};
|
||||
this.Command = data.command ? data.command : '';
|
||||
this.Network = data.network ? data.network : '';
|
||||
this.Privileged = data.privileged ? data.privileged : false;
|
||||
|
|
|
@ -10,7 +10,6 @@ function TemplateServiceFactory($q, Templates, TemplateHelper, ImageHelper, Cont
|
|||
'use strict';
|
||||
var service = {};
|
||||
|
||||
// TODO CHANGE
|
||||
service.templates = function() {
|
||||
var deferred = $q.defer();
|
||||
|
||||
|
@ -28,7 +27,6 @@ function TemplateServiceFactory($q, Templates, TemplateHelper, ImageHelper, Cont
|
|||
return deferred.promise;
|
||||
};
|
||||
|
||||
// TODO CHANGE
|
||||
service.template = function(id) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
|
@ -49,7 +47,6 @@ function TemplateServiceFactory($q, Templates, TemplateHelper, ImageHelper, Cont
|
|||
return Templates.remove({ id: id }).$promise;
|
||||
};
|
||||
|
||||
// TODO CHANGE
|
||||
service.create = function(model) {
|
||||
var payload = new TemplateCreateRequest(model);
|
||||
return Templates.create(payload).$promise;
|
||||
|
@ -63,12 +60,12 @@ function TemplateServiceFactory($q, Templates, TemplateHelper, ImageHelper, Cont
|
|||
|
||||
service.createTemplateConfiguration = function(template, containerName, network) {
|
||||
var imageConfiguration = ImageHelper.createImageConfigForContainer(template.RegistryModel);
|
||||
var containerConfiguration = service.createContainerConfiguration(template, containerName, network);
|
||||
containerConfiguration.Image = imageConfiguration.fromImage + ':' + imageConfiguration.tag;
|
||||
var containerConfiguration = createContainerConfiguration(template, containerName, network);
|
||||
containerConfiguration.Image = imageConfiguration.fromImage;
|
||||
return containerConfiguration;
|
||||
};
|
||||
|
||||
service.createContainerConfiguration = function(template, containerName, network) {
|
||||
function createContainerConfiguration(template, containerName, network) {
|
||||
var configuration = TemplateHelper.getDefaultContainerConfiguration();
|
||||
configuration.HostConfig.NetworkMode = network.Name;
|
||||
configuration.HostConfig.Privileged = template.Privileged;
|
||||
|
@ -76,7 +73,6 @@ function TemplateServiceFactory($q, Templates, TemplateHelper, ImageHelper, Cont
|
|||
configuration.HostConfig.ExtraHosts = template.Hosts ? template.Hosts : [];
|
||||
configuration.name = containerName;
|
||||
configuration.Hostname = template.Hostname;
|
||||
configuration.Image = template.Image;
|
||||
configuration.Env = TemplateHelper.EnvToStringArray(template.Env);
|
||||
configuration.Cmd = ContainerHelper.commandStringToArray(template.Command);
|
||||
var portConfiguration = TemplateHelper.portArrayToPortConfiguration(template.Ports);
|
||||
|
@ -87,7 +83,7 @@ function TemplateServiceFactory($q, Templates, TemplateHelper, ImageHelper, Cont
|
|||
configuration.Tty = consoleConfiguration.tty;
|
||||
configuration.Labels = TemplateHelper.updateContainerConfigurationWithLabels(template.Labels);
|
||||
return configuration;
|
||||
};
|
||||
}
|
||||
|
||||
service.updateContainerConfigurationWithVolumes = function(configuration, template, generatedVolumesPile) {
|
||||
var volumes = template.Volumes;
|
||||
|
|
|
@ -73,7 +73,7 @@ function ($scope, $q, $state, $transition$, $anchorScroll, ContainerService, Ima
|
|||
generatedVolumeIds.push(volumeId);
|
||||
});
|
||||
TemplateService.updateContainerConfigurationWithVolumes(templateConfiguration, template, data);
|
||||
return ImageService.pullImage(template.Image, { URL: template.Registry }, true);
|
||||
return ImageService.pullImage(template.RegistryModel, true);
|
||||
})
|
||||
.then(function success() {
|
||||
return ContainerService.createAndStartContainer(templateConfiguration);
|
||||
|
@ -94,6 +94,7 @@ function ($scope, $q, $state, $transition$, $anchorScroll, ContainerService, Ima
|
|||
});
|
||||
}
|
||||
|
||||
// TODO CHANGE
|
||||
function createComposeStackFromTemplate(template, userId, accessControlData) {
|
||||
var stackName = $scope.formValues.name;
|
||||
|
||||
|
@ -127,6 +128,7 @@ function ($scope, $q, $state, $transition$, $anchorScroll, ContainerService, Ima
|
|||
});
|
||||
}
|
||||
|
||||
// TODO CHANGE
|
||||
function createStackFromTemplate(template, userId, accessControlData) {
|
||||
var stackName = $scope.formValues.name;
|
||||
var env =_.filter(
|
||||
|
|
Loading…
Reference in New Issue