mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 22:39:41 +02:00
feat(stacks): add the ability to specify env vars when deploying stacks (#1345)
This commit is contained in:
parent
42347d714f
commit
693f1319a4
11 changed files with 173 additions and 30 deletions
|
@ -1,6 +1,6 @@
|
|||
angular.module('createStack', [])
|
||||
.controller('CreateStackController', ['$scope', '$state', '$document', 'StackService', 'CodeMirrorService', 'Authentication', 'Notifications', 'FormValidator', 'ResourceControlService',
|
||||
function ($scope, $state, $document, StackService, CodeMirrorService, Authentication, Notifications, FormValidator, ResourceControlService) {
|
||||
.controller('CreateStackController', ['$scope', '$state', '$document', 'StackService', 'CodeMirrorService', 'Authentication', 'Notifications', 'FormValidator', 'ResourceControlService', 'FormHelper',
|
||||
function ($scope, $state, $document, StackService, CodeMirrorService, Authentication, Notifications, FormValidator, ResourceControlService, FormHelper) {
|
||||
|
||||
// Store the editor content when switching builder methods
|
||||
var editorContent = '';
|
||||
|
@ -11,6 +11,7 @@ function ($scope, $state, $document, StackService, CodeMirrorService, Authentica
|
|||
StackFileContent: '# Define or paste the content of your docker-compose file here',
|
||||
StackFile: null,
|
||||
RepositoryURL: '',
|
||||
Env: [],
|
||||
RepositoryPath: 'docker-compose.yml',
|
||||
AccessControlData: new AccessControlFormData()
|
||||
};
|
||||
|
@ -20,6 +21,14 @@ function ($scope, $state, $document, StackService, CodeMirrorService, Authentica
|
|||
formValidationError: ''
|
||||
};
|
||||
|
||||
$scope.addEnvironmentVariable = function() {
|
||||
$scope.formValues.Env.push({ name: '', value: ''});
|
||||
};
|
||||
|
||||
$scope.removeEnvironmentVariable = function(index) {
|
||||
$scope.formValues.Env.splice(index, 1);
|
||||
};
|
||||
|
||||
function validateForm(accessControlData, isAdmin) {
|
||||
$scope.state.formValidationError = '';
|
||||
var error = '';
|
||||
|
@ -34,20 +43,21 @@ function ($scope, $state, $document, StackService, CodeMirrorService, Authentica
|
|||
|
||||
function createStack(name) {
|
||||
var method = $scope.state.Method;
|
||||
var env = FormHelper.removeInvalidEnvVars($scope.formValues.Env);
|
||||
|
||||
if (method === 'editor') {
|
||||
// The codemirror editor does not work with ng-model so we need to retrieve
|
||||
// the value directly from the editor.
|
||||
var stackFileContent = $scope.editor.getValue();
|
||||
|
||||
return StackService.createStackFromFileContent(name, stackFileContent);
|
||||
return StackService.createStackFromFileContent(name, stackFileContent, env);
|
||||
} else if (method === 'upload') {
|
||||
var stackFile = $scope.formValues.StackFile;
|
||||
return StackService.createStackFromFileUpload(name, stackFile);
|
||||
return StackService.createStackFromFileUpload(name, stackFile, env);
|
||||
} else if (method === 'repository') {
|
||||
var gitRepository = $scope.formValues.RepositoryURL;
|
||||
var pathInRepository = $scope.formValues.RepositoryPath;
|
||||
return StackService.createStackFromGitRepository(name, gitRepository, pathInRepository);
|
||||
return StackService.createStackFromGitRepository(name, gitRepository, pathInRepository, env);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue