mirror of https://github.com/portainer/portainer
fix(endpoints-creation): remove endpoint if an error is raised during creation (#1678)
parent
0c5152fb5f
commit
b8f8df5f48
|
@ -30,18 +30,21 @@ function ($scope, $state, $filter, EndpointService, Notifications, ExtensionMana
|
||||||
var TLSCertFile = TLSSkipClientVerify ? null : securityData.TLSCert;
|
var TLSCertFile = TLSSkipClientVerify ? null : securityData.TLSCert;
|
||||||
var TLSKeyFile = TLSSkipClientVerify ? null : securityData.TLSKey;
|
var TLSKeyFile = TLSSkipClientVerify ? null : securityData.TLSKey;
|
||||||
|
|
||||||
|
var endpointId;
|
||||||
$scope.state.actionInProgress = true;
|
$scope.state.actionInProgress = true;
|
||||||
EndpointService.createRemoteEndpoint(name, URL, PublicURL, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile)
|
EndpointService.createRemoteEndpoint(name, URL, PublicURL, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile)
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
|
endpointId = data.Id;
|
||||||
var currentEndpointId = EndpointProvider.endpointID();
|
var currentEndpointId = EndpointProvider.endpointID();
|
||||||
EndpointProvider.setEndpointID(data.Id);
|
EndpointProvider.setEndpointID(endpointId);
|
||||||
ExtensionManager.initEndpointExtensions(data.Id)
|
ExtensionManager.initEndpointExtensions(endpointId)
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
Notifications.success('Endpoint created', name);
|
Notifications.success('Endpoint created', name);
|
||||||
$state.reload();
|
$state.reload();
|
||||||
})
|
})
|
||||||
.catch(function error(err) {
|
.catch(function error(err) {
|
||||||
Notifications.error('Failure', err, 'Unable to create endpoint');
|
Notifications.error('Failure', err, 'Unable to create endpoint');
|
||||||
|
EndpointService.deleteEndpoint(endpointId);
|
||||||
})
|
})
|
||||||
.finally(function final() {
|
.finally(function final() {
|
||||||
$scope.state.actionInProgress = false;
|
$scope.state.actionInProgress = false;
|
||||||
|
|
Loading…
Reference in New Issue