Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
comcalvi committed Dec 12, 2023
1 parent 49e890c commit 5129e95
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
28 changes: 11 additions & 17 deletions packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ const DIFF_HANDLERS: HandlerRegistry = {
* a stack which current state is described by +currentTemplate+ is updated with
* the template +newTemplate+.
*/
// eslint-disable-next-line max-len
export function diffTemplate(currentTemplate: { [key: string]: any }, newTemplate: { [key: string]: any }, changeSet?: CloudFormation.DescribeChangeSetOutput): types.TemplateDiff {
export function diffTemplate(
currentTemplate: { [key: string]: any },
newTemplate: { [key: string]: any },
changeSet?: CloudFormation.DescribeChangeSetOutput
): types.TemplateDiff {
const replacements = changeSet ? findResourceReplacements(changeSet): undefined;
// Base diff
const theDiff = calculateTemplateDiff(currentTemplate, newTemplate, replacements);
Expand Down Expand Up @@ -97,8 +100,11 @@ function propagatePropertyReplacement(source: types.ResourceDifference, dest: ty
}
}

// eslint-disable-next-line max-len
function calculateTemplateDiff(currentTemplate: { [key: string]: any }, newTemplate: { [key: string]: any }, replacements?: ResourceReplacements): types.TemplateDiff {
function calculateTemplateDiff(
currentTemplate: { [key: string]: any },
newTemplate: { [key: string]: any },
replacements?: ResourceReplacements,
): types.TemplateDiff {
const differences: types.ITemplateDiff = {};
const unknown: { [key: string]: types.Difference<any> } = {};
for (const key of unionOf(Object.keys(currentTemplate), Object.keys(newTemplate)).sort()) {
Expand All @@ -118,14 +124,6 @@ function calculateTemplateDiff(currentTemplate: { [key: string]: any }, newTempl
return new types.TemplateDiff(differences);
}

/**
* Compare two CloudFormation resources and return semantic differences between them
*/
/*export function diffResource(oldValue: types.Resource, newValue: types.Resource): types.ResourceDifference {
return impl.diffResource(oldValue, newValue);
}
*/

/**
* Replace all references to the given logicalID on the given template, in-place
*
Expand Down Expand Up @@ -214,9 +212,5 @@ function findResourceReplacements(changeSet: CloudFormation.DescribeChangeSetOut
};
}

//console.log('----=----=-=-=-=-=-=');
//console.log(JSON.stringify(replacements, undefined, 2));
//console.log('----=----=-=-=-=-=-=');

return replacements;
}
}
9 changes: 6 additions & 3 deletions packages/aws-cdk/lib/diff.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import * as cxschema from '@aws-cdk/cloud-assembly-schema';
import * as cfnDiff from '@aws-cdk/cloudformation-diff';
import * as cxapi from '@aws-cdk/cx-api';
Expand Down Expand Up @@ -77,8 +76,12 @@ export enum RequireApproval {
*
* Returns true if the changes are prompt-worthy, false otherwise.
*/
// eslint-disable-next-line max-len
export function printSecurityDiff(oldTemplate: any, newTemplate: cxapi.CloudFormationStackArtifact, requireApproval: RequireApproval, changeSet?: CloudFormation.DescribeChangeSetOutput): boolean {
export function printSecurityDiff(
oldTemplate: any,
newTemplate: cxapi.CloudFormationStackArtifact,
requireApproval: RequireApproval,
changeSet?: CloudFormation.DescribeChangeSetOutput,
): boolean {
const diff = cfnDiff.diffTemplate(oldTemplate, newTemplate.template, changeSet);

if (difRequiresApproval(diff, requireApproval)) {
Expand Down

0 comments on commit 5129e95

Please sign in to comment.