1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-21 14:29:40 +02:00

fix(service-creation): fix the command specification and add the ability to specify an entrypoint (#409)

This commit is contained in:
Anthony Lapenna 2016-12-25 22:14:26 +13:00 committed by GitHub
parent edeed41797
commit ce32ed5b98
2 changed files with 20 additions and 1 deletions

View file

@ -9,6 +9,7 @@ function ($scope, $state, Service, Volume, Network, ImageHelper, Messages) {
Mode: 'replicated', Mode: 'replicated',
Replicas: 1, Replicas: 1,
Command: '', Command: '',
EntryPoint: '',
WorkingDir: '', WorkingDir: '',
User: '', User: '',
Env: [], Env: [],
@ -93,9 +94,19 @@ function ($scope, $state, Service, Volume, Network, ImageHelper, Messages) {
} }
} }
function commandToArray(cmd) {
var tokens = [].concat.apply([], cmd.split('"').map(function(v,i) {
return i%2 ? v : v.split(' ');
})).filter(Boolean);
return tokens;
}
function prepareCommandConfig(config, input) { function prepareCommandConfig(config, input) {
if (input.EntryPoint) {
config.TaskTemplate.ContainerSpec.Command = commandToArray(input.EntryPoint);
}
if (input.Command) { if (input.Command) {
config.TaskTemplate.ContainerSpec.Command = _.split(input.Command, ' '); config.TaskTemplate.ContainerSpec.Args = commandToArray(input.Command);
} }
if (input.User) { if (input.User) {
config.TaskTemplate.ContainerSpec.User = input.User; config.TaskTemplate.ContainerSpec.User = input.User;

View file

@ -116,6 +116,14 @@
</div> </div>
</div> </div>
<!-- !command-input --> <!-- !command-input -->
<!-- entrypoint-input -->
<div class="form-group">
<label for="service_entrypoint" class="col-sm-1 control-label text-left">Entrypoint</label>
<div class="col-sm-9">
<input type="text" class="form-control" ng-model="formValues.EntryPoint" id="service_entrypoint" placeholder="e.g. /bin/sh -c">
</div>
</div>
<!-- !entrypoint-input -->
<!-- workdir-user-input --> <!-- workdir-user-input -->
<div class="form-group"> <div class="form-group">
<label for="service_workingdir" class="col-sm-1 control-label text-left">Working Dir</label> <label for="service_workingdir" class="col-sm-1 control-label text-left">Working Dir</label>