parent
666b541e42
commit
54923c9ae3
@ -2,7 +2,9 @@
|
||||
|
||||
## 4.4.1 (not yet released)
|
||||
|
||||
(nothing yet)
|
||||
- #83, #84 Fix running `triton` on Windows.
|
||||
Note: Triton config is stored in "%APPDATA%/Joyent/Triton/..." on Windows,
|
||||
"~/.triton/..." on other platforms.
|
||||
|
||||
|
||||
## 4.4.0
|
||||
|
@ -64,7 +64,8 @@ for example:
|
||||
Install Bash completion with
|
||||
|
||||
```bash
|
||||
triton completion > /usr/local/etc/bash_completion.d/triton
|
||||
triton completion > /usr/local/etc/bash_completion.d/triton # Mac
|
||||
triton completion > /etc/bash_completion.d/triton # Linux
|
||||
```
|
||||
|
||||
Alternatively, if you don't have or don't want to use a "bash\_completion.d"
|
||||
@ -258,7 +259,7 @@ A basic example:
|
||||
|
||||
This section defines all the vars in a TritonApi config. The baked in defaults
|
||||
are in "etc/defaults.json" and can be overriden for the CLI in
|
||||
"~/.triton/config.json".
|
||||
"~/.triton/config.json" (on Windows: "%APPDATA%/Joyent/Triton/config.json").
|
||||
|
||||
| Name | Description |
|
||||
| ---- | ----------- |
|
||||
|
18
lib/cli.js
18
lib/cli.js
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2015 Joyent, Inc.
|
||||
* Copyright 2016 Joyent, Inc.
|
||||
*
|
||||
* The `triton` CLI class.
|
||||
*/
|
||||
@ -34,7 +34,21 @@ var tritonapi = require('./tritonapi');
|
||||
|
||||
var pkg = require('../package.json');
|
||||
|
||||
var CONFIG_DIR = path.resolve(process.env.HOME, '.triton');
|
||||
var CONFIG_DIR;
|
||||
if (process.platform === 'win32') {
|
||||
/*
|
||||
* For better or worse we are using APPDATA (i.e. the *Roaming* AppData
|
||||
* dir) over LOCALAPPDATA (non-roaming). The former is meant for "user"
|
||||
* data, the latter for "machine" data.
|
||||
*
|
||||
* TODO: We should likely separate out the *cache* subdir to
|
||||
* machine-specific data dir.
|
||||
*/
|
||||
CONFIG_DIR = path.resolve(process.env.APPDATA, 'Joyent', 'Triton');
|
||||
} else {
|
||||
CONFIG_DIR = path.resolve(process.env.HOME, '.triton');
|
||||
}
|
||||
|
||||
|
||||
var OPTIONS = [
|
||||
{
|
||||
|
@ -855,19 +855,24 @@ function deepEqual(a, b) {
|
||||
/**
|
||||
* Resolve "~/..." and "~" to an absolute path.
|
||||
*
|
||||
* Limitations: This does not handle "~user/...". This depends on the HOME
|
||||
* envvar being defined. A better alternative is the "tilde-expansion"
|
||||
* module (used elsewhere in node-triton), but that doesn't have a sync
|
||||
* option.
|
||||
* Limitations:
|
||||
* - This does not handle "~user/...".
|
||||
* - This depends on the HOME envvar being defined (%USERPROFILE% on Windows).
|
||||
*/
|
||||
function tildeSync(s) {
|
||||
var home = process.env.HOME;
|
||||
var envvar = (process.platform === 'win32' ? 'USERPROFILE' : 'HOME');
|
||||
var home = process.env[envvar];
|
||||
if (!home) {
|
||||
return s;
|
||||
} else if (s === '~') {
|
||||
throw new Error(format('cannot determine home dir: %s environment ' +
|
||||
'variable is not defined', envvar));
|
||||
}
|
||||
|
||||
if (s === '~') {
|
||||
return home;
|
||||
} else if (s.slice(0, 2) === '~/') {
|
||||
return home + s.slice(1);
|
||||
} else if (s.slice(0, 2) === '~/' ||
|
||||
(process.platform === 'win32' && s.slice(0, 2) === '~'+path.sep))
|
||||
{
|
||||
return path.resolve(home, s.slice(2));
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ var format = require('util').format;
|
||||
var fs = require('fs');
|
||||
var strsplit = require('strsplit');
|
||||
var sshpk = require('sshpk');
|
||||
var tilde = require('tilde-expansion');
|
||||
var vasync = require('vasync');
|
||||
|
||||
var common = require('./common');
|
||||
|
@ -15,7 +15,6 @@ var format = require('util').format;
|
||||
var fs = require('fs');
|
||||
var strsplit = require('strsplit');
|
||||
var tabula = require('tabula');
|
||||
var tilde = require('tilde-expansion');
|
||||
var vasync = require('vasync');
|
||||
|
||||
var common = require('../common');
|
||||
|
@ -8,7 +8,6 @@ var assert = require('assert-plus');
|
||||
var format = require('util').format;
|
||||
var fs = require('fs');
|
||||
var sshpk = require('sshpk');
|
||||
var tilde = require('tilde-expansion');
|
||||
var vasync = require('vasync');
|
||||
|
||||
var common = require('../common');
|
||||
@ -168,7 +167,7 @@ function _createProfile(opts, cb) {
|
||||
}
|
||||
|
||||
// Try as a local path.
|
||||
tilde(value, function (keyPath) {
|
||||
var keyPath = common.tildeSync(value);
|
||||
fs.stat(keyPath, function (statErr, stats) {
|
||||
if (statErr || !stats.isFile()) {
|
||||
return valCb(new Error(format(
|
||||
@ -192,7 +191,6 @@ function _createProfile(opts, cb) {
|
||||
valCb(null, newVal);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
} ];
|
||||
|
||||
|
@ -9,7 +9,6 @@ var format = require('util').format;
|
||||
var fs = require('fs');
|
||||
var strsplit = require('strsplit');
|
||||
var sshpk = require('sshpk');
|
||||
var tilde = require('tilde-expansion');
|
||||
var vasync = require('vasync');
|
||||
|
||||
var common = require('../common');
|
||||
|
@ -14,9 +14,9 @@ var assert = require('assert-plus');
|
||||
var format = require('util').format;
|
||||
var fs = require('fs');
|
||||
var strsplit = require('strsplit');
|
||||
var tilde = require('tilde-expansion');
|
||||
var vasync = require('vasync');
|
||||
|
||||
var common = require('./common');
|
||||
var errors = require('./errors');
|
||||
|
||||
|
||||
@ -184,7 +184,7 @@ function _addMetadataFromJsonStr(ilk, metadata, s, from, cb) {
|
||||
|
||||
function _addMetadataFromFile(ilk, metadata, file, cb) {
|
||||
assert.string(ilk, 'ilk');
|
||||
tilde(file, function (metaPath) {
|
||||
var metaPath = common.tildeSync(file);
|
||||
fs.stat(metaPath, function (statErr, stats) {
|
||||
if (statErr || !stats.isFile()) {
|
||||
cb(new errors.TritonError(format(
|
||||
@ -217,7 +217,6 @@ function _addMetadataFromFile(ilk, metadata, file, cb) {
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function _addMetadataFromKvStr(ilk, metadata, s, from, cb) {
|
||||
@ -266,7 +265,7 @@ function _addMetadataFromKfStr(ilk, metadata, s, from, cb) {
|
||||
function _addMetadatumFromFile(ilk, metadata, key, file, from, cb) {
|
||||
assert.string(ilk, 'ilk');
|
||||
|
||||
tilde(file, function (filePath) {
|
||||
var filePath = common.tildeSync(file);
|
||||
fs.stat(filePath, function (statErr, stats) {
|
||||
if (statErr || !stats.isFile()) {
|
||||
cb(new errors.TritonError(format(
|
||||
@ -281,7 +280,6 @@ function _addMetadatumFromFile(ilk, metadata, key, file, from, cb) {
|
||||
_addMetadatum(ilk, metadata, key, content, from, cb);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
10
lib/rbac.js
10
lib/rbac.js
@ -17,7 +17,6 @@ var mkdirp = require('mkdirp');
|
||||
var path = require('path');
|
||||
var rimraf = require('rimraf');
|
||||
var sshpk = require('sshpk');
|
||||
var tilde = require('tilde-expansion');
|
||||
var vasync = require('vasync');
|
||||
|
||||
var common = require('./common');
|
||||
@ -785,14 +784,13 @@ function executeRbacUpdatePlan(ctx, cb) {
|
||||
c.user);
|
||||
vasync.pipeline({arg: {}, funcs: [
|
||||
function vars(ctx2, next2) {
|
||||
tilde('~', function (s) {
|
||||
ctx2.homeDir = s;
|
||||
ctx2.homeDir = common.tildeSync('~');
|
||||
ctx2.keyName = format('%s user %s',
|
||||
c.currProfile.name, c.user);
|
||||
ctx2.keyPath = format('%s/.ssh/%s-user-%s.id_rsa',
|
||||
ctx2.homeDir, c.currProfile.name, c.user);
|
||||
ctx2.keyPath = path.resolve(ctx2.homeDir, '.ssh',
|
||||
format('%s-user-%s.id_rsa',
|
||||
c.currProfile.name, c.user));
|
||||
next2();
|
||||
});
|
||||
},
|
||||
function rmOldPrivKey(ctx2, next2) {
|
||||
rimraf(ctx2.keyPath, next2);
|
||||
|
@ -22,7 +22,6 @@
|
||||
"smartdc-auth": "2.2.3",
|
||||
"strsplit": "1.0.0",
|
||||
"tabula": "1.7.0",
|
||||
"tilde-expansion": "0.0.0",
|
||||
"vasync": "1.6.3",
|
||||
"verror": "1.6.0",
|
||||
"wordwrap": "1.0.0"
|
||||
|
Reference in New Issue
Block a user