Skip to content

Commit

Permalink
chore(core): change FeatureFlags to use constructs.IConstruct (#19567)
Browse files Browse the repository at this point in the history
This change is motivated by #18140, where we are running into trouble because the current scope is a `constructs.Construct` but `FeatureFlags.of` required a `core.construct`.

----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
madeline-k authored Mar 29, 2022
1 parent 64b266f commit a0fb04f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/core/lib/feature-flags.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as cxapi from '@aws-cdk/cx-api';
import { IConstruct } from '../lib/construct-compat';
import { IConstruct, Node } from 'constructs';

/**
* Features that are implemented behind a flag in order to preserve backwards
Expand All @@ -24,7 +24,7 @@ export class FeatureFlags {
* module.
*/
public isEnabled(featureFlag: string): boolean | undefined {
const context = this.construct.node.tryGetContext(featureFlag);
const context = Node.of(this.construct).tryGetContext(featureFlag);
if (cxapi.FUTURE_FLAGS_EXPIRED.includes(featureFlag)) {
if (context !== undefined) {
throw new Error(`Unsupported feature flag '${featureFlag}'. This flag existed on CDKv1 but has been removed in CDKv2.`
Expand Down

0 comments on commit a0fb04f

Please sign in to comment.