From 50d33a07dfea390260d63d6627eb542cdc23bb9c Mon Sep 17 00:00:00 2001 From: Roman Usachev Date: Wed, 24 Feb 2016 03:13:24 +0300 Subject: [PATCH] Filesystem binds edit --- app/components/container/container.html | 50 ++++++++++++++-- .../container/containerController.js | 59 ++++++++++++++++++- 2 files changed, 100 insertions(+), 9 deletions(-) diff --git a/app/components/container/container.html b/app/components/container/container.html index 419932e95..2ec08ef6c 100644 --- a/app/components/container/container.html +++ b/app/components/container/container.html @@ -76,13 +76,13 @@ Environment: -
- +
+
  • {{ k }}
-
+
@@ -138,8 +138,8 @@ Ports: -
- +
+
  • {{ containerport }} => @@ -147,7 +147,7 @@
-
+
@@ -195,6 +195,44 @@
{{ container.Config.Entrypoint.join(' ') }}
+ + Bindings: + +
+ + +
    +
  • {{ b }}
  • +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + +
+ + Volumes: {{ container.Volumes }} diff --git a/app/components/container/containerController.js b/app/components/container/containerController.js index 9977ff37b..56881de7a 100644 --- a/app/components/container/containerController.js +++ b/app/components/container/containerController.js @@ -2,7 +2,9 @@ angular.module('container', []) .controller('ContainerController', ['$scope', '$routeParams', '$location', 'Container', 'ContainerCommit', 'Image', 'Messages', 'ViewSpinner', '$timeout', function ($scope, $routeParams, $location, Container, ContainerCommit, Image, Messages, ViewSpinner, $timeout) { $scope.changes = []; - $scope.edit = false; + $scope.editEnv = false; + $scope.editPorts = false; + $scope.editBinds = false; $scope.newCfg = { Env: [], Ports: {} @@ -14,11 +16,46 @@ angular.module('container', []) $scope.container = d; $scope.container.edit = false; $scope.container.newContainerName = d.Name; + + // fill up env $scope.newCfg.Env = d.Config.Env.map(function(entry) { return {name: entry.split('=')[0], value: entry.split('=')[1]}; }); - $scope.newCfg.Ports = angular.copy(d.HostConfig.PortBindings) || []; - angular.forEach($scope.newCfg.Ports, function(conf, port, arr) { arr[port] = conf || []; }); + + // fill up ports + $scope.newCfg.Ports = {}; + angular.forEach(d.Config.ExposedPorts, function(i, port) { + $scope.newCfg.Ports[port] = d.HostConfig.PortBindings[port] || []; + }); + //angular.forEach($scope.newCfg.Ports, function(conf, port, arr) { arr[port] = conf || []; }); + + // fill up bindings + $scope.newCfg.Binds = []; + var defaultBinds = {}; + angular.forEach(d.Config.Volumes, function(value, vol) { + defaultBinds[vol] = { ContPath: vol, HostPath: '', ReadOnly: false, DefaultBind: true }; + }); + angular.forEach(d.HostConfig.Binds, function(binding, i) { + var mountpoint = binding.split(':')[0]; + var vol = binding.split(':')[1] || ''; + var ro = binding.split(':').length > 2 && binding.split(':')[2] == 'ro'; + var defaultBind = false; + if (vol == '') { + vol = mountpoint; + mountpoint = ''; + } + + if (vol in defaultBinds) { + delete defaultBinds[vol]; + defaultBind = true; + } + $scope.newCfg.Binds.push({ ContPath: vol, HostPath: mountpoint, ReadOnly: ro, DefaultBind: defaultBind }); + }); + angular.forEach(defaultBinds, function(bind) { + $scope.newCfg.Binds.push(bind); + }); + + console.log($scope.newCfg); ViewSpinner.stop(); }, function (e) { @@ -78,6 +115,21 @@ angular.module('container', []) var portBindings = angular.copy($scope.newCfg.Ports); + var binds = []; + angular.forEach($scope.newCfg.Binds, function(b) { + if (b.ContPath != '') { + var bindLine = ''; + if (b.HostPath != '') { + bindLine = b.HostPath + ':'; + } + bindLine += b.ContPath; + if (b.ReadOnly) { + bindLine += ':ro'; + } + binds.push(bindLine); + } + }); + ViewSpinner.spin(); ContainerCommit.commit({id: $routeParams.id, tag: $scope.container.Config.Image, config: config }, function (d) { @@ -87,6 +139,7 @@ angular.module('container', []) // Append current host config to image with new port bindings imageData.Config.HostConfig = angular.copy($scope.container.HostConfig); imageData.Config.HostConfig.PortBindings = portBindings; + imageData.Config.HostConfig.Binds = binds; Container.create(imageData.Config, function(containerData) { // Stop current if running