Skip to content

Commit

Permalink
Merge pull request #317 from adobe/remove-client-side-validation
Browse files Browse the repository at this point in the history
Remove client side validation of Openwhisk flag limits
  • Loading branch information
MichaelGoberling authored Jul 20, 2023
2 parents ea0da26 + fc84b20 commit 223863f
Show file tree
Hide file tree
Showing 14 changed files with 10 additions and 199 deletions.
27 changes: 3 additions & 24 deletions src/commands/runtime/action/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,6 @@ ActionCreate.args = [
}
]

ActionCreate.limits = {
timeoutMs: {
min: 100,
max: 3600000
},
memoryMB: {
min: 128,
max: 4096
},
logsizeMB: {
min: 0,
max: 10
}
}

ActionCreate.flags = {
...RuntimeBaseCommand.flags,
param: Flags.string({
Expand Down Expand Up @@ -282,21 +267,15 @@ ActionCreate.flags = {
}),
timeout: Flags.integer({
char: 't',
description: `the timeout LIMIT in milliseconds after which the action is terminated (default 60000, min: ${ActionCreate.limits.timeoutMs.min}, max: ${ActionCreate.limits.timeoutMs.max})`, // help description for flag
min: ActionCreate.limits.timeoutMs.min,
max: ActionCreate.limits.timeoutMs.max
description: 'the timeout LIMIT in milliseconds after which the action is terminated (default 60000, min: 100, max: 3600000)' // help description for flag
}),
memory: Flags.integer({
char: 'm',
description: `the maximum memory LIMIT in MB for the action (default 256, min: ${ActionCreate.limits.memoryMB.min}, max: ${ActionCreate.limits.memoryMB.max})`, // help description for flag
min: ActionCreate.limits.memoryMB.min,
max: ActionCreate.limits.memoryMB.max
description: 'the maximum memory LIMIT in MB for the action (default 256, min: 128, max: 4096)' // help description for flag
}),
logsize: Flags.integer({
char: 'l',
description: `the maximum log size LIMIT in MB for the action (default 10, min: ${ActionCreate.limits.logsizeMB.min}, max: ${ActionCreate.limits.logsizeMB.max})`, // help description for flag
min: ActionCreate.limits.logsizeMB.min,
max: ActionCreate.limits.logsizeMB.max
description: 'the maximum log size LIMIT in MB for the action (default 10, min: 0, max: 10)' // help description for flag
}),
concurrency: Flags.integer({
char: 'c',
Expand Down
9 changes: 1 addition & 8 deletions src/commands/runtime/action/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,12 @@ ActionList.args = [
}
]

ActionList.limits = {
min: 0,
max: 50
}

ActionList.flags = {
...RuntimeBaseCommand.flags,
// example usage: aio runtime:action:list --limit 10 --skip 2
limit: Flags.integer({
char: 'l',
description: `only return LIMIT number of actions (min: ${ActionList.limits.min}, max: ${ActionList.limits.max})`,
min: ActionList.limits.min,
max: ActionList.limits.max
description: 'only return LIMIT number of actions (min: 0, max: 50)'
}),
skip: Flags.integer({
char: 's',
Expand Down
9 changes: 1 addition & 8 deletions src/commands/runtime/activation/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,12 @@ ActivationList.args = [
}
]

ActivationList.limits = {
min: 0,
max: 50
}

ActivationList.flags = {
...RuntimeBaseCommand.flags,
// example usage: aio runtime:activation:list --limit 10 --skip 2
limit: Flags.integer({
char: 'l',
description: `only return LIMIT number of activations (min: ${ActivationList.limits.min}, max: ${ActivationList.limits.max})`,
min: ActivationList.limits.min,
max: ActivationList.limits.max
description: 'only return LIMIT number of activations (min: 0, max: 50)'
}),
skip: Flags.integer({
char: 's',
Expand Down
11 changes: 2 additions & 9 deletions src/commands/runtime/activation/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ ActivationLogs.args = [
}
]

ActivationLogs.limits = {
min: 0,
max: 50
}

ActivationLogs.flags = {
...RuntimeBaseCommand.flags,
action: Flags.string({
Expand Down Expand Up @@ -129,10 +124,8 @@ ActivationLogs.flags = {
default: false
}),
limit: Flags.integer({
description: `return logs only from last LIMIT number of activations (min: ${ActivationLogs.limits.min}, max: ${ActivationLogs.limits.max})`,
exclusive: ['last'],
min: ActivationLogs.limits.min,
max: ActivationLogs.limits.max
description: 'return logs only from last LIMIT number of activations (min: 0, max: 50)',
exclusive: ['last']
}),
tail: Flags.boolean({
description: 'Fetch logs continuously',
Expand Down
9 changes: 1 addition & 8 deletions src/commands/runtime/package/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,13 @@ class PackageList extends RuntimeBaseCommand {
}
}

PackageList.limits = {
min: 0,
max: 50
}

PackageList.flags = {
...RuntimeBaseCommand.flags,
// example usage: aio runtime:package:list --limit 10 --skip 2
// aio runtime:package:list --count true OR aio runtime:package:list --count yes
limit: Flags.integer({
char: 'l',
description: `only return LIMIT number of packages (min: ${PackageList.limits.min}, max: ${PackageList.limits.max})`,
min: PackageList.limits.min,
max: PackageList.limits.max
description: 'only return LIMIT number of packages (min: 0, max: 50)'
}),
skip: Flags.integer({
char: 's',
Expand Down
9 changes: 1 addition & 8 deletions src/commands/runtime/rule/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,11 @@ class RuleList extends RuntimeBaseCommand {

RuleList.description = 'Retrieves a list of Rules'

RuleList.limits = {
min: 0,
max: 50
}

RuleList.flags = {
...RuntimeBaseCommand.flags,
limit: Flags.integer({
char: 'l',
description: `Limit number of rules returned (min: ${RuleList.limits.min}, max: ${RuleList.limits.max})`,
min: RuleList.limits.min,
max: RuleList.limits.max
description: 'Limit number of rules returned (min: 0, max: 50)'
}),
skip: Flags.integer({
char: 's',
Expand Down
9 changes: 1 addition & 8 deletions src/commands/runtime/trigger/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,11 @@ class TriggerList extends RuntimeBaseCommand {
}
}

TriggerList.limits = {
min: 0,
max: 50
}

TriggerList.flags = {
...RuntimeBaseCommand.flags,
limit: Flags.integer({
char: 'l',
description: `only return LIMIT number of triggers (min: ${TriggerList.limits.min}, max: ${TriggerList.limits.max})`,
min: TriggerList.limits.min,
max: TriggerList.limits.max,
description: 'only return LIMIT number of triggers (min: 0, max: 50)',
default: 30
}),
skip: Flags.integer({
Expand Down
42 changes: 0 additions & 42 deletions test/commands/runtime/action/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,48 +836,6 @@ describe('instance methods', () => {
await expect(rejectWithError(command, error, handleError)).toBeTruthy()
})

test('errors out on create with timeout below min', async () => {
const flag = '--timeout'
const invalidValue = '99'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer greater than or equal to 100 but received: ${invalidValue}\nSee more help with --help`)
})

test('errors out on create with timeout above max', async () => {
const flag = '--timeout'
const invalidValue = '3600001'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer less than or equal to 3600000 but received: ${invalidValue}\nSee more help with --help`)
})

test('errors out on create with memory below min', async () => {
const flag = '--memory'
const invalidValue = '127'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer greater than or equal to 128 but received: ${invalidValue}\nSee more help with --help`)
})

test('errors out on create with memory above max', async () => {
const flag = '--memory'
const invalidValue = '4097'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer less than or equal to 4096 but received: ${invalidValue}\nSee more help with --help`)
})

test('errors out on create with logsize below min', async () => {
const flag = '--logsize'
const invalidValue = '-1'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer greater than or equal to 0 but received: ${invalidValue}\nSee more help with --help`)
})

test('errors out on create with logsize above max', async () => {
const flag = '--logsize'
const invalidValue = '11'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer less than or equal to 10 but received: ${invalidValue}\nSee more help with --help`)
})

test('errors on --web-secure with --web false flag', async () => {
rtLib.mockRejected(rtAction, '')
command.argv = ['hello', '/action/fileWithNoExt', '--web-secure', 'true', '--web', 'false']
Expand Down
14 changes: 0 additions & 14 deletions test/commands/runtime/action/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,6 @@ describe('instance methods', () => {
expect(handleError).toHaveBeenLastCalledWith('failed to list the actions', new Error('an error'))
})

test('errors out on list with limit below min', async () => {
const flag = '--limit'
const invalidValue = '-1'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer greater than or equal to 0 but received: ${invalidValue}\nSee more help with --help`)
})

test('errors out on list with limit above max', async () => {
const flag = '--limit'
const invalidValue = '51'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer less than or equal to 50 but received: ${invalidValue}\nSee more help with --help`)
})

test('return list of actions with annotated kinds', () => {
const data = [
{
Expand Down
14 changes: 0 additions & 14 deletions test/commands/runtime/activation/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,20 +390,6 @@ describe('instance methods', () => {
expect(handleError).toHaveBeenLastCalledWith('failed to list the activations', new Error('an error'))
})

test('errors out on list with limit below min', async () => {
const flag = '--limit'
const invalidValue = '-1'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer greater than or equal to 0 but received: ${invalidValue}\nSee more help with --help`)
})

test('errors out on list with limit above max', async () => {
const flag = '--limit'
const invalidValue = '51'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer less than or equal to 50 but received: ${invalidValue}\nSee more help with --help`)
})

test('ignore activation without annotations', () => {
const data = [
{
Expand Down
14 changes: 0 additions & 14 deletions test/commands/runtime/activation/logs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,6 @@ describe('instance methods', () => {
expect(handleError).toHaveBeenCalledWith('failed to retrieve logs for activation', expect.any(Error))
})

test('errors out on list with limit below min', async () => {
const flag = '--limit'
const invalidValue = '-1'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer greater than or equal to 0 but received: ${invalidValue}\nSee more help with --help`)
})

test('errors out on list with limit above max', async () => {
const flag = '--limit'
const invalidValue = '51'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer less than or equal to 50 but received: ${invalidValue}\nSee more help with --help`)
})

test('retrieve last log (default)', () => {
command.argv = []
return command.run()
Expand Down
14 changes: 0 additions & 14 deletions test/commands/runtime/package/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,5 @@ describe('instance methods', () => {
expect(JSON.parse(stdout.output)).toEqual({ packages: 2 })
})
})

test('errors out on list with limit below min', async () => {
const flag = '--limit'
const invalidValue = '-1'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer greater than or equal to 0 but received: ${invalidValue}\nSee more help with --help`)
})

test('errors out on list with limit above max', async () => {
const flag = '--limit'
const invalidValue = '51'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer less than or equal to 50 but received: ${invalidValue}\nSee more help with --help`)
})
})
})
14 changes: 0 additions & 14 deletions test/commands/runtime/rule/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,5 @@ describe('instance methods', () => {
await expect(command.run()).rejects.toThrow(...error)
expect(handleError).toHaveBeenLastCalledWith(...error)
})

test('errors out on list with limit below min', async () => {
const flag = '--limit'
const invalidValue = '-1'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer greater than or equal to 0 but received: ${invalidValue}\nSee more help with --help`)
})

test('errors out on list with limit above max', async () => {
const flag = '--limit'
const invalidValue = '51'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer less than or equal to 50 but received: ${invalidValue}\nSee more help with --help`)
})
})
})
14 changes: 0 additions & 14 deletions test/commands/runtime/trigger/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,6 @@ describe('instance methods', () => {
expect(handleError).toHaveBeenLastCalledWith(...error)
})

test('errors out on list with limit below min', async () => {
const flag = '--limit'
const invalidValue = '-1'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer greater than or equal to 0 but received: ${invalidValue}\nSee more help with --help`)
})

test('errors out on list with limit above max', async () => {
const flag = '--limit'
const invalidValue = '51'
command.argv = [flag, invalidValue]
await expect(command.run()).rejects.toThrow(`Parsing ${flag} \n\tExpected an integer less than or equal to 50 but received: ${invalidValue}\nSee more help with --help`)
})

test('return list of triggers, --name-sort flag', () => {
const cmd = rtLib.mockResolvedFixture(rtAction, 'trigger/list-name-sort.json')
command.argv = ['--name']
Expand Down

0 comments on commit 223863f

Please sign in to comment.