mirror of https://github.com/portainer/portainer
feat(area-endpoints/creation): allow custom Docker socket (#4772) and handle public IP, group and tags for docket sockets (#4798)
* fix(endpoints/creation): hide TLS, make use of PublicIP, Groups, Tags for local Docker endpoint * feat(endpoints/creation): allow specifying custom Docker socket (#4772) * feat(endpoints/creation): override default socket path * fix(endpoints/creation): typo socketPath -> SocketPathpull/4909/head
parent
52d4296c08
commit
3dccc59048
|
@ -58,10 +58,20 @@ angular.module('portainer.app').factory('EndpointService', [
|
||||||
return Endpoints.remove({ id: endpointID }).$promise;
|
return Endpoints.remove({ id: endpointID }).$promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
service.createLocalEndpoint = function (name = 'local') {
|
service.createLocalEndpoint = function (name = 'local', URL = '', PublicURL = '', groupID = 1, tagIds = []) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
|
|
||||||
FileUploadService.createEndpoint(name, PortainerEndpointCreationTypes.LocalDockerEnvironment, '', '', 1, [], false)
|
var endpointURL = URL;
|
||||||
|
if (endpointURL !== '') {
|
||||||
|
if (endpointURL.indexOf('//./pipe/') == 0) {
|
||||||
|
// Windows named pipe
|
||||||
|
endpointURL = 'npipe://' + URL;
|
||||||
|
} else {
|
||||||
|
endpointURL = 'unix://' + URL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FileUploadService.createEndpoint(name, PortainerEndpointCreationTypes.LocalDockerEnvironment, endpointURL, PublicURL, groupID, tagIds, false)
|
||||||
.then(function success(response) {
|
.then(function success(response) {
|
||||||
deferred.resolve(response.data);
|
deferred.resolve(response.data);
|
||||||
})
|
})
|
||||||
|
|
|
@ -100,12 +100,18 @@ angular
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.addDockerEndpoint = function () {
|
$scope.addDockerEndpoint = function () {
|
||||||
|
var name = $scope.formValues.Name;
|
||||||
|
var URL = $filter('stripprotocol')($scope.formValues.URL);
|
||||||
|
var publicURL = $scope.formValues.PublicURL;
|
||||||
|
var groupId = $scope.formValues.GroupId;
|
||||||
|
var tagIds = $scope.formValues.TagIds;
|
||||||
|
|
||||||
if ($scope.formValues.ConnectSocket) {
|
if ($scope.formValues.ConnectSocket) {
|
||||||
var endpointName = $scope.formValues.Name;
|
URL = $scope.formValues.SocketPath;
|
||||||
$scope.state.actionInProgress = true;
|
$scope.state.actionInProgress = true;
|
||||||
EndpointService.createLocalEndpoint(endpointName)
|
EndpointService.createLocalEndpoint(name, URL, publicURL, groupId, tagIds)
|
||||||
.then(function success() {
|
.then(function success() {
|
||||||
Notifications.success('Endpoint created', endpointName);
|
Notifications.success('Endpoint created', name);
|
||||||
$state.go('portainer.endpoints', {}, { reload: true });
|
$state.go('portainer.endpoints', {}, { reload: true });
|
||||||
})
|
})
|
||||||
.catch(function error(err) {
|
.catch(function error(err) {
|
||||||
|
@ -115,11 +121,9 @@ angular
|
||||||
$scope.state.actionInProgress = false;
|
$scope.state.actionInProgress = false;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var name = $scope.formValues.Name;
|
if (publicURL === '') {
|
||||||
var URL = $filter('stripprotocol')($scope.formValues.URL);
|
publicURL = URL.split(':')[0];
|
||||||
var publicURL = $scope.formValues.PublicURL === '' ? URL.split(':')[0] : $scope.formValues.PublicURL;
|
}
|
||||||
var groupId = $scope.formValues.GroupId;
|
|
||||||
var tagIds = $scope.formValues.TagIds;
|
|
||||||
|
|
||||||
var securityData = $scope.formValues.SecurityFormData;
|
var securityData = $scope.formValues.SecurityFormData;
|
||||||
var TLS = securityData.TLS;
|
var TLS = securityData.TLS;
|
||||||
|
|
|
@ -210,6 +210,42 @@
|
||||||
<label class="switch" style="margin-left: 20px;"> <input type="checkbox" ng-model="formValues.ConnectSocket" /><i></i> </label>
|
<label class="switch" style="margin-left: 20px;"> <input type="checkbox" ng-model="formValues.ConnectSocket" /><i></i> </label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div ng-if="state.EnvironmentType === 'docker' && formValues.ConnectSocket">
|
||||||
|
<div class="form-group" style="padding-left: 15px;">
|
||||||
|
<label for="override_socket" class="col-sm_12 control-label text-left">
|
||||||
|
Override default socket path
|
||||||
|
</label>
|
||||||
|
<label class="switch" style="margin-left: 20px;"> <input type="checkbox" ng-model="formValues.OverrideSocket" /><i></i> </label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-if="formValues.OverrideSocket">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="socket_path" class="col-sm-3 col-lg-2 control-label text-left">
|
||||||
|
Socket path
|
||||||
|
<portainer-tooltip position="bottom" message="Path to the Docker socket. Remember to bind-mount the socket, see the important notice above for more information.">
|
||||||
|
</portainer-tooltip>
|
||||||
|
</label>
|
||||||
|
<div class="col-sm-9 col-lg-10">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
name="socket_path"
|
||||||
|
ng-model="formValues.SocketPath"
|
||||||
|
placeholder="e.g. /var/run/docker.sock (on Linux) or //./pipe/docker_engine (on Windows)"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group" ng-show="endpointCreationForm.socket_path.$invalid">
|
||||||
|
<div class="col-sm-12 small text-warning">
|
||||||
|
<div ng-messages="endpointCreationForm.socket_path.$error">
|
||||||
|
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field is required.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!-- !connect-via-socket-input -->
|
<!-- !connect-via-socket-input -->
|
||||||
<!-- endpoint-url-input -->
|
<!-- endpoint-url-input -->
|
||||||
<div ng-if="(state.EnvironmentType === 'docker' && !formValues.ConnectSocket) || state.EnvironmentType === 'agent'">
|
<div ng-if="(state.EnvironmentType === 'docker' && !formValues.ConnectSocket) || state.EnvironmentType === 'agent'">
|
||||||
|
@ -378,7 +414,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- !azure-details -->
|
<!-- !azure-details -->
|
||||||
<!-- endpoint-security -->
|
<!-- endpoint-security -->
|
||||||
<por-endpoint-security ng-if="state.EnvironmentType === 'docker'" form-data="formValues.SecurityFormData"></por-endpoint-security>
|
<por-endpoint-security ng-if="state.EnvironmentType === 'docker' && !formValues.ConnectSocket" form-data="formValues.SecurityFormData"></por-endpoint-security>
|
||||||
<!-- !endpoint-security -->
|
<!-- !endpoint-security -->
|
||||||
<div class="col-sm-12 form-section-title">
|
<div class="col-sm-12 form-section-title">
|
||||||
Metadata
|
Metadata
|
||||||
|
|
|
@ -173,7 +173,7 @@ function shell_run_container() {
|
||||||
'docker rm -f portainer',
|
'docker rm -f portainer',
|
||||||
'docker run -d -p 8000:8000 -p 9000:9000 -v $(pwd)/dist:/app -v ' +
|
'docker run -d -p 8000:8000 -p 9000:9000 -v $(pwd)/dist:/app -v ' +
|
||||||
portainer_data +
|
portainer_data +
|
||||||
':/data -v /var/run/docker.sock:/var/run/docker.sock:z -v /tmp:/tmp --name portainer portainer/base /app/portainer',
|
':/data -v /var/run/docker.sock:/var/run/docker.sock:z -v /var/run/docker.sock:/var/run/alternative.sock:z -v /tmp:/tmp --name portainer portainer/base /app/portainer',
|
||||||
].join(';');
|
].join(';');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue