From 4a291247ac83c9b7f773a18190616d91fa6da5c9 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Tue, 7 Nov 2017 08:32:09 +0100 Subject: [PATCH] =?UTF-8?q?feat(service-creation):=20pass=20volume=20drive?= =?UTF-8?q?r=20and=20options=20when=20mapping=20a=E2=80=A6=20(#1360)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(service-creation): pass volume driver and options when mapping an existing volume * refactor(service-creation): remove commented code --- .../createService/createServiceController.js | 24 ++++++++++++++++++- .../createService/createservice.html | 3 +-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/components/createService/createServiceController.js b/app/components/createService/createServiceController.js index 3e3c5ecb1..487104a20 100644 --- a/app/components/createService/createServiceController.js +++ b/app/components/createService/createServiceController.js @@ -198,10 +198,32 @@ function ($q, $scope, $state, $timeout, Service, ServiceHelper, ConfigService, C config.TaskTemplate.ContainerSpec.Labels = LabelHelper.fromKeyValueToLabelHash(input.ContainerLabels); } + function createMountObjectFromVolume(volumeObject, target, readonly) { + return { + Target: target, + Source: volumeObject.Id, + Type: 'volume', + ReadOnly: readonly, + VolumeOptions: { + Labels: volumeObject.Labels, + DriverConfig: { + Name: volumeObject.Driver, + Options: volumeObject.Options + } + } + }; + } + function prepareVolumes(config, input) { input.Volumes.forEach(function (volume) { if (volume.Source && volume.Target) { - config.TaskTemplate.ContainerSpec.Mounts.push(volume); + if (volume.Type !== 'volume') { + config.TaskTemplate.ContainerSpec.Mounts.push(volume); + } else { + var volumeObject = volume.Source; + var mount = createMountObjectFromVolume(volumeObject, volume.Target, volume.ReadOnly); + config.TaskTemplate.ContainerSpec.Mounts.push(mount); + } } }); } diff --git a/app/components/createService/createservice.html b/app/components/createService/createservice.html index e2c404fc0..3368ae1c6 100644 --- a/app/components/createService/createservice.html +++ b/app/components/createService/createservice.html @@ -241,9 +241,8 @@
volume - -