mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-19 05:37:51 +00:00
Use DOCKER_HOST from env if possible, and no connection options are available
Connects-to: #625 Change-Type: patch
This commit is contained in:
parent
e8c4a9abfd
commit
2bbd45e867
@ -68,8 +68,9 @@ exports.appendOptions = function(opts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.generateConnectOpts = generateConnectOpts = function(opts) {
|
exports.generateConnectOpts = generateConnectOpts = function(opts) {
|
||||||
var Promise, _, fs;
|
var Promise, _, buildDockerodeOpts, fs;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
|
buildDockerodeOpts = require('dockerode-options');
|
||||||
fs = require('mz/fs');
|
fs = require('mz/fs');
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
return Promise["try"](function() {
|
return Promise["try"](function() {
|
||||||
@ -82,6 +83,8 @@ exports.generateConnectOpts = generateConnectOpts = function(opts) {
|
|||||||
connectOpts.port = opts.dockerPort || 2376;
|
connectOpts.port = opts.dockerPort || 2376;
|
||||||
} else if ((opts.docker != null) && (opts.dockerHost != null)) {
|
} else if ((opts.docker != null) && (opts.dockerHost != null)) {
|
||||||
throw new Error("Both a local docker socket and docker host have been provided. Don't know how to continue.");
|
throw new Error("Both a local docker socket and docker host have been provided. Don't know how to continue.");
|
||||||
|
} else if (process.env.DOCKER_HOST) {
|
||||||
|
connectOpts = buildDockerodeOpts(process.env.DOCKER_HOST);
|
||||||
} else {
|
} else {
|
||||||
connectOpts.socketPath = '/var/run/docker.sock';
|
connectOpts.socketPath = '/var/run/docker.sock';
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,7 @@ exports.appendOptions = (opts) ->
|
|||||||
|
|
||||||
exports.generateConnectOpts = generateConnectOpts = (opts) ->
|
exports.generateConnectOpts = generateConnectOpts = (opts) ->
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
|
buildDockerodeOpts = require('dockerode-options')
|
||||||
fs = require('mz/fs')
|
fs = require('mz/fs')
|
||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
|
|
||||||
@ -103,8 +104,11 @@ exports.generateConnectOpts = generateConnectOpts = (opts) ->
|
|||||||
else if opts.docker? and opts.dockerHost?
|
else if opts.docker? and opts.dockerHost?
|
||||||
# Both provided, no obvious way to continue
|
# Both provided, no obvious way to continue
|
||||||
throw new Error("Both a local docker socket and docker host have been provided. Don't know how to continue.")
|
throw new Error("Both a local docker socket and docker host have been provided. Don't know how to continue.")
|
||||||
|
else if process.env.DOCKER_HOST
|
||||||
|
# If no explicit options are provided, use the env
|
||||||
|
connectOpts = buildDockerodeOpts(process.env.DOCKER_HOST)
|
||||||
else
|
else
|
||||||
# None provided, assume default docker local socket
|
# No options anywhere, assume default docker local socket
|
||||||
connectOpts.socketPath = '/var/run/docker.sock'
|
connectOpts.socketPath = '/var/run/docker.sock'
|
||||||
|
|
||||||
# Now need to check if the user wants to connect over TLS
|
# Now need to check if the user wants to connect over TLS
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
"docker-qemu-transpose": "^0.2.2",
|
"docker-qemu-transpose": "^0.2.2",
|
||||||
"docker-toolbelt": "^1.3.3",
|
"docker-toolbelt": "^1.3.3",
|
||||||
"dockerode": "^2.5.0",
|
"dockerode": "^2.5.0",
|
||||||
|
"dockerode-options": "^0.2.1",
|
||||||
"drivelist": "^5.0.22",
|
"drivelist": "^5.0.22",
|
||||||
"etcher-image-write": "^9.0.3",
|
"etcher-image-write": "^9.0.3",
|
||||||
"global-tunnel-ng": "github:zvin/global-tunnel#dont-proxy-connections-to-file-sockets",
|
"global-tunnel-ng": "github:zvin/global-tunnel#dont-proxy-connections-to-file-sockets",
|
||||||
|
Loading…
Reference in New Issue
Block a user