Skip to content

Commit e1107da

Browse files
committed
Fix journal commands
1 parent 017527d commit e1107da

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

extensions/cli-ext-insight-journal/logger.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ export default new Command({
2828
],
2929
handler: async (opts) => {
3030
const optsAll = opts._all || opts;
31-
const log = await opts.api
31+
const logResp = await opts.api
3232
.get(openapi.getUrl(`/insight/pl-waw-1/project/${optsAll.project}/journal/${optsAll.journal}`));
33+
const log = logResp.bodyJson;
3334
const token = await opts.auth.getToken(log.fqdn);
3435
const logFile = optsAll['log-file'] == 'stdin' ? process.stdin : fs.createReadStream(optsAll['log-file']);
3536
const inStream = logFile

extensions/cli-ext-insight-journal/stream.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ export default new Command({
2828
],
2929
handler: async (opts) => {
3030
const optsAll = opts._all || opts;
31-
const log = await opts.api
31+
const logResp = await opts.api
3232
.get(openapi.getUrl(`/insight/pl-waw-1/project/${optsAll.project}/journal/${optsAll.journal}`));
33+
const log = logResp.bodyJson;
3334
const token = await opts.auth.getToken(log.fqdn);
3435

3536
const stream = await opts.http.get(`http://${log.fqdn}/log`, {
3637
headers: { authorization: `Bearer ${token}` },
3738
});
3839
let lines = 0;
39-
const logFile = optsAll['log-file'] == 'stdout' ? process.stdout : fs.createReadStream(optsAll['log-file']);
40+
const logFile = optsAll['log-file-output'] == 'stdout' ? process.stdout : fs.createWriteStream(optsAll['log-file-output']);
4041
return new Promise((resolve, reject) => stream.body
4142
.on('error', err => {
4243
logFile.close();

packages/cli-core/lib/auth.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,13 @@ export default ({ http, logger, config, passport, as, defaultAudience }) => {
8282

8383
if (as) {
8484
logger.debug(`Use delegate to switch actor to '${as}'`);
85-
const body = await exchange(access_token, {
86-
audience,
85+
const body = await exchange(audience, access_token, {
8786
resource: as,
8887
});
8988
return body.access_token;
9089
} else if (!passport && audience && defaultAudience !== audience) {
9190
logger.debug(`Update audience as '${audience}'`);
92-
const body = await exchange(access_token, {
93-
audience,
94-
});
91+
const body = await exchange(audience, access_token);
9592
return body.access_token;
9693
}
9794

0 commit comments

Comments
 (0)