Skip to content

Commit 83b8df8

Browse files
author
Elad Ben-Israel
authored
chore: eliminate the use of xxx.Construct to reduce v2 merge conflicts (#12504)
Introduce an eslint rule & fix all instances in our code which refer to `@aws-cdk/core.Construct` using a qualified namespace (e.g. `core.Construct`, `cdk.Construct`, etc). In v2, `Construct` will refer to `constructs.Construct` so it will reduce the chances for merge issues. The rule fixer automatically adds an `import` statement (separated from the main import group) and replaces the usage. If the file already imports `constructs.Construct`, then the new import will alias as `CoreConstruct`. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 737bab3 commit 83b8df8

File tree

89 files changed

+639
-194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+639
-194
lines changed

packages/@aws-cdk-containers/ecs-service-extensions/lib/environment.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import * as ecs from '@aws-cdk/aws-ecs';
33
import * as cdk from '@aws-cdk/core';
44
import { EnvironmentCapacityType } from './extensions/extension-interfaces';
55

6+
// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
7+
// eslint-disable-next-line no-duplicate-imports, import/order
8+
import { Construct } from '@aws-cdk/core';
9+
610
/**
711
* Settings for the environment you want to deploy.
812
* services within.
@@ -64,11 +68,11 @@ export interface IEnvironment {
6468
* or it can create it's own VPC and cluster. By default it will create
6569
* a cluster with Fargate capacity.
6670
*/
67-
export class Environment extends cdk.Construct implements IEnvironment {
71+
export class Environment extends Construct implements IEnvironment {
6872
/**
6973
* Import an existing environment from its attributes.
7074
*/
71-
public static fromEnvironmentAttributes(scope: cdk.Construct, id: string, attrs: EnvironmentAttributes): IEnvironment {
75+
public static fromEnvironmentAttributes(scope: Construct, id: string, attrs: EnvironmentAttributes): IEnvironment {
7276
return new ImportedEnvironment(scope, id, attrs);
7377
}
7478

@@ -94,7 +98,7 @@ export class Environment extends cdk.Construct implements IEnvironment {
9498

9599
private readonly scope: cdk.Construct;
96100

97-
constructor(scope: cdk.Construct, id: string, props?: EnvironmentProps) {
101+
constructor(scope: Construct, id: string, props?: EnvironmentProps) {
98102
super(scope, id);
99103

100104
this.scope = scope;
@@ -139,13 +143,13 @@ export interface EnvironmentAttributes {
139143
cluster: ecs.ICluster;
140144
}
141145

142-
export class ImportedEnvironment extends cdk.Construct implements IEnvironment {
146+
export class ImportedEnvironment extends Construct implements IEnvironment {
143147
public readonly capacityType: EnvironmentCapacityType;
144148
public readonly cluster: ecs.ICluster;
145149
public readonly id: string;
146150
public readonly vpc: ec2.IVpc;
147151

148-
constructor(scope: cdk.Construct, id: string, props: EnvironmentAttributes) {
152+
constructor(scope: Construct, id: string, props: EnvironmentAttributes) {
149153
super(scope, id);
150154

151155
this.id = id;

packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/appmesh.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import { Service } from '../service';
99
import { Container } from './container';
1010
import { ServiceExtension, ServiceBuild } from './extension-interfaces';
1111

12+
// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
13+
// eslint-disable-next-line no-duplicate-imports, import/order
14+
import { Construct } from '@aws-cdk/core';
15+
1216
// The version of the App Mesh envoy sidecar to add to the task.
1317
const APP_MESH_ENVOY_SIDECAR_VERSION = 'v1.15.1.0-prod';
1418

@@ -63,7 +67,7 @@ export class AppMeshExtension extends ServiceExtension {
6367
}
6468
}
6569

66-
public prehook(service: Service, scope: cdk.Construct) {
70+
public prehook(service: Service, scope: Construct) {
6771
this.parentService = service;
6872
this.scope = scope;
6973

packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/assign-public-ip/assign-public-ip.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import * as ec2 from '@aws-cdk/aws-ec2';
22
import * as ecs from '@aws-cdk/aws-ecs';
33
import * as route53 from '@aws-cdk/aws-route53';
4-
import * as cdk from '@aws-cdk/core';
54
import { Service } from '../../service';
65
import { Container } from '../container';
76
import { ServiceExtension, ServiceBuild, EnvironmentCapacityType } from '../extension-interfaces';
87
import { TaskRecordManager } from './task-record-manager';
98

9+
// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
10+
// eslint-disable-next-line no-duplicate-imports, import/order
11+
import { Construct } from '@aws-cdk/core';
12+
1013
export interface AssignPublicIpExtensionOptions {
1114
/**
1215
* Enable publishing task public IPs to a recordset in a Route 53 hosted zone.
@@ -52,7 +55,7 @@ export class AssignPublicIpExtension extends ServiceExtension {
5255
return Boolean(this.dns);
5356
}
5457

55-
public prehook(service: Service, _scope: cdk.Construct) {
58+
public prehook(service: Service, _scope: Construct) {
5659
super.prehook(service, _scope);
5760

5861
if (service.capacityType != EnvironmentCapacityType.FARGATE) {

packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/assign-public-ip/task-record-manager.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import * as sqs from '@aws-cdk/aws-sqs';
1111
import * as cdk from '@aws-cdk/core';
1212
import * as customresources from '@aws-cdk/custom-resources';
1313

14+
// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
15+
// eslint-disable-next-line no-duplicate-imports, import/order
16+
import { Construct } from '@aws-cdk/core';
17+
1418
export interface TaskRecordManagerProps {
1519
service: ecs.Ec2Service | ecs.FargateService;
1620
dnsZone: route53.IHostedZone;
@@ -21,8 +25,8 @@ export interface TaskRecordManagerProps {
2125
* An event-driven serverless app to maintain a list of public ips in a Route 53
2226
* hosted zone.
2327
*/
24-
export class TaskRecordManager extends cdk.Construct {
25-
constructor(scope: cdk.Construct, id: string, props: TaskRecordManagerProps) {
28+
export class TaskRecordManager extends Construct {
29+
constructor(scope: Construct, id: string, props: TaskRecordManagerProps) {
2630
super(scope, id);
2731

2832
// Poison pills go here.

packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/cloudwatch-agent.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import * as ecs from '@aws-cdk/aws-ecs';
22
import * as iam from '@aws-cdk/aws-iam';
3-
import * as cdk from '@aws-cdk/core';
43
import { Service } from '../service';
54
import { ServiceExtension } from './extension-interfaces';
65

6+
// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
7+
// eslint-disable-next-line no-duplicate-imports, import/order
8+
import { Construct } from '@aws-cdk/core';
9+
710
const CLOUDWATCH_AGENT_IMAGE = 'amazon/cloudwatch-agent:latest';
811

912
/**
@@ -28,7 +31,7 @@ export class CloudwatchAgentExtension extends ServiceExtension {
2831
super('cloudwatchAgent');
2932
}
3033

31-
public prehook(service: Service, scope: cdk.Construct) {
34+
public prehook(service: Service, scope: Construct) {
3235
this.parentService = service;
3336
this.scope = scope;
3437
}
@@ -70,4 +73,4 @@ export class CloudwatchAgentExtension extends ServiceExtension {
7073
});
7174
}
7275
}
73-
}
76+
}

packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/container.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import * as ecs from '@aws-cdk/aws-ecs';
2-
import * as cdk from '@aws-cdk/core';
32
import { Service } from '../service';
43
import { ServiceExtension } from './extension-interfaces';
54

5+
// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
6+
// eslint-disable-next-line no-duplicate-imports, import/order
7+
import { Construct } from '@aws-cdk/core';
8+
69
/**
710
* Setting for the main application container of a service
811
*/
@@ -59,7 +62,7 @@ export class Container extends ServiceExtension {
5962
}
6063

6164
// @ts-ignore - Ignore unused params that are required for abstract class extend
62-
public prehook(service: Service, scope: cdk.Construct) {
65+
public prehook(service: Service, scope: Construct) {
6366
this.parentService = service;
6467
}
6568

@@ -142,4 +145,4 @@ export class Container extends ServiceExtension {
142145
});
143146
}
144147
}
145-
}
148+
}

packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/extension-interfaces.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import * as ecs from '@aws-cdk/aws-ecs';
22
import * as cdk from '@aws-cdk/core';
33
import { Service } from '../service';
44

5+
// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
6+
// eslint-disable-next-line no-duplicate-imports, import/order
7+
import { Construct } from '@aws-cdk/core';
8+
59
/**
610
* A list of the capacity types that are supported. These
711
* capacity types may change the behavior of an extension.
@@ -154,7 +158,7 @@ export abstract class ServiceExtension {
154158
* @param parent - The parent service which this extension has been added to
155159
* @param scope - The scope that this extension should create resources in
156160
*/
157-
public prehook(parent: Service, scope: cdk.Construct) {
161+
public prehook(parent: Service, scope: Construct) {
158162
this.parentService = parent;
159163
this.scope = scope;
160164
}

packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/firelens.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import { Service } from '../service';
55
import { Container } from './container';
66
import { ContainerMutatingHook, ServiceExtension } from './extension-interfaces';
77

8+
// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
9+
// eslint-disable-next-line no-duplicate-imports, import/order
10+
import { Construct } from '@aws-cdk/core';
11+
812
/**
913
* Settings for the hook which mutates the application container
1014
* to route logs through FireLens
@@ -63,7 +67,7 @@ export class FireLensExtension extends ServiceExtension {
6367
super('firelens');
6468
}
6569

66-
public prehook(service: Service, scope: cdk.Construct) {
70+
public prehook(service: Service, scope: Construct) {
6771
this.parentService = service;
6872

6973
// Create a log group for the service, into which FireLens

packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/http-load-balancer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import * as cdk from '@aws-cdk/core';
44
import { Service } from '../service';
55
import { ServiceExtension, ServiceBuild } from './extension-interfaces';
66

7+
// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
8+
// eslint-disable-next-line no-duplicate-imports, import/order
9+
import { Construct } from '@aws-cdk/core';
10+
711
/**
812
* This extension add a public facing load balancer for sending traffic
913
* to one or more replicas of the application container
@@ -17,7 +21,7 @@ export class HttpLoadBalancerExtension extends ServiceExtension {
1721
}
1822

1923
// Before the service is created go ahead and create the load balancer itself.
20-
public prehook(service: Service, scope: cdk.Construct) {
24+
public prehook(service: Service, scope: Construct) {
2125
this.parentService = service;
2226

2327
this.loadBalancer = new alb.ApplicationLoadBalancer(scope, `${this.parentService.id}-load-balancer`, {

packages/@aws-cdk-containers/ecs-service-extensions/lib/extensions/xray.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import * as cdk from '@aws-cdk/core';
44
import { Service } from '../service';
55
import { ServiceExtension } from './extension-interfaces';
66

7+
// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
8+
// eslint-disable-next-line no-duplicate-imports, import/order
9+
import { Construct } from '@aws-cdk/core';
10+
711
const XRAY_DAEMON_IMAGE = 'amazon/aws-xray-daemon:latest';
812

913
/**
@@ -17,7 +21,7 @@ export class XRayExtension extends ServiceExtension {
1721
}
1822

1923
// @ts-ignore - Ignore unused params that are required for abstract class extend
20-
public prehook(service: Service, scope: cdk.Construct) {
24+
public prehook(service: Service, scope: Construct) {
2125
this.parentService = service;
2226
}
2327

0 commit comments

Comments
 (0)