Merge pull request #483 from hashicorp/chore-support-cli-json-updates

chore: 🤖 support api_errors and drop errors format flag
This commit is contained in:
Susmitha Girumala authored and GitHub committed 2021-03-05 10:32:48 -05:00
commit 24bbaeb6ad
2 files changed
+9 -4

No files matched your search

+5 -2
View File
@@ -18,8 +18,10 @@ const escapeAndValidateBase62 = (str) => {
};
module.exports = {
// Check boundary cli existence
exists: () => Boolean(cliPath()),
// Initiate connection and return output
connect: (target_id, token, host_id) => {
const addr = origin.origin;
@@ -33,13 +35,13 @@ module.exports = {
`-target-id=${sanitized.target_id}`,
`-token=${sanitized.token}`,
`-addr=${addr}`,
'-format=json',
'--output-json-errors'
'-format=json'
];
if (host_id) command.push(`-host-id=${sanitized.host_id}`)
return spawnAsyncJSONPromise(command);
},
// Returns JSON-formatted version information from the CLI
version: () => {
const command = [ '-v' ];
@@ -54,4 +56,5 @@ module.exports = {
return { gitRevision, versionNumber, formatted };
return rawOutput;
}
}
+4 -2
View File
@@ -52,8 +52,10 @@ module.exports = {
childProcess.stderr.on('data', (data) => {
errorStream += data.toString();
const jsonData = jsonify(errorStream);
const error = jsonData ? jsonData.error : undefined;
if (jsonData) reject(new Error(error));
if (jsonData) {
const error = jsonData.api_error || jsonData.error;
reject(new Error(error));
}
});
});
},