From 1d150414d942f45108d656c7535d61a5060e609c Mon Sep 17 00:00:00 2001 From: Riccardo Capuani Date: Fri, 27 Oct 2017 10:48:11 +0200 Subject: [PATCH] feat(templates): add /etc/hosts entries support (#1307) --- app/components/templates/templates.html | 24 +++++++++++++++++++ .../templates/templatesController.js | 8 +++++++ app/helpers/templateHelper.js | 3 ++- app/models/api/template.js | 1 + app/services/templateService.js | 1 + 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/app/components/templates/templates.html b/app/components/templates/templates.html index 8b7172b17..74f773fbe 100644 --- a/app/components/templates/templates.html +++ b/app/components/templates/templates.html @@ -195,6 +195,30 @@ + +
+
+ + + add additional entry + +
+ +
+
+
+
+ value + +
+ +
+
+
+
+ diff --git a/app/components/templates/templatesController.js b/app/components/templates/templatesController.js index dac5df747..38fc6a525 100644 --- a/app/components/templates/templatesController.js +++ b/app/components/templates/templatesController.js @@ -34,6 +34,14 @@ function ($scope, $q, $state, $transition$, $anchorScroll, $filter, ContainerSer $scope.state.selectedTemplate.Ports.splice(index, 1); }; + $scope.addExtraHost = function() { + $scope.state.selectedTemplate.Hosts.push(''); + }; + + $scope.removeExtraHost = function(index) { + $scope.state.selectedTemplate.Hosts.splice(index, 1); + }; + function validateForm(accessControlData, isAdmin) { $scope.state.formValidationError = ''; var error = ''; diff --git a/app/helpers/templateHelper.js b/app/helpers/templateHelper.js index a4f626fd5..d6ad6bc63 100644 --- a/app/helpers/templateHelper.js +++ b/app/helpers/templateHelper.js @@ -15,7 +15,8 @@ angular.module('portainer.helpers') }, PortBindings: {}, Binds: [], - Privileged: false + Privileged: false, + ExtraHosts: [] }, Volumes: {} }; diff --git a/app/models/api/template.js b/app/models/api/template.js index 0123f92e4..e6499ee33 100644 --- a/app/models/api/template.js +++ b/app/models/api/template.js @@ -42,4 +42,5 @@ function TemplateViewModel(data) { }; }); } + this.Hosts = data.hosts ? data.hosts : []; } diff --git a/app/services/templateService.js b/app/services/templateService.js index a28e866ea..57fe4b9b2 100644 --- a/app/services/templateService.js +++ b/app/services/templateService.js @@ -40,6 +40,7 @@ angular.module('portainer.services') configuration.HostConfig.NetworkMode = network.Name; configuration.HostConfig.Privileged = template.Privileged; configuration.HostConfig.RestartPolicy = { Name: template.RestartPolicy }; + configuration.HostConfig.ExtraHosts = template.Hosts ? template.Hosts : []; configuration.name = containerName; configuration.Hostname = containerName; configuration.Image = template.Image;