Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/builtins/deploy-delegates/lambda-deployer/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ function validateLambdaDeployState(reporter, awsProfile, awsRegion, currentRegio
const remoteIAMRole = data.Configuration.Role;
if (stringUtils.isNonBlankString(localIAMRole) && !R.equals(localIAMRole, remoteIAMRole)) {
return callback(`The IAM role for Lambda ARN (${lambdaArn}) should be ${remoteIAMRole}, but found ${localIAMRole}. \
Please solve this IAM role mismatch and re-deploy again.`);
Please solve this IAM role mismatch and re-deploy again. To ignore this error run "ask deploy --ignore-hash".`);
}
updatedDeployState = R.set(R.lensPath(['iamRole']), remoteIAMRole, currentRegionDeployState);
// 2. check revision id
const localRevisionId = lambdaData.revisionId;
const remoteRevisionId = data.Configuration.RevisionId;
if (stringUtils.isNonBlankString(localRevisionId) && !R.equals(localRevisionId, remoteRevisionId) && !ignoreHash) {
return callback(`The current revisionId (The revision ID for Lambda ARN (${lambdaArn}) should be ${remoteRevisionId}, \
but found ${localRevisionId}. Please solve this revision mismatch and re-deploy again.`);
but found ${localRevisionId}. Please solve this revision mismatch and re-deploy again. \
To ignore this error run "ask deploy --ignore-hash".`);
}
updatedDeployState = R.set(R.lensPath(['lambda', 'revisionId']), remoteRevisionId, updatedDeployState);
// 3. add lastModified
Expand Down
6 changes: 4 additions & 2 deletions lib/view/multi-tasks-view.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const Listr = require('listr');
const { EventEmitter } = require('events');
const { Observable } = require('rxjs');
const CliError = require('@src/exceptions/cli-error');

/**
* Reactive (rxjs) task class which serve as the middleware for Listr task registration
Expand Down Expand Up @@ -119,9 +120,10 @@ class MultiTasksView {
this.taskRunner.run().then((context) => {
callback(null, context);
}).catch((listrError) => {
// listError { errors: [], context } contains array of errors from tasks and all context
const errorMessage = listrError.errors
.map(e => e.resultMessage || e.message || e).join('\n');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taking care of all possible ways we throw the error. In this specific situation the error was on resultMessage

callback({
error: [...new Set(listrError.errors)].join('\n- '),
error: new CliError(errorMessage),
partialResult: listrError.context
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/builtins/lambda-deployer/helper-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('Builtins test - lambda-deployer helper.js test', () => {
}
};
const TEST_IAM_ROLE_ERROR = `The IAM role for Lambda ARN (${TEST_LAMBDA_ARN}) should be ${TEST_REMOTE_IAM_ROLE}, \
but found ${TEST_LOCAL_IAM_ROLE}. Please solve this IAM role mismatch and re-deploy again.`;
but found ${TEST_LOCAL_IAM_ROLE}. Please solve this IAM role mismatch and re-deploy again. To ignore this error run "ask deploy --ignore-hash".`;
sinon.stub(LambdaClient.prototype, 'getFunction').callsArgWith(1, null, TEST_REMOTE_DEPLOY_STATE);
// call
helper.validateLambdaDeployState(REPORTER, TEST_AWS_PROFILE, TEST_AWS_REGION, TEST_LOCAL_DEPLOY_STATE, TEST_IGNORE_HASH, (err) => {
Expand All @@ -102,7 +102,7 @@ but found ${TEST_LOCAL_IAM_ROLE}. Please solve this IAM role mismatch and re-dep
}
};
const TEST_REVISION_ID_ERROR = `The current revisionId (The revision ID for Lambda ARN (${TEST_LAMBDA_ARN}) should be \
${TEST_REMOTE_REVISION_ID}, but found ${TEST_LOCAL_REVISION_ID}. Please solve this revision mismatch and re-deploy again.`;
${TEST_REMOTE_REVISION_ID}, but found ${TEST_LOCAL_REVISION_ID}. Please solve this revision mismatch and re-deploy again. To ignore this error run "ask deploy --ignore-hash".`;
sinon.stub(LambdaClient.prototype, 'getFunction').callsArgWith(1, null, TEST_REMOTE_DEPLOY_STATE);
// call
helper.validateLambdaDeployState(REPORTER, TEST_AWS_PROFILE, TEST_AWS_REGION, TEST_LOCAL_DEPLOY_STATE, TEST_IGNORE_HASH, (err) => {
Expand Down
5 changes: 3 additions & 2 deletions test/unit/view/multi-tasks-view-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const sinon = require('sinon');
const Listr = require('listr');
const events = require('events');
const { Observable } = require('rxjs');
const CliError = require('@src/exceptions/cli-error');
const MultiTasksView = require('@src/view/multi-tasks-view');

const { ListrReactiveTask } = MultiTasksView;
Expand Down Expand Up @@ -62,14 +63,14 @@ describe('View test - MultiTasksView test', () => {
// setup
const multiTasks = new MultiTasksView(TEST_OPTIONS);
const newTask = new ListrReactiveTask(TEST_TASK_HANDLE, TEST_TASK_ID);
sinon.stub(Listr.prototype, 'run').rejects({ errors: ['error'] });
sinon.stub(Listr.prototype, 'run').rejects({ errors: ['error 1', { resultMessage: 'error 2' }, new Error('error 3')] });
sinon.stub(ListrReactiveTask.prototype, 'execute');
multiTasks._listrTasks.push(newTask);
// call
multiTasks.start((err, res) => {
// verify
expect(res).equal(undefined);
expect(err.error).equal('error');
expect(err.error).eql(new CliError('error 1\nerror 2\nerror 3'));
expect(ListrReactiveTask.prototype.execute.callCount).equal(1);
done();
});
Expand Down