Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove DockerHub class #1153

Merged
merged 1 commit into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion examples/cdk-examples-typescript/hello-cdk-ecs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ class BonjourECS extends cdk.Stack {
const ecsService = new ecs.LoadBalancedEc2Service(this, "Ec2Service", {
cluster,
memoryLimitMiB: 512,
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
});

// ecsService.addTracing

// Output the DNS where you can access your service
new cdk.Output(this, 'LoadBalancerDNS', { value: ecsService.loadBalancer.dnsName });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BonjourFargate extends cdk.Stack {
// Instantiate Fargate Service with just cluster and image
const fargateService = new ecs.LoadBalancedFargateService(this, "FargateService", {
cluster,
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
});

// Output the DNS where you can access your service
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-ecs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ const taskDefinition = new ecs.TaskDefinition(this, 'TaskDef', {
#### Images

Images supply the software that runs inside the container. Images can be
obtained from either DockerHub or from ECR repositories:
obtained from either DockerHub or from ECR repositories, or built directly from a local Dockerfile.

* `ecs.ContainerImage.fromDockerHub(imageName)`: use a publicly available image from
DockerHub.
* `ecs.ContaienrImage.fromEcrRepository(repo, tag)`: use the given ECR repository as the image
to start.
* `ecs.ContainerImage.fromEcrRepository(repo, tag)`: use the given ECR repository as the image
to start. If no tag is provided, "latest" is assumed.
* `ecs.ContainerImage.fromAsset(this, 'Image', { directory: './image' })`: build and upload an
image directly from a `Dockerfile` in your source directory.

Expand Down Expand Up @@ -240,4 +240,4 @@ EC2 instance group so that your instance count scales with demand.

- [ ] Instance AutoScaling
- [ ] Service Discovery Integration
- [ ] Private registry authentication
- [ ] Private registry authentication
12 changes: 0 additions & 12 deletions packages/@aws-cdk/aws-ecs/lib/images/dockerhub.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
import { ContainerDefinition } from "../container-definition";
import { IContainerImage } from "../container-image";

/**
* Factory for DockerHub images
*/
export class DockerHub {
/**
* Reference an image on DockerHub
*/
public static image(name: string): IContainerImage {
return new DockerHubImage(name);
}
}

/**
* A DockerHub image
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ec2 = require('@aws-cdk/aws-ec2');
import cdk = require('@aws-cdk/cdk');
import { Cluster } from './cluster';
import { DockerHub } from './images/dockerhub';
import { ContainerImage } from './container-image';
import { LoadBalancedFargateService } from './load-balanced-fargate-service';

/**
Expand Down Expand Up @@ -97,7 +97,7 @@ export class LoadBalancedFargateServiceApplet extends cdk.Stack {
memoryMiB: props.memoryMiB,
publicLoadBalancer: props.publicLoadBalancer,
publicTasks: props.publicTasks,
image: DockerHub.image(props.image),
image: ContainerImage.fromDockerHub(props.image),
desiredCount: props.desiredCount,
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef', {
});

const container = taskDefinition.addContainer('web', {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 256,
});

Expand All @@ -42,4 +42,4 @@ listener.addTargets('ECS', {

new cdk.Output(stack, 'LoadBalancerDNS', { value: lb.dnsName, });

app.run();
app.run();
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef', {
});

const container = taskDefinition.addContainer('web', {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 256,
});
container.addPortMappings({
Expand Down
28 changes: 14 additions & 14 deletions packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export = {
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand Down Expand Up @@ -97,7 +97,7 @@ export = {
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand Down Expand Up @@ -127,7 +127,7 @@ export = {
});

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand Down Expand Up @@ -159,7 +159,7 @@ export = {
});

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand Down Expand Up @@ -210,7 +210,7 @@ export = {
});

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand All @@ -236,7 +236,7 @@ export = {
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand Down Expand Up @@ -265,7 +265,7 @@ export = {
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand Down Expand Up @@ -296,7 +296,7 @@ export = {
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand Down Expand Up @@ -327,7 +327,7 @@ export = {
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand All @@ -354,7 +354,7 @@ export = {
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand Down Expand Up @@ -384,7 +384,7 @@ export = {
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand All @@ -411,7 +411,7 @@ export = {
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand Down Expand Up @@ -442,7 +442,7 @@ export = {
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand Down Expand Up @@ -470,7 +470,7 @@ export = {
cluster.addDefaultAutoScalingGroupCapacity({ instanceType: new ec2.InstanceType('t2.micro') });
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TD', { networkMode: ecs.NetworkMode.Host });
const container = taskDefinition.addContainer('web', {
image: ecs.DockerHub.image('test'),
image: ecs.ContainerImage.fromDockerHub('test'),
memoryLimitMiB: 1024,
});
container.addPortMappings({ containerPort: 808 });
Expand Down
12 changes: 6 additions & 6 deletions packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-task-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export = {
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

const container = taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512 // add validation?
});

Expand Down Expand Up @@ -104,7 +104,7 @@ export = {
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

const container = taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand Down Expand Up @@ -154,7 +154,7 @@ export = {
});

const container = taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
memoryLimitMiB: 512
});

Expand Down Expand Up @@ -200,7 +200,7 @@ export = {

taskDefinition.addContainer("web", {
memoryLimitMiB: 1024,
image: ecs.DockerHub.image("amazon/amazon-ecs-sample")
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample")
});

// THEN
Expand All @@ -226,7 +226,7 @@ export = {
// });

// taskDefinition.addContainer("web", {
// image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
// image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
// memoryLimitMiB: 512
// });

Expand All @@ -243,7 +243,7 @@ export = {
// const stack = new cdk.Stack();
// const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef', {});
// const container = taskDefinition.addContainer("web", {
// image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
// image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
// memoryLimitMiB: 512 // add validation?
// });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef', {
});

const container = taskDefinition.addContainer('web', {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
});

container.addPortMappings({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export = {
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'FargateTaskDef');

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
});

new ecs.FargateService(stack, "FargateService", {
Expand Down Expand Up @@ -107,7 +107,7 @@ export = {
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'FargateTaskDef');

taskDefinition.addContainer("web", {
image: ecs.DockerHub.image("amazon/amazon-ecs-sample"),
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"),
});

new ecs.FargateService(stack, "FargateService", {
Expand All @@ -128,4 +128,4 @@ export = {
test.done();
},
}
};
};
Loading