From bde9dd8b8808695cc1b73d2ff89a81af624ed483 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Sat, 27 May 2017 10:11:42 +0200 Subject: [PATCH] feat(templates): add support for a restart_policy field (#898) --- app/models/api/template.js | 3 ++- app/models/api/templateLinuxServer.js | 2 ++ app/services/templateService.js | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/api/template.js b/app/models/api/template.js index 6d8d5497a..b7ade6535 100644 --- a/app/models/api/template.js +++ b/app/models/api/template.js @@ -11,8 +11,9 @@ function TemplateViewModel(data) { this.Network = data.network ? data.network : ''; this.Env = data.env ? data.env : []; this.Privileged = data.privileged ? data.privileged : false; - this.Volumes = []; this.Interactive = data.interactive ? data.interactive : false; + this.RestartPolicy = data.restart_policy ? data.restart_policy : 'always'; + this.Volumes = []; if (data.volumes) { this.Volumes = data.volumes.map(function (v) { return { diff --git a/app/models/api/templateLinuxServer.js b/app/models/api/templateLinuxServer.js index ae65c214d..d6c0d210b 100644 --- a/app/models/api/templateLinuxServer.js +++ b/app/models/api/templateLinuxServer.js @@ -10,6 +10,8 @@ function TemplateLSIOViewModel(data) { this.Network = data.network ? data.network : ''; this.Env = data.env ? data.env : []; this.Privileged = data.privileged ? data.privileged : false; + this.Interactive = data.interactive ? data.interactive : false; + this.RestartPolicy = data.restart_policy ? data.restart_policy : 'always'; this.Volumes = []; if (data.volumes) { this.Volumes = data.volumes.map(function (v) { diff --git a/app/services/templateService.js b/app/services/templateService.js index 4be7d7cbe..9a4efc9f1 100644 --- a/app/services/templateService.js +++ b/app/services/templateService.js @@ -39,6 +39,7 @@ angular.module('portainer.services') var configuration = TemplateHelper.getDefaultContainerConfiguration(); configuration.HostConfig.NetworkMode = network.Name; configuration.HostConfig.Privileged = template.Privileged; + configuration.HostConfig.RestartPolicy = { Name: template.RestartPolicy }; configuration.name = containerName; configuration.Image = template.Image; configuration.Env = TemplateHelper.EnvToStringArray(template.Env, containerMapping);