Skip to content

Commit

Permalink
refactor(Config Schema): List properties in alphabetical order
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Sep 15, 2020
1 parent d5833f8 commit e028f5e
Showing 1 changed file with 42 additions and 43 deletions.
85 changes: 42 additions & 43 deletions lib/plugins/aws/provider/awsProvider.js
Expand Up @@ -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: [
Expand All @@ -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',
Expand All @@ -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: {
Expand Down Expand Up @@ -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' } }],
},
Expand Down Expand Up @@ -328,46 +327,48 @@ 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: {
properties: {
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.
//
Expand All @@ -388,6 +389,10 @@ class AwsProvider {
},
additionalProperties: false,
},
Transform: {
type: 'array',
items: { type: 'string' },
},
extensions: {
type: 'object',
patternProperties: {
Expand All @@ -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,
},
Expand Down

0 comments on commit e028f5e

Please sign in to comment.