mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
feat(templates): advanced template creation (#277)
This commit is contained in:
parent
6589730acc
commit
c3cf5b5f9d
6 changed files with 55 additions and 15 deletions
|
@ -48,4 +48,42 @@ angular.module('portainer.helpers', [])
|
|||
};
|
||||
}
|
||||
};
|
||||
}]);
|
||||
}])
|
||||
.factory('TemplateHelper', [function TemplateHelperFactory() {
|
||||
'use strict';
|
||||
return {
|
||||
getPortBindings: function(ports) {
|
||||
var bindings = [];
|
||||
ports.forEach(function (port) {
|
||||
var portAndProtocol = _.split(port, '/');
|
||||
var binding = {
|
||||
containerPort: portAndProtocol[0],
|
||||
protocol: portAndProtocol[1]
|
||||
};
|
||||
bindings.push(binding);
|
||||
});
|
||||
return bindings;
|
||||
},
|
||||
getVolumeBindings: function(volumes) {
|
||||
var bindings = [];
|
||||
volumes.forEach(function (volume) {
|
||||
bindings.push({ containerPath: volume });
|
||||
});
|
||||
return bindings;
|
||||
},
|
||||
getEnvBindings: function(env) {
|
||||
var bindings = [];
|
||||
env.forEach(function (envvar) {
|
||||
var binding = {
|
||||
name: envvar.name
|
||||
};
|
||||
if (envvar.set) {
|
||||
binding.value = envvar.set;
|
||||
}
|
||||
bindings.push(binding);
|
||||
});
|
||||
return bindings;
|
||||
}
|
||||
};
|
||||
}])
|
||||
;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue