mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
feat(stack-creation): add the ability to specify git credentials (#1722)
* feat(stack-creation): add the ability to specify git credentials * docs(api): update Swagger
This commit is contained in:
parent
50ece68f35
commit
adf1ba7b47
7 changed files with 106 additions and 45 deletions
|
@ -124,7 +124,7 @@ function StackServiceFactory($q, Stack, ResourceControlService, FileUploadServic
|
|||
return deferred.promise;
|
||||
};
|
||||
|
||||
service.createStackFromGitRepository = function(name, gitRepository, pathInRepository, env) {
|
||||
service.createStackFromGitRepository = function(name, repositoryOptions, env) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
SwarmService.swarm()
|
||||
|
@ -133,8 +133,11 @@ function StackServiceFactory($q, Stack, ResourceControlService, FileUploadServic
|
|||
var payload = {
|
||||
Name: name,
|
||||
SwarmID: swarm.Id,
|
||||
GitRepository: gitRepository,
|
||||
PathInRepository: pathInRepository,
|
||||
RepositoryURL: repositoryOptions.RepositoryURL,
|
||||
ComposeFilePathInRepository: repositoryOptions.ComposeFilePathInRepository,
|
||||
RepositoryAuthentication: repositoryOptions.RepositoryAuthentication,
|
||||
RepositoryUsername: repositoryOptions.RepositoryUsername,
|
||||
RepositoryPassword: repositoryOptions.RepositoryPassword,
|
||||
Env: env
|
||||
};
|
||||
return Stack.create({ method: 'repository' }, payload).$promise;
|
||||
|
|
|
@ -7,8 +7,11 @@ function ($scope, $state, StackService, Authentication, Notifications, FormValid
|
|||
StackFileContent: '',
|
||||
StackFile: null,
|
||||
RepositoryURL: '',
|
||||
RepositoryAuthentication: false,
|
||||
RepositoryUsername: '',
|
||||
RepositoryPassword: '',
|
||||
Env: [],
|
||||
RepositoryPath: 'docker-compose.yml',
|
||||
ComposeFilePathInRepository: 'docker-compose.yml',
|
||||
AccessControlData: new AccessControlFormData()
|
||||
};
|
||||
|
||||
|
@ -48,9 +51,14 @@ function ($scope, $state, StackService, Authentication, Notifications, FormValid
|
|||
var stackFile = $scope.formValues.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, env);
|
||||
var repositoryOptions = {
|
||||
RepositoryURL: $scope.formValues.RepositoryURL,
|
||||
ComposeFilePathInRepository: $scope.formValues.ComposeFilePathInRepository,
|
||||
RepositoryAuthentication: $scope.formValues.RepositoryAuthentication,
|
||||
RepositoryUsername: $scope.formValues.RepositoryUsername,
|
||||
RepositoryPassword: $scope.formValues.RepositoryPassword
|
||||
};
|
||||
return StackService.createStackFromGitRepository(name, repositoryOptions, env);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,19 +84,17 @@ function ($scope, $state, StackService, Authentication, Notifications, FormValid
|
|||
createStack(name, method)
|
||||
.then(function success(data) {
|
||||
Notifications.success('Stack successfully deployed');
|
||||
return ResourceControlService.applyResourceControl('stack', name, userId, accessControlData, [])
|
||||
.then(function success() {
|
||||
$state.go('docker.stacks');
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to apply resource control on the stack');
|
||||
});
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.warning('Deployment error', err.err.data.err);
|
||||
})
|
||||
.then(function success(data) {
|
||||
return ResourceControlService.applyResourceControl('stack', name, userId, accessControlData, []);
|
||||
})
|
||||
.then(function success() {
|
||||
$state.go('docker.stacks');
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to apply resource control on the stack');
|
||||
})
|
||||
.finally(function final() {
|
||||
$scope.state.actionInProgress = false;
|
||||
});
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<span class="col-sm-12 text-muted small">
|
||||
You can use the URL of a public git repository.
|
||||
You can use the URL of a git repository.
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
@ -130,7 +130,29 @@
|
|||
<div class="form-group">
|
||||
<label for="stack_repository_path" class="col-sm-2 control-label text-left">Compose path</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" ng-model="formValues.RepositoryPath" id="stack_repository_path" placeholder="docker-compose.yml">
|
||||
<input type="text" class="form-control" ng-model="formValues.ComposeFilePathInRepository" id="stack_repository_path" placeholder="docker-compose.yml">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<label class="control-label text-left">
|
||||
Authentication
|
||||
</label>
|
||||
<label class="switch" style="margin-left: 20px;">
|
||||
<input type="checkbox" ng-model="formValues.RepositoryAuthentication"><i></i>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" ng-if="formValues.RepositoryAuthentication">
|
||||
<label for="repository_username" class="col-sm-1 control-label text-left">Username</label>
|
||||
<div class="col-sm-11 col-md-5">
|
||||
<input type="text" class="form-control" ng-model="formValues.RepositoryUsername" name="repository_username" placeholder="myGitUser">
|
||||
</div>
|
||||
<label for="repository_password" class="col-sm-1 margin-sm-top control-label text-left">
|
||||
Password
|
||||
</label>
|
||||
<div class="col-sm-11 col-md-5 margin-sm-top">
|
||||
<input type="password" class="form-control" ng-model="formValues.RepositoryPassword" name="repository_password" placeholder="myPassword">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -174,7 +196,7 @@
|
|||
<div class="col-sm-12">
|
||||
<button type="button" class="btn btn-primary btn-sm" ng-disabled="state.actionInProgress
|
||||
|| (state.Method === 'upload' && !formValues.StackFile)
|
||||
|| (state.Method === 'repository' && (!formValues.RepositoryURL || !formValues.RepositoryPath))
|
||||
|| (state.Method === 'repository' && ((!formValues.RepositoryURL || !formValues.ComposeFilePathInRepository) || (formValues.RepositoryAuthentication && (!formValues.RepositoryUsername || !formValues.RepositoryPassword))))
|
||||
|| !formValues.Name" ng-click="deployStack()" button-spinner="state.actionInProgress">
|
||||
<span ng-hide="state.actionInProgress">Deploy the stack</span>
|
||||
<span ng-show="state.actionInProgress">Deployment in progress...</span>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue