Skip to content

Commit a34e72b

Browse files
rename tail-logs to tail-log (#40)
1 parent aabf455 commit a34e72b

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

src/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ class Client {
423423
return res.headers.get("content-length");
424424
}
425425

426-
async tailLogs(programId, environmentId, service, name, writeStream) {
426+
async tailLog(programId, environmentId, service, name, writeStream) {
427427
let environments = await this.listEnvironments(programId)
428428
let environment = environments.find(e => e.id === environmentId);
429429
if (!environment) {
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ const { getApiKey, getOrgId, getProgramId } = require('../../cloudmanager-helper
1616
const Client = require('../../client')
1717
const commonFlags = require('../../common-flags')
1818

19-
async function _tailLogs(programId, environmentId, service, logName, passphrase) {
19+
async function _tailLog(programId, environmentId, service, logName, passphrase) {
2020
const apiKey = await getApiKey()
2121
const accessToken = await getAccessToken(passphrase)
2222
const orgId = await getOrgId()
23-
await new Client(orgId, accessToken, apiKey).tailLogs(programId, environmentId, service, logName, process.stdout)
23+
await new Client(orgId, accessToken, apiKey).tailLog(programId, environmentId, service, logName, process.stdout)
2424
}
2525

26-
class TailLogs extends Command {
26+
class TailLog extends Command {
2727
async run() {
28-
const { args, flags } = this.parse(TailLogs)
28+
const { args, flags } = this.parse(TailLog)
2929

3030
const programId = await getProgramId(flags)
3131

3232
let result
3333

3434
try {
35-
result = await this.tailLogs(programId, args.environmentId, args.service, args.name, flags.passphrase)
35+
result = await this.tailLog(programId, args.environmentId, args.service, args.name, flags.passphrase)
3636
} catch (error) {
3737
this.error(error.message)
3838
}
@@ -42,22 +42,24 @@ class TailLogs extends Command {
4242
return result
4343
}
4444

45-
async tailLogs(programId, environmentId, service, name, passphrase = null) {
46-
return _tailLogs(programId, environmentId, service, name, passphrase)
45+
async tailLog(programId, environmentId, service, name, passphrase = null) {
46+
return _tailLog(programId, environmentId, service, name, passphrase)
4747
}
4848
}
4949

50-
TailLogs.description = 'lists available logs for an environment in a Cloud Manager program'
50+
TailLog.description = 'lists available logs for an environment in a Cloud Manager program'
5151

52-
TailLogs.args = [
52+
TailLog.args = [
5353
{name: 'environmentId', required: true, description: "the environment id"},
5454
{name: 'service', required: true, description: "the service"},
5555
{name: 'name', required: true, description: "the log name"}
5656
]
5757

58-
TailLogs.flags = {
58+
TailLog.flags = {
5959
...commonFlags.global,
6060
...commonFlags.programId
6161
}
6262

63-
module.exports = TailLogs
63+
TailLog.aliases = ['cloudmanager:tail-logs']
64+
65+
module.exports = TailLog

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const GetExecutionStepDetails = require('./commands/cloudmanager/get-execution-s
2424
const GetExecutionStepLog = require('./commands/cloudmanager/get-execution-step-log')
2525
const ListAvailableLogOptions = require('./commands/cloudmanager/list-available-log-options')
2626
const DownloadLogs = require('./commands/cloudmanager/download-logs')
27-
const TailLogs = require('./commands/cloudmanager/tail-logs')
27+
const TailLog = require('./commands/cloudmanager/tail-log')
2828

2929
module.exports = {
3030
'aaa': CloudManagerCommand, // needs to be first alphabetically
@@ -41,5 +41,5 @@ module.exports = {
4141
'get-execution-step-log': new GetExecutionStepLog().getExecutionStepLog,
4242
'list-available-log-options': new ListAvailableLogOptions().listAvailableLogOptions,
4343
'download-logs': new DownloadLogs().downloadLogs,
44-
'tail-logs': new TailLogs().tailLogs
44+
'tail-log': new TailLog().tailLog
4545
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,30 @@ governing permissions and limitations under the License.
1111
*/
1212

1313
const { setStore } = require('@adobe/aio-cna-core-config')
14-
const TailLogs = require('../../src/commands/cloudmanager/tail-logs')
14+
const TailLog = require('../../src/commands/cloudmanager/tail-log')
1515
const Client = require('../../src/client')
1616

1717
beforeEach(() => {
1818
setStore({})
1919
})
2020

21-
test('tail-logs - missing arg', async () => {
21+
test('tail-log - missing arg', async () => {
2222
expect.assertions(2)
2323

24-
let runResult = TailLogs.run([])
24+
let runResult = TailLog.run([])
2525
await expect(runResult instanceof Promise).toBeTruthy()
2626
await expect(runResult).rejects.toSatisfy(err => err.message.indexOf("Missing 3 required args") === 0)
2727
})
2828

29-
test('tail-logs - missing config', async () => {
29+
test('tail-log - missing config', async () => {
3030
expect.assertions(2)
3131

32-
let runResult = TailLogs.run(["5", "author", "aemerror", "--programId", "5"])
32+
let runResult = TailLog.run(["5", "author", "aemerror", "--programId", "5"])
3333
await expect(runResult instanceof Promise).toBeTruthy()
3434
await expect(runResult).rejects.toEqual(new Error('missing config data: jwt-auth'))
3535
})
3636

37-
test('tail-logs - failure', async () => {
37+
test('tail-log - failure', async () => {
3838
setStore({
3939
'jwt-auth': JSON.stringify({
4040
client_id: '1234',
@@ -46,12 +46,12 @@ test('tail-logs - failure', async () => {
4646

4747
expect.assertions(2)
4848

49-
let runResult = TailLogs.run(["17", "author", "aemerror", "--programId", "5"])
49+
let runResult = TailLog.run(["17", "author", "aemerror", "--programId", "5"])
5050
await expect(runResult instanceof Promise).toBeTruthy()
5151
await expect(runResult).rejects.toEqual(new Error('Could not find environment 17 for program 5'))
5252
})
5353

54-
test('tail-logs - no logs for tailing', async () => {
54+
test('tail-log - no logs for tailing', async () => {
5555
setStore({
5656
'jwt-auth': JSON.stringify({
5757
client_id: '1234',
@@ -63,7 +63,7 @@ test('tail-logs - no logs for tailing', async () => {
6363

6464
expect.assertions(2)
6565

66-
let runResult = TailLogs.run(["1", "publish", "aemerror", "--programId", "4"])
66+
let runResult = TailLog.run(["1", "publish", "aemerror", "--programId", "4"])
6767
await expect(runResult instanceof Promise).toBeTruthy()
6868
await expect(runResult).rejects.toEqual(new Error('No logs for tailing available in 1 for program 4'))
6969
})

0 commit comments

Comments
 (0)