proxy support

This commit is contained in:
Eugene Mirotin 2017-04-26 16:16:06 +03:00
parent 1d8382e91d
commit 8866f47805
7 changed files with 152 additions and 111 deletions

View File

@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
var Promise, Raven, _, actions, capitano, capitanoExecuteAsync, errors, events, plugins, resin, update; var Promise, Raven, _, actions, capitano, capitanoExecuteAsync, errors, events, globalTunnel, plugins, proxy, resin, settings, update;
Raven = require('raven'); Raven = require('raven');
@ -29,6 +29,18 @@ Raven.config(require('./config').sentryDsn, {
return process.exit(1); return process.exit(1);
}); });
globalTunnel = require('global-tunnel-ng');
settings = require('resin-settings-client');
try {
proxy = settings.get('proxy') || null;
} catch (error1) {
proxy = null;
}
globalTunnel.initialize(proxy);
_ = require('lodash'); _ = require('lodash');
Promise = require('bluebird'); Promise = require('bluebird');

107
capitanodoc.coffee Normal file
View File

@ -0,0 +1,107 @@
# coffeelint: disable=max_line_length
module.exports =
title: 'Resin CLI Documentation'
introduction: '''
This tool allows you to interact with the resin.io api from the comfort of your command line.
Please make sure your system meets the requirements as specified in the [README](https://github.com/resin-io/resin-cli).
To get started download the CLI from npm.
$ npm install resin-cli -g
Then authenticate yourself:
$ resin login
Now you have access to all the commands referenced below.
## Proxy support
The CLI does support HTTP(S) proxies.
You can configure the proxy using several methods (in order of their precedence):
* set the `RESINRC_PROXY` environment variable in the URL format (with protocol, host, port, and optionally the basic auth),
* use the [resin config file](https://www.npmjs.com/package/resin-settings-client#documentation) (project-specific or user-level)
and set the `proxy` setting. This can be:
* a string in the URL format,
* or an object following [this format](https://www.npmjs.com/package/global-tunnel-ng#options), which allows more control,
* or set the conventional `https_proxy` / `HTTPS_PROXY` / `http_proxy` / `HTTP_PROXY`
environment variable (in the same standard URL format).
'''
categories: [
{
title: 'Application'
files: [ 'lib/actions/app.coffee' ]
},
{
title: 'Authentication',
files: [ 'lib/actions/auth.coffee' ]
},
{
title: 'Device',
files: [ 'lib/actions/device.coffee' ]
},
{
title: 'Environment Variables',
files: [ 'lib/actions/environment-variables.coffee' ]
},
{
title: 'Help',
files: [ 'lib/actions/help.coffee' ]
},
{
title: 'Information',
files: [ 'lib/actions/info.coffee' ]
},
{
title: 'Keys',
files: [ 'lib/actions/keys.coffee' ]
},
{
title: 'Logs',
files: [ 'lib/actions/logs.coffee' ]
},
{
title: 'Sync',
files: [ 'lib/actions/sync.coffee' ]
},
{
title: 'SSH',
files: [ 'lib/actions/ssh.coffee' ]
},
{
title: 'Notes',
files: [ 'lib/actions/notes.coffee' ]
},
{
title: 'OS',
files: [ 'lib/actions/os.coffee' ]
},
{
title: 'Config',
files: [ 'lib/actions/config.coffee' ]
},
{
title: 'Settings',
files: [ 'lib/actions/settings.coffee' ]
},
{
title: 'Wizard',
files: [ 'lib/actions/wizard.coffee' ]
},
{
title: 'Local',
files: [ 'lib/actions/local/index.coffee' ]
},
{
title: 'Deploy',
files: [
'lib/actions/build.coffee'
'lib/actions/deploy.coffee'
]
}
]

View File

@ -1,109 +0,0 @@
{
"title": "Resin CLI Documentation",
"introduction": "This tool allows you to interact with the resin.io api from the comfort of your command line.\n\nPlease make sure your system meets the requirements as specified in the [README](https://github.com/resin-io/resin-cli).\n\nTo get started download the CLI from npm.\n\n\t$ npm install resin-cli -g\n\nThen authenticate yourself:\n\n\t$ resin login\n\nNow you have access to all the commands referenced below.",
"categories": [
{
"title": "Application",
"files": [
"lib/actions/app.coffee"
]
},
{
"title": "Authentication",
"files": [
"lib/actions/auth.coffee"
]
},
{
"title": "Device",
"files": [
"lib/actions/device.coffee"
]
},
{
"title": "Environment Variables",
"files": [
"lib/actions/environment-variables.coffee"
]
},
{
"title": "Help",
"files": [
"lib/actions/help.coffee"
]
},
{
"title": "Information",
"files": [
"lib/actions/info.coffee"
]
},
{
"title": "Keys",
"files": [
"lib/actions/keys.coffee"
]
},
{
"title": "Logs",
"files": [
"lib/actions/logs.coffee"
]
},
{
"title": "Sync",
"files": [
"lib/actions/sync.coffee"
]
},
{
"title": "SSH",
"files": [
"lib/actions/ssh.coffee"
]
},
{
"title": "Notes",
"files": [
"lib/actions/notes.coffee"
]
},
{
"title": "OS",
"files": [
"lib/actions/os.coffee"
]
},
{
"title": "Config",
"files": [
"lib/actions/config.coffee"
]
},
{
"title": "Settings",
"files": [
"lib/actions/settings.coffee"
]
},
{
"title": "Wizard",
"files": [
"lib/actions/wizard.coffee"
]
},
{
"title": "Local",
"files": [
"lib/actions/local/index.coffee"
]
},
{
"title": "Deploy",
"files": [
"lib/actions/build.coffee",
"lib/actions/deploy.coffee"
]
}
]
}

View File

@ -14,6 +14,20 @@ Then authenticate yourself:
Now you have access to all the commands referenced below. Now you have access to all the commands referenced below.
## Proxy support
The CLI does support HTTP(S) proxies.
You can configure the proxy using several methods (in order of their precedence):
* set the `RESINRC_PROXY` environment variable in the URL format (with protocol, host, port, and optionally the basic auth),
* use the [resin config file](https://www.npmjs.com/package/resin-settings-client#documentation) (project-specific or user-level)
and set the `proxy` setting. This can be:
* a string in the URL format,
* or an object following [this format](https://www.npmjs.com/package/global-tunnel-ng#options), which allows more control,
* or set the conventional `https_proxy` / `HTTPS_PROXY` / `http_proxy` / `HTTP_PROXY`
environment variable (in the same standard URL format).
# Table of contents # Table of contents
- Application - Application

View File

@ -1,6 +1,6 @@
_ = require('lodash') _ = require('lodash')
path = require('path') path = require('path')
capitanodoc = require('../../capitanodoc.json') capitanodoc = require('../../capitanodoc')
markdown = require('./markdown') markdown = require('./markdown')
result = {} result = {}

View File

@ -23,6 +23,21 @@ Raven.config require('./config').sentryDsn,
console.error(error) console.error(error)
process.exit(1) process.exit(1)
# Doing this before requiring any other modules,
# including the 'resin-sdk', to prevent any module from reading the http proxy config
# before us
globalTunnel = require('global-tunnel-ng')
settings = require('resin-settings-client')
try
proxy = settings.get('proxy') or null
catch
proxy = null
# Init the tunnel even if the proxy is not configured
# because it can also get the proxy from the http(s)_proxy env var
# If that is not set as well the initialize will do nothing
globalTunnel.initialize(proxy)
_ = require('lodash') _ = require('lodash')
Promise = require('bluebird') Promise = require('bluebird')
capitano = require('capitano') capitano = require('capitano')

View File

@ -47,6 +47,7 @@
"dockerode": "^2.4.2", "dockerode": "^2.4.2",
"drivelist": "^5.0.16", "drivelist": "^5.0.16",
"etcher-image-write": "^9.0.3", "etcher-image-write": "^9.0.3",
"global-tunnel-ng": "^2.0.0",
"inquirer": "^3.0.6", "inquirer": "^3.0.6",
"is-root": "^1.0.0", "is-root": "^1.0.0",
"js-yaml": "^3.7.0", "js-yaml": "^3.7.0",
@ -73,6 +74,7 @@
"resin-image-fs": "^2.1.2", "resin-image-fs": "^2.1.2",
"resin-image-manager": "^4.1.1", "resin-image-manager": "^4.1.1",
"resin-sdk-preconfigured": "^6.0.0", "resin-sdk-preconfigured": "^6.0.0",
"resin-settings-client": "^3.6.1",
"resin-stream-logger": "^0.0.4", "resin-stream-logger": "^0.0.4",
"resin-sync": "^7.0.0", "resin-sync": "^7.0.0",
"rimraf": "^2.4.3", "rimraf": "^2.4.3",