From 919caa8f91c7deeb16472fdc7d3653ee65ce2a77 Mon Sep 17 00:00:00 2001 From: Philipp Muens Date: Mon, 15 Aug 2016 15:36:54 +0200 Subject: [PATCH] Remove validations for existence of compiledCloudFormationTemplate Because it's already available at the beginning of the deploy plugin as the core CloudFormation template will be attached there (which is then used to merge other resources into it later on). --- .../aws/deploy/compile/events/apiGateway/lib/validate.js | 5 ----- .../aws/deploy/compile/events/apiGateway/tests/validate.js | 6 ------ lib/plugins/aws/deploy/compile/events/s3/index.js | 5 ----- lib/plugins/aws/deploy/compile/events/s3/tests/index.js | 5 ----- lib/plugins/aws/deploy/compile/events/schedule/index.js | 5 ----- .../aws/deploy/compile/events/schedule/tests/index.js | 5 ----- lib/plugins/aws/deploy/compile/events/sns/index.js | 5 ----- lib/plugins/aws/deploy/compile/events/sns/tests/index.js | 5 ----- lib/plugins/aws/deploy/compile/functions/index.js | 5 ----- lib/plugins/aws/deploy/compile/functions/tests/index.js | 5 ----- 10 files changed, 51 deletions(-) diff --git a/lib/plugins/aws/deploy/compile/events/apiGateway/lib/validate.js b/lib/plugins/aws/deploy/compile/events/apiGateway/lib/validate.js index fdb4dd4af..249fdc952 100644 --- a/lib/plugins/aws/deploy/compile/events/apiGateway/lib/validate.js +++ b/lib/plugins/aws/deploy/compile/events/apiGateway/lib/validate.js @@ -5,11 +5,6 @@ const BbPromise = require('bluebird'); module.exports = { validate() { - if (!this.serverless.service.provider.compiledCloudFormationTemplate) { - throw new this.serverless.classes - .Error('This plugin needs access to the compiled CloudFormation template'); - } - // validate that path and method exists for each http event in service _.forEach(this.serverless.service.functions, (functionObject, functionName) => { functionObject.events.forEach(event => { diff --git a/lib/plugins/aws/deploy/compile/events/apiGateway/tests/validate.js b/lib/plugins/aws/deploy/compile/events/apiGateway/tests/validate.js index 439e7507a..179b590cf 100644 --- a/lib/plugins/aws/deploy/compile/events/apiGateway/tests/validate.js +++ b/lib/plugins/aws/deploy/compile/events/apiGateway/tests/validate.js @@ -30,12 +30,6 @@ describe('#validate()', () => { }; }); - it('should throw an error if the compiled CloudFormation template is not available', () => { - awsCompileApigEvents.serverless.service.provider.compiledCloudFormationTemplate = false; - - expect(() => awsCompileApigEvents.validate()).to.throw(Error); - }); - it('should validate the http events "path" property', () => { awsCompileApigEvents.serverless.service.functions = { first: { diff --git a/lib/plugins/aws/deploy/compile/events/s3/index.js b/lib/plugins/aws/deploy/compile/events/s3/index.js index 27e8d60dd..dbf77be59 100644 --- a/lib/plugins/aws/deploy/compile/events/s3/index.js +++ b/lib/plugins/aws/deploy/compile/events/s3/index.js @@ -13,11 +13,6 @@ class AwsCompileS3Events { } compileS3Events() { - if (!this.serverless.service.provider.compiledCloudFormationTemplate) { - throw new this.serverless.classes - .Error('This plugin needs access to the compiled CloudFormation template'); - } - this.serverless.service.getAllFunctions().forEach((functionName) => { const functionObj = this.serverless.service.getFunction(functionName); diff --git a/lib/plugins/aws/deploy/compile/events/s3/tests/index.js b/lib/plugins/aws/deploy/compile/events/s3/tests/index.js index 7de57d26e..f7afee965 100644 --- a/lib/plugins/aws/deploy/compile/events/s3/tests/index.js +++ b/lib/plugins/aws/deploy/compile/events/s3/tests/index.js @@ -21,11 +21,6 @@ describe('AwsCompileS3Events', () => { }); describe('#compileS3Events()', () => { - it('should throw an error if the compiled CloudFormation template is not available', () => { - awsCompileS3Events.serverless.service.provider.compiledCloudFormationTemplate = false; - expect(() => awsCompileS3Events.compileS3Events()).to.throw(Error); - }); - it('should throw an error if s3 event type is not a string or an object', () => { awsCompileS3Events.serverless.service.functions = { first: { diff --git a/lib/plugins/aws/deploy/compile/events/schedule/index.js b/lib/plugins/aws/deploy/compile/events/schedule/index.js index e75902822..2766a924d 100644 --- a/lib/plugins/aws/deploy/compile/events/schedule/index.js +++ b/lib/plugins/aws/deploy/compile/events/schedule/index.js @@ -13,11 +13,6 @@ class AwsCompileScheduledEvents { } compileScheduledEvents() { - if (!this.serverless.service.provider.compiledCloudFormationTemplate) { - throw new this.serverless.classes - .Error('This plugin needs access to the compiled CloudFormation template'); - } - this.serverless.service.getAllFunctions().forEach((functionName) => { const functionObj = this.serverless.service.getFunction(functionName); diff --git a/lib/plugins/aws/deploy/compile/events/schedule/tests/index.js b/lib/plugins/aws/deploy/compile/events/schedule/tests/index.js index 933b64570..ffca20b0a 100644 --- a/lib/plugins/aws/deploy/compile/events/schedule/tests/index.js +++ b/lib/plugins/aws/deploy/compile/events/schedule/tests/index.js @@ -21,11 +21,6 @@ describe('AwsCompileScheduledEvents', () => { }); describe('#compileScheduledEvents()', () => { - it('should throw an error if the compiled CloudFormation template is not available', () => { - awsCompileScheduledEvents.serverless.service.provider.compiledCloudFormationTemplate = false; - expect(() => awsCompileScheduledEvents.compileScheduledEvents()).to.throw(Error); - }); - it('should throw an error if schedule event type is not a string or an object', () => { awsCompileScheduledEvents.serverless.service.functions = { first: { diff --git a/lib/plugins/aws/deploy/compile/events/sns/index.js b/lib/plugins/aws/deploy/compile/events/sns/index.js index 3ad1ce092..2f07934c7 100644 --- a/lib/plugins/aws/deploy/compile/events/sns/index.js +++ b/lib/plugins/aws/deploy/compile/events/sns/index.js @@ -13,11 +13,6 @@ class AwsCompileSNSEvents { } compileSNSEvents() { - if (!this.serverless.service.provider.compiledCloudFormationTemplate) { - throw new this.serverless.classes - .Error('This plugin needs access to the compiled CloudFormation template'); - } - this.serverless.service.getAllFunctions().forEach((functionName) => { const functionObj = this.serverless.service.getFunction(functionName); diff --git a/lib/plugins/aws/deploy/compile/events/sns/tests/index.js b/lib/plugins/aws/deploy/compile/events/sns/tests/index.js index c95e836df..6f374e5fb 100644 --- a/lib/plugins/aws/deploy/compile/events/sns/tests/index.js +++ b/lib/plugins/aws/deploy/compile/events/sns/tests/index.js @@ -20,11 +20,6 @@ describe('AwsCompileSNSEvents', () => { }); describe('#compileSNSEvents()', () => { - it('should throw an error if the compiled CloudFormation template is not available', () => { - awsCompileSNSEvents.serverless.service.provider.compiledCloudFormationTemplate = false; - expect(() => awsCompileSNSEvents.compileSNSEvents()).to.throw(Error); - }); - it('should throw an error if SNS event type is not a string or an object', () => { awsCompileSNSEvents.serverless.service.functions = { first: { diff --git a/lib/plugins/aws/deploy/compile/functions/index.js b/lib/plugins/aws/deploy/compile/functions/index.js index 1d3816ec5..d767203bc 100644 --- a/lib/plugins/aws/deploy/compile/functions/index.js +++ b/lib/plugins/aws/deploy/compile/functions/index.js @@ -15,11 +15,6 @@ class AwsCompileFunctions { } compileFunctions() { - if (!this.serverless.service.provider.compiledCloudFormationTemplate) { - throw new this.serverless.classes - .Error('This plugin needs access to the compiled CloudFormation template'); - } - // merge in the iamRoleLambdaTemplate const iamRoleLambdaTemplate = this.serverless.utils.readFileSync( path.join(this.serverless.config.serverlessPath, diff --git a/lib/plugins/aws/deploy/compile/functions/tests/index.js b/lib/plugins/aws/deploy/compile/functions/tests/index.js index 8e95e6253..2af4f213c 100644 --- a/lib/plugins/aws/deploy/compile/functions/tests/index.js +++ b/lib/plugins/aws/deploy/compile/functions/tests/index.js @@ -30,11 +30,6 @@ describe('AwsCompileFunctions', () => { }); describe('#compileFunctions()', () => { - it('should throw an error if the compiled CloudFormation template is not available', () => { - awsCompileFunctions.serverless.service.provider.compiledCloudFormationTemplate = false; - expect(() => awsCompileFunctions.compileFunctions()).to.throw(Error); - }); - it('should merge the IamRoleLambda template into the CloudFormation template', () => { const iamRoleLambdaTemplate = awsCompileFunctions.serverless.utils.readFileSync( path.join(