Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config Schema: Revert invalid "oneOf" based validation #8376

Merged
merged 1 commit into from Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions lib/plugins/aws/package/compile/events/cloudWatchEvent/index.js
Expand Up @@ -35,12 +35,6 @@ class AwsCompileCloudWatchEventEvents {
name: { type: 'string', pattern: '[a-zA-Z0-9-_.]+', minLength: 1, maxLength: 64 },
enabled: { type: 'boolean' },
},
oneOf: [
{ required: ['input'] },
{ required: ['inputPath'] },
{ required: ['inputTransformer'] },
{ required: [] },
],
additionalProperties: false,
});
}
Expand Down Expand Up @@ -69,6 +63,16 @@ class AwsCompileCloudWatchEventEvents {
Input = event.cloudwatchEvent.input;
InputTransformer = event.cloudwatchEvent.inputTransformer;

if ([Input, InputPath, InputTransformer].filter(Boolean).length > 1) {
throw new this.serverless.classes.Error(
[
'You can only set one of input, inputPath, or inputTransformer ',
'properties at the same time for cloudwatch events. ',
'Please check the AWS docs for more info',
].join('')
);
}

if (Input && typeof Input === 'object') {
Input = JSON.stringify(Input);
}
Expand Down
21 changes: 10 additions & 11 deletions lib/plugins/aws/package/compile/events/eventBridge/index.js
Expand Up @@ -49,17 +49,7 @@ class AwsCompileEventBridgeEvents {
additionalProperties: false,
},
},
allOf: [
{ anyOf: [{ required: ['pattern'] }, { required: ['schedule'] }] },
{
oneOf: [
{ required: [] },
{ required: ['input'] },
{ required: ['inputPath'] },
{ required: ['inputTransformer'] },
],
},
],
anyOf: [{ required: ['pattern'] }, { required: ['schedule'] }],
});
}

Expand Down Expand Up @@ -105,6 +95,15 @@ class AwsCompileEventBridgeEvents {
idx
);

if ([Input, InputPath, InputTransformer].filter(Boolean).length > 1) {
throw new this.serverless.classes.Error(
[
'You can only set one of input, inputPath, or inputTransformer ',
'properties for eventBridge events.',
].join('')
);
}

if (InputTransformer) {
InputTransformer = _.mapKeys(
InputTransformer,
Expand Down
5 changes: 0 additions & 5 deletions lib/plugins/aws/provider/awsProvider.js
Expand Up @@ -555,11 +555,6 @@ class AwsProvider {
role: { $ref: '#/definitions/awsArn' },
roleManagedExternally: { type: 'boolean' },
},
oneOf: [
{ required: [] },
{ required: ['role'] },
{ required: ['roleManagedExternally'] },
],
additionalProperties: false,
},
],
Expand Down