Skip to content

Commit 417db1a

Browse files
committed
fix(cli): don't nag for flags that don't need configuring
The flags nag message is too pessimistic, showing 18 unconfigured flags on a newly cdk inited project. * Part of that is the CDK library emitting info for flags that don't exist anymore, fixed here: aws/aws-cdk#35227 * Part of that is we are alarming on unconfigured flags, even if the behavior of unconfigured flags is the same as recommended behavior. We shouldn't alarm on the latter, so filter them out.
1 parent 73184ac commit 417db1a

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

packages/aws-cdk/lib/cli/cdk-toolkit.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,11 +2113,29 @@ async function askUserConfirmation(
21132113
});
21142114
}
21152115

2116+
/**
2117+
* Display a warning if there are flags that are different from the recommended value
2118+
*
2119+
* This happens if both of the following are true:
2120+
*
2121+
* - The user didn't configure the value
2122+
* - The default value for the flag (unconfiguredBehavesLike) is different from the recommended value
2123+
*/
21162124
export async function displayFlagsMessage(ioHost: IoHelper, toolkit: InternalToolkit, cloudExecutable: CloudExecutable): Promise<void> {
2117-
let numUnconfigured = (await toolkit.flags(cloudExecutable))
2125+
const flags = await toolkit.flags(cloudExecutable);
2126+
2127+
// The "unconfiguredBehavesLike" information got added later. If none of the flags have this information,
2128+
// we don't have enough information to reliably display this information without scaring users, so don't do anything.
2129+
if (flags.every(flag => flag.unconfiguredBehavesLike === undefined)) {
2130+
return;
2131+
}
2132+
2133+
const unconfiguredFlags = flags
21182134
.filter(flag => !OBSOLETE_FLAGS.includes(flag.name))
2119-
.filter(flag => flag.userValue === undefined).length;
2135+
.filter(flag => (flag.unconfiguredBehavesLike?.v2 ?? false) !== flag.recommendedValue)
2136+
.filter(flag => flag.userValue === undefined);
21202137

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

0 commit comments

Comments
 (0)