From e028f5e26987e8e9161e93492a3dde646de46fd7 Mon Sep 17 00:00:00 2001 From: Mariusz Nowak Date: Tue, 15 Sep 2020 18:02:45 +0200 Subject: [PATCH] refactor(Config Schema): List properties in alphabetical order --- lib/plugins/aws/provider/awsProvider.js | 85 ++++++++++++------------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/lib/plugins/aws/provider/awsProvider.js b/lib/plugins/aws/provider/awsProvider.js index 0cd59925b4f..7afb978bd81 100644 --- a/lib/plugins/aws/provider/awsProvider.js +++ b/lib/plugins/aws/provider/awsProvider.js @@ -141,18 +141,15 @@ class AwsProvider { // TODO: Complete schema, see https://github.com/serverless/serverless/issues/8016 serverless.configSchemaHandler.defineProvider('aws', { definitions: { - awsArnString: { - type: 'string', - pattern: '^arn:', - }, awsArn: { oneOf: [ { $ref: '#/definitions/awsArnString' }, { $ref: '#/definitions/awsCfFunction' }, ], }, - awsCfInstruction: { - oneOf: [{ type: 'string', minLength: 1 }, { $ref: '#/definitions/awsCfFunction' }], + awsArnString: { + type: 'string', + pattern: '^arn:', }, awsCfFunction: { oneOf: [ @@ -163,14 +160,18 @@ class AwsProvider { { $ref: '#/definitions/awsCfSub' }, ], }, - // currently used by lib/plugins/aws/utils/resolveCfImportValue.js for non nested import expressions - awsCfImportLocallyResolvable: { + awsCfGetAtt: { type: 'object', properties: { - 'Fn::ImportValue': { type: 'string' }, + 'Fn::GetAtt': { + type: 'array', + minItems: 2, + maxItems: 2, + items: { type: 'string', minLength: 1 }, + }, }, + required: ['Fn::GetAtt'], additionalProperties: false, - required: ['Fn::ImportValue'], }, awsCfImport: { type: 'object', @@ -180,31 +181,29 @@ class AwsProvider { additionalProperties: false, required: ['Fn::ImportValue'], }, - awsCfJoin: { + awsCfImportLocallyResolvable: { type: 'object', properties: { - 'Fn::Join': { - type: 'array', - minItems: 2, - maxItems: 2, - items: [{ type: 'string', minLength: 1 }, { type: 'array' }], - additionalItems: false, - }, + 'Fn::ImportValue': { type: 'string' }, }, - required: ['Fn::Join'], additionalProperties: false, + required: ['Fn::ImportValue'], }, - awsCfGetAtt: { + awsCfInstruction: { + oneOf: [{ type: 'string', minLength: 1 }, { $ref: '#/definitions/awsCfFunction' }], + }, + awsCfJoin: { type: 'object', properties: { - 'Fn::GetAtt': { + 'Fn::Join': { type: 'array', minItems: 2, maxItems: 2, - items: { type: 'string', minLength: 1 }, + items: [{ type: 'string', minLength: 1 }, { type: 'array' }], + additionalItems: false, }, }, - required: ['Fn::GetAtt'], + required: ['Fn::Join'], additionalProperties: false, }, awsCfRef: { @@ -270,16 +269,16 @@ class AwsProvider { { type: 'object', properties: { - allowedOrigins: { - oneOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }], - }, + allowCredentials: { type: 'boolean' }, allowedHeaders: { oneOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }], }, allowedMethods: { oneOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }], }, - allowCredentials: { type: 'boolean' }, + allowedOrigins: { + oneOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }], + }, exposedResponseHeaders: { oneOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }], }, @@ -328,20 +327,20 @@ class AwsProvider { function: { // TODO: Complete schema, see https://github.com/serverless/serverless/issues/8017 properties: { - handler: { type: 'string' }, fileSystemConfig: { type: 'object', properties: { - localMountPath: { type: 'string', pattern: '^/mnt/[a-zA-Z0-9-_.]+$' }, arn: { type: 'string', pattern: '^arn:aws[a-zA-Z-]*:elasticfilesystem:[a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-[1-9]{1}:[0-9]{12}:access-point/fsap-[a-f0-9]{17}$', }, + localMountPath: { type: 'string', pattern: '^/mnt/[a-zA-Z0-9-_.]+$' }, }, additionalProperties: false, required: ['localMountPath', 'arn'], }, + handler: { type: 'string' }, }, }, resources: { @@ -349,25 +348,27 @@ class AwsProvider { AWSTemplateFormatVersion: { type: 'string', }, + Conditions: { + type: 'object', + }, Description: { type: 'string', }, - Metadata: { + Mappings: { type: 'object', }, - Parameters: { + Metadata: { type: 'object', }, - Mappings: { + // According to https://s3.amazonaws.com/cfn-resource-specifications-us-east-1-prod/schemas/2.15.0/all-spec.json + // `Outputs` is just an "object", though it seems like this is under-specifying that section a bit. + // See also https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html + Outputs: { type: 'object', }, - Conditions: { + Parameters: { type: 'object', }, - Transform: { - type: 'array', - items: { type: 'string' }, - }, // Not replicating the full JSON schema from https://s3.amazonaws.com/cfn-resource-specifications-us-east-1-prod/schemas/2.15.0/all-spec.json // as that gets into the specifics for each resource type. // @@ -388,6 +389,10 @@ class AwsProvider { }, additionalProperties: false, }, + Transform: { + type: 'array', + items: { type: 'string' }, + }, extensions: { type: 'object', patternProperties: { @@ -406,12 +411,6 @@ class AwsProvider { }, additionalProperties: false, }, - // According to https://s3.amazonaws.com/cfn-resource-specifications-us-east-1-prod/schemas/2.15.0/all-spec.json - // `Outputs` is just an "object", though it seems like this is under-specifying that section a bit. - // See also https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html - Outputs: { - type: 'object', - }, }, additionalProperties: false, },