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

Handle no changes #25

Merged
merged 1 commit into from
Jan 10, 2019
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
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface ParseResult {
changedDataSources: Array<Changed>;
}

const NO_CHANGES_STRING = '\nNo changes. Infrastructure is up-to-date.\n';
const CONTENT_START_STRING = '\nTerraform will perform the following actions:\n';
const CONTENT_END_STRING = '\nPlan:';
const OLD_NEW_SEPARATOR = ' => ';
Expand Down Expand Up @@ -356,6 +357,11 @@ export function parseStdout (logOutput: string): ParseResult {

let lastChange = null;

if (logOutput.includes(NO_CHANGES_STRING)) {
// no changes to parse...
return result;
}

const startPos = findParseableContentStartPos(logOutput);
if (startPos === -1) {
result.errors.push({
Expand Down
5 changes: 5 additions & 0 deletions test/unit/data/13-no-changes.expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"errors": [],
"changedResources": [],
"changedDataSources": []
}
12 changes: 12 additions & 0 deletions test/unit/data/13-no-changes.stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.


------------------------------------------------------------------------

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.
4 changes: 4 additions & 0 deletions test/unit/terraform-plan-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@ test('should handle tainted resources', async (t) => {
test('should handle modules', async (t) => {
return runTest('12-modules', t);
});

test('should handle no changes', async (t) => {
return runTest('13-no-changes', t);
});