mirror of https://github.com/portainer/portainer
Added ENV variables to container start.
parent
76d7e280f9
commit
4d22a04484
|
@ -7,7 +7,7 @@ function($scope, $routeParams, $location, Container, Messages) {
|
|||
memory: 0,
|
||||
memorySwap: 0,
|
||||
cpuShares: 1024,
|
||||
env: '',
|
||||
env: [],
|
||||
commands: '',
|
||||
volumesFrom: '',
|
||||
portBindings: []
|
||||
|
@ -28,6 +28,10 @@ function($scope, $routeParams, $location, Container, Messages) {
|
|||
var loc = $location;
|
||||
var s = $scope;
|
||||
|
||||
var env = $scope.config.env.map(function(envar) {
|
||||
return envar.name + '=' + envar.value;
|
||||
});
|
||||
|
||||
var exposedPorts = {};
|
||||
var portBindings = {};
|
||||
// TODO: consider using compatibility library
|
||||
|
@ -57,6 +61,7 @@ function($scope, $routeParams, $location, Container, Messages) {
|
|||
CpuShares: $scope.config.cpuShares,
|
||||
Cmd: cmds,
|
||||
VolumesFrom: $scope.config.volumesFrom,
|
||||
Env: env,
|
||||
ExposedPorts: exposedPorts,
|
||||
HostConfig: {
|
||||
PortBindings: portBindings
|
||||
|
@ -90,4 +95,13 @@ function($scope, $routeParams, $location, Container, Messages) {
|
|||
var idx = $scope.config.portBindings.indexOf(portBinding);
|
||||
$scope.config.portBindings.splice(idx, 1);
|
||||
};
|
||||
|
||||
$scope.addEnv = function() {
|
||||
$scope.config.env.push({name: '', value: ''});
|
||||
};
|
||||
|
||||
$scope.removeEnv = function(envar) {
|
||||
var idx = $scope.config.env.indexOf(envar);
|
||||
$scope.config.env.splice(idx, 1);
|
||||
};
|
||||
}]);
|
||||
|
|
|
@ -19,7 +19,7 @@ describe('startContainerController', function () {
|
|||
});
|
||||
}));
|
||||
|
||||
describe('Starting a container with options', function () {
|
||||
describe('Create and start a container with port bindings', function () {
|
||||
it('should issue a correct create request to the Docker remote API', function() {
|
||||
var controller = createController();
|
||||
var id = '6abd8bfba81cf8a05a76a4bdefcb36c4b66cd02265f4bfcd0e236468696ebc6c';
|
||||
|
@ -30,6 +30,7 @@ describe('startContainerController', function () {
|
|||
"CpuShares": 1024,
|
||||
"Cmd": null,
|
||||
"VolumesFrom": "",
|
||||
"Env": [],
|
||||
"ExposedPorts":{
|
||||
"9000/tcp": {},
|
||||
},
|
||||
|
@ -53,11 +54,40 @@ describe('startContainerController', function () {
|
|||
scope.config.name = 'container-name';
|
||||
scope.config.portBindings = [{ip: '10.20.10.15', extPort: '9999', intPort: '9000'}]
|
||||
|
||||
//var response = mockContainer.create({});
|
||||
scope.create();
|
||||
|
||||
$httpBackend.flush();
|
||||
//console.log(response);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Create and start a container with environment variables', function () {
|
||||
it('should issue a correct create request to the Docker remote API', function() {
|
||||
var controller = createController();
|
||||
var id = '6abd8bfba81cf8a05a76a4bdefcb36c4b66cd02265f4bfcd0e236468696ebc6c';
|
||||
var expectedBody = {
|
||||
"name": "container-name",
|
||||
"Memory": 0,
|
||||
"MemorySwap": 0,
|
||||
"CpuShares": 1024,
|
||||
"Cmd": null,
|
||||
"VolumesFrom": "",
|
||||
"Env":["SHELL=/bin/bash", "TERM=xterm-256color"],
|
||||
"ExposedPorts":{},
|
||||
"HostConfig": {"PortBindings":{}}
|
||||
};
|
||||
$httpBackend.expectPOST('/dockerapi/containers/create?name=container-name', expectedBody).respond({
|
||||
"Id": id,
|
||||
"Warnings": null
|
||||
});
|
||||
$httpBackend.expectPOST('/dockerapi/containers/' + id + '/start?').respond({
|
||||
"Id": id,
|
||||
"Warnings": null
|
||||
});
|
||||
|
||||
scope.config.name = 'container-name';
|
||||
scope.config.env = [{name: 'SHELL', value: '/bin/bash'}, {name: 'TERM', value: 'xterm-256color'}];
|
||||
|
||||
scope.create();
|
||||
$httpBackend.flush();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -33,6 +33,23 @@
|
|||
<label>Volumes From:</label>
|
||||
<input type="text" ng-model="config.volumesFrom" class="form-control"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Environment Variables:</label>
|
||||
<div ng-repeat="envar in config.env" class="form-inline">
|
||||
<div class="form-group">
|
||||
<label class="sr-only">Variable Name:</label>
|
||||
<input type="text" ng-model="envar.name" class="form-control" placeholder="NAME"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="sr-only">Variable Value:</label>
|
||||
<input type="text" ng-model="envar.value" class="form-control" placeholder="value"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button class="btn btn-danger btn-xs form-control" ng-click="removeEnv(portBinding)">Remove</button>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-success" ng-click="addEnv()">Add ENV variable</button>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Port bindings:</label>
|
||||
<div ng-repeat="portBinding in config.portBindings" class="form-inline">
|
||||
|
|
|
@ -6,6 +6,7 @@ files = [
|
|||
JASMINE,
|
||||
JASMINE_ADAPTER,
|
||||
'assets/js/jquery-1.11.1.min.js',
|
||||
'assets/js/bootstrap.min.js',
|
||||
'assets/js/angularjs/1.2.6/angular.min.js',
|
||||
'assets/js/angularjs/1.2.6/angular-route.min.js',
|
||||
'assets/js/angularjs/1.2.6/angular-resource.min.js',
|
||||
|
|
Loading…
Reference in New Issue