Skip to content

Commit

Permalink
chore: isolate CoreConstruct imports to avoid merge conflicts (#12850)
Browse files Browse the repository at this point in the history
As part of CDKv2, the construct layer in '@aws-cdk/core' is
being replaced with the constructs API in the 'constructs'
module. During the transition period between v1 and v2,
both exist.

On the `master` branch, code will include importing
`Construct` from the '@aws-cdk/core' module but this
will not be possible in the `v2-main` branch where this API
does not exist.

Any change to the same line as the import of the `Construct`
symbol will cause merge conflicts. Hence, move the import
into a separate line and section to avoid these conflicts.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
Niranjan Jayakar committed Feb 4, 2021
1 parent 5664480 commit 404b556
Show file tree
Hide file tree
Showing 83 changed files with 534 additions and 67 deletions.
6 changes: 5 additions & 1 deletion packages/@aws-cdk/assets/lib/staging.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { AssetStaging, Construct } from '@aws-cdk/core';
import { AssetStaging } from '@aws-cdk/core';
import { toSymlinkFollow } from './compat';
import { FingerprintOptions } from './fs/options';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* Deprecated
* @deprecated use `core.AssetStagingProps`
Expand Down
6 changes: 5 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/deployment.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import * as crypto from 'crypto';
import { Construct as CoreConstruct, Lazy, RemovalPolicy, Resource, CfnResource } from '@aws-cdk/core';
import { Lazy, RemovalPolicy, Resource, CfnResource } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnDeployment } from './apigateway.generated';
import { Method } from './method';
import { IRestApi, RestApi, SpecRestApi, RestApiBase } from './restapi';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct as CoreConstruct } from '@aws-cdk/core';

export interface DeploymentProps {
/**
* The Rest API to deploy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import * as kms from '@aws-cdk/aws-kms';
import * as lambda from '@aws-cdk/aws-lambda';
import * as sns from '@aws-cdk/aws-sns';
import * as subs from '@aws-cdk/aws-sns-subscriptions';
import { Construct } from '@aws-cdk/core';

import { TopicHook } from './topic-hook';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* Use a Lambda Function as a hook target
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Construct } from '@aws-cdk/core';

import { ILifecycleHook } from './lifecycle-hook';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* Interface for autoscaling lifecycle hook targets
*/
Expand Down
6 changes: 5 additions & 1 deletion packages/@aws-cdk/aws-autoscaling/lib/step-scaling-action.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Construct as CoreConstruct, Duration, Lazy } from '@aws-cdk/core';
import { Duration, Lazy } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { IAutoScalingGroup } from './auto-scaling-group';
import { CfnScalingPolicy } from './autoscaling.generated';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct as CoreConstruct } from '@aws-cdk/core';

/**
* Properties for a scaling policy
*/
Expand Down
6 changes: 5 additions & 1 deletion packages/@aws-cdk/aws-autoscaling/lib/step-scaling-policy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { findAlarmThresholds, normalizeIntervals } from '@aws-cdk/aws-autoscaling-common';
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import { Construct as CoreConstruct, Duration } from '@aws-cdk/core';
import { Duration } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { IAutoScalingGroup } from './auto-scaling-group';
import { AdjustmentType, MetricAggregationType, StepScalingAction } from './step-scaling-action';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct as CoreConstruct } from '@aws-cdk/core';

export interface BasicStepScalingPolicyProps {
/**
* Metric to scale on.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import { Construct as CoreConstruct, Duration } from '@aws-cdk/core';
import { Duration } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { IAutoScalingGroup } from './auto-scaling-group';
import { CfnScalingPolicy } from './autoscaling.generated';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct as CoreConstruct } from '@aws-cdk/core';

/**
* Base interface for target tracking props
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
* - GetAtt.Attribute1: "foo"
* - GetAtt.Attribute2: 1234
*/
import { App, CfnOutput, Construct, CustomResource, CustomResourceProvider, CustomResourceProviderRuntime, Stack, Token } from '@aws-cdk/core';
import { App, CfnOutput, CustomResource, CustomResourceProvider, CustomResourceProviderRuntime, Stack, Token } from '@aws-cdk/core';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/* eslint-disable cdk/no-core-construct */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import * as lambda from '@aws-cdk/aws-lambda';
import * as sns from '@aws-cdk/aws-sns';
import * as sns_subscriptions from '@aws-cdk/aws-sns-subscriptions';
import * as sqs from '@aws-cdk/aws-sqs';
import { App, CfnParameter, Construct, Stack } from '@aws-cdk/core';
import { App, CfnParameter, Stack } from '@aws-cdk/core';
import * as cfn from '../lib';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/* eslint-disable cdk/no-core-construct */

interface MyNestedStackProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
/// !cdk-integ pragma:ignore-assets
import * as path from 'path';
import * as lambda from '@aws-cdk/aws-lambda';
import { App, Construct, Stack } from '@aws-cdk/core';
import { App, Stack } from '@aws-cdk/core';
import * as cfn from '../lib';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/* eslint-disable cdk/no-core-construct */

class NestedStack extends cfn.NestedStack {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/// !cdk-integ pragma:ignore-assets
import * as sns from '@aws-cdk/aws-sns';
import { App, Construct, Stack } from '@aws-cdk/core';
import { App, Stack } from '@aws-cdk/core';
import * as cfn from '../lib';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/* eslint-disable cdk/no-core-construct */

class YourNestedStack extends cfn.NestedStack {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
/* eslint-disable cdk/no-core-construct */

import * as sns from '@aws-cdk/aws-sns';
import { App, Construct, Stack } from '@aws-cdk/core';
import { App, Stack } from '@aws-cdk/core';
import * as cfn from '../lib';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

class ConsumerNestedStack extends cfn.NestedStack {
constructor(scope: Construct, id: string, topic: sns.Topic) {
super(scope, id);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/// !cdk-integ *
import * as sns from '@aws-cdk/aws-sns';
import { App, Construct, Fn, Stack } from '@aws-cdk/core';
import { App, Fn, Stack } from '@aws-cdk/core';
import * as cfn from '../lib';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

// non-nested non-parent stack consumes a resource from a nested stack

/* eslint-disable cdk/no-core-construct */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/// !cdk-integ *
import * as sns from '@aws-cdk/aws-sns';
import { App, Construct, Fn, Stack } from '@aws-cdk/core';
import { App, Fn, Stack } from '@aws-cdk/core';
import * as cfn from '../lib';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

// references between siblings

/* eslint-disable cdk/no-core-construct */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import * as path from 'path';
import { expect, haveResource, matchTemplate, SynthUtils } from '@aws-cdk/assert';
import * as s3_assets from '@aws-cdk/aws-s3-assets';
import * as sns from '@aws-cdk/aws-sns';
import { App, CfnParameter, CfnResource, Construct, ContextProvider, LegacyStackSynthesizer, Names, Stack } from '@aws-cdk/core';
import { App, CfnParameter, CfnResource, ContextProvider, LegacyStackSynthesizer, Names, Stack } from '@aws-cdk/core';
import { Test } from 'nodeunit';
import { NestedStack } from '../lib/nested-stack';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/* eslint-disable cdk/no-core-construct */
/* eslint-disable max-len */

Expand Down
6 changes: 5 additions & 1 deletion packages/@aws-cdk/aws-cloudfront/lib/origin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Construct, Duration, Token } from '@aws-cdk/core';
import { Duration, Token } from '@aws-cdk/core';
import { CfnDistribution } from './cloudfront.generated';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* The failover configuration used for Origin Groups,
* returned in {@link OriginBindConfig.failoverConfig}.
Expand Down
6 changes: 5 additions & 1 deletion packages/@aws-cdk/aws-cloudwatch/lib/alarm-action.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Construct } from '@aws-cdk/core';

import { IAlarm } from './alarm-base';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* Interface for objects that can be the targets of CloudWatch alarm actions
*/
Expand Down
6 changes: 5 additions & 1 deletion packages/@aws-cdk/aws-codepipeline-actions/lib/action.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import * as events from '@aws-cdk/aws-events';
import { Construct, Lazy } from '@aws-cdk/core';
import { Lazy } from '@aws-cdk/core';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* Low-level class for generic CodePipeline Actions.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import { Construct, SecretValue } from '@aws-cdk/core';
import { SecretValue } from '@aws-cdk/core';
import { Action } from '../action';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* Construction properties of the {@link AlexaSkillDeployAction Alexa deploy Action}.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import * as iam from '@aws-cdk/aws-iam';
import { Construct } from '@aws-cdk/core';

import { Action } from '../action';
import { sourceArtifactBounds } from '../common';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* Construction properties for {@link BitBucketSourceAction}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import * as codecommit from '@aws-cdk/aws-codecommit';
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import * as targets from '@aws-cdk/aws-events-targets';
import * as iam from '@aws-cdk/aws-iam';
import { Construct, Names, Token } from '@aws-cdk/core';
import { Names, Token } from '@aws-cdk/core';
import { Action } from '../action';
import { sourceArtifactBounds } from '../common';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* How should the CodeCommit Action detect changes.
* This is the type of the {@link CodeCommitSourceAction.trigger} property.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import * as codedeploy from '@aws-cdk/aws-codedeploy';
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import * as iam from '@aws-cdk/aws-iam';
import { Construct, Lazy } from '@aws-cdk/core';
import { Lazy } from '@aws-cdk/core';
import { Action } from '../action';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* Configuration for replacing a placeholder string in the ECS task
* definition template file with an image URI.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import * as codedeploy from '@aws-cdk/aws-codedeploy';
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import * as iam from '@aws-cdk/aws-iam';
import { Construct } from '@aws-cdk/core';

import { Action } from '../action';
import { deployArtifactBounds } from '../common';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* Construction properties of the {@link CodeDeployServerDeployAction CodeDeploy server deploy CodePipeline Action}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import * as codepipeline from '@aws-cdk/aws-codepipeline';
import * as ecr from '@aws-cdk/aws-ecr';
import * as targets from '@aws-cdk/aws-events-targets';
import * as iam from '@aws-cdk/aws-iam';
import { Construct, Names } from '@aws-cdk/core';
import { Names } from '@aws-cdk/core';
import { Action } from '../action';
import { sourceArtifactBounds } from '../common';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* The CodePipeline variables emitted by the ECR source Action.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import * as ecs from '@aws-cdk/aws-ecs';
import * as iam from '@aws-cdk/aws-iam';
import { Construct, Duration } from '@aws-cdk/core';
import { Duration } from '@aws-cdk/core';
import { Action } from '../action';
import { deployArtifactBounds } from '../common';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* Construction properties of {@link EcsDeployAction}.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import { Construct, SecretValue } from '@aws-cdk/core';
import { SecretValue } from '@aws-cdk/core';
import { Action } from '../action';
import { sourceArtifactBounds } from '../common';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* If and how the GitHub source action should be triggered
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import { Construct } from '@aws-cdk/core';

import { Action } from '../action';
import { IJenkinsProvider, jenkinsArtifactsBounds } from './jenkins-provider';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';

/**
* The type of the Jenkins Action that determines its CodePipeline Category -
* Build, or Test.
Expand Down
Loading

0 comments on commit 404b556

Please sign in to comment.