Skip to content
Closed
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
22 changes: 20 additions & 2 deletions packages/aws-cdk/lib/cli/cdk-toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2113,11 +2113,29 @@ async function askUserConfirmation(
});
}

/**
* Display a warning if there are flags that are different from the recommended value
*
* This happens if both of the following are true:
*
* - The user didn't configure the value
* - The default value for the flag (unconfiguredBehavesLike) is different from the recommended value
*/
export async function displayFlagsMessage(ioHost: IoHelper, toolkit: InternalToolkit, cloudExecutable: CloudExecutable): Promise<void> {
let numUnconfigured = (await toolkit.flags(cloudExecutable))
const flags = await toolkit.flags(cloudExecutable);

// The "unconfiguredBehavesLike" information got added later. If none of the flags have this information,
// we don't have enough information to reliably display this information without scaring users, so don't do anything.
if (flags.every(flag => flag.unconfiguredBehavesLike === undefined)) {
return;
}

const unconfiguredFlags = flags
.filter(flag => !OBSOLETE_FLAGS.includes(flag.name))
.filter(flag => flag.userValue === undefined).length;
.filter(flag => (flag.unconfiguredBehavesLike?.v2 ?? false) !== flag.recommendedValue)
.filter(flag => flag.userValue === undefined);

const numUnconfigured = unconfiguredFlags.length;
if (numUnconfigured > 0) {
await ioHost.defaults.warn(`${numUnconfigured} feature flags are not configured. Run 'cdk --unstable=flags flags' to learn more.`);
}
Expand Down
Loading